Package org.apache.lenya.cms.publication

Examples of org.apache.lenya.cms.publication.DocumentManager


        String navigationTitle = DocumentHelper.getSimpleElementText(element);

        String contentUri = baseUri + path + "/index_" + language;
        String metaUri = contentUri + ".meta";

        DocumentManager docManager = null;
        ServiceSelector selector = null;
        ResourceType resourceType = null;
        SourceResolver resolver = null;
        try {

            org.w3c.dom.Document xml = SourceUtil.readDOM(metaUri, this.manager);
            NamespaceHelper helper = new NamespaceHelper(
                    "http://apache.org/cocoon/lenya/page-envelope/1.0", "", xml);
            Element metaElement = helper.getFirstChild(xml.getDocumentElement(), "meta");
            Element internalElement = helper.getFirstChild(metaElement, "internal");
            Element resourceTypeElement = helper.getFirstChild(internalElement, "resourceType");
            String resourceTypeName = DocumentHelper.getSimpleElementText(resourceTypeElement);

            Element mimeTypeElement = helper.getFirstChild(internalElement, "mimeType");
            String mimeType = DocumentHelper.getSimpleElementText(mimeTypeElement);

            selector = (ServiceSelector) this.manager.lookup(ResourceType.ROLE + "Selector");
            resourceType = (ResourceType) selector.select(resourceTypeName);

            docManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
            Document newDoc;
            SiteStructure site = area.getSite();
            if (!site.contains(path) || site.getNode(path).getLanguages().length == 0) {
                newDoc = docManager.add(area.getPublication().getFactory(), resourceType,
                        contentUri, area.getPublication(), area.getName(), path, language, "xml",
                        navigationTitle, visibleInNav);
                newDoc.setMimeType(mimeType);
            } else {
                SiteNode node = site.getNode(path);
                Document doc = node.getLink(node.getLanguages()[0]).getDocument();
                newDoc = docManager.addVersion(doc, area.getName(), language, true);
                resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
                SourceUtil.copy(resolver, contentUri, newDoc.getOutputStream());
                newDoc.getLink().setLabel(navigationTitle);
            }
View Full Code Here


    protected void publish(Document authoringDocument) throws DocumentException, SiteException,
            PublicationException {

        createAncestorNodes(authoringDocument);

        DocumentManager documentManager = null;

        try {
            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
            documentManager.copyToArea(authoringDocument, Publication.LIVE_AREA);

            boolean notify = Boolean.valueOf(getBooleanCheckboxParameter(PARAM_SEND_NOTIFICATION))
                    .booleanValue();
            if (notify) {
                sendNotification(authoringDocument);
View Full Code Here

    protected Document createCollectionDocument(Publication pub) throws ServiceException,
            DocumentBuildException, PublicationException {
        ServiceSelector typeSelector = null;
        ResourceType type = null;
        DocumentManager docMgr = null;
        Document doc;
        try {
            typeSelector = (ServiceSelector) getManager().lookup(ResourceType.ROLE + "Selector");
            type = (ResourceType) typeSelector.select("collection");
            docMgr = (DocumentManager) getManager().lookup(DocumentManager.ROLE);
            ResourceType.Sample sample = type.getSample(type.getSampleNames()[0]);
            doc = docMgr.add(getFactory(), type, sample.getUri(), pub, "authoring", "en", "xml");
            doc.setMimeType(sample.getMimeType());
           
        } finally {
            if (docMgr != null) {
                getManager().release(docMgr);
View Full Code Here

     * @throws Exception
     */
    public void testCheckIn() throws Exception {
        login("lenya");

        DocumentManager docMgr = null;
        try {
            docMgr = (DocumentManager) getManager().lookup(DocumentManager.ROLE);
            Document source = getPublication("test").getArea("authoring").getSite().getNode(
                    "/links").getLink("en").getDocument();
            Document target = docMgr.addVersion(source, "authoring", "es");
            target.delete();
        } finally {
            if (docMgr != null) {
                getManager().release(docMgr);
            }
View Full Code Here

        super.doExecute();

        Document targetDoc;
        Document source = getSourceDocument();
        DocumentLocator target = getTargetLocator();
        DocumentManager documentManager = null;
        try {
            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
            documentManager.moveAll(source.area(), source.getPath(), source.area(), target
                    .getPath());
            targetDoc = getDocumentFactory().get(target);
        } finally {
            if (documentManager != null) {
                this.manager.release(documentManager);
View Full Code Here

     */
    protected void deactivate(Document authoringDocument) {

        boolean success = false;

        DocumentManager documentManager = null;
        try {
            Document liveDocument = authoringDocument.getIdentityMap()
                    .getAreaVersion(authoringDocument, Publication.LIVE_AREA);

            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
            documentManager.delete(liveDocument);

            WorkflowUtil.invoke(this.manager, getLogger(), authoringDocument, getEvent());
            success = true;
        } catch (Exception e) {
            throw new RuntimeException(e);
View Full Code Here

        // create new document
        // implementation note: since blog does not have a hierarchy,
        // document id (full path) and document id-name (this leaf's id)
        // are the same
        DocumentManager documentManager = null;
        DocumentTypeBuilder documentTypeBuilder = null;
        try {
            documentTypeBuilder = (DocumentTypeBuilder) this.manager
                    .lookup(DocumentTypeBuilder.ROLE);

            DocumentType documentType = documentTypeBuilder
                    .buildDocumentType(getDocumentTypeName(), getSourceDocument().getPublication());

            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);

            DocumentIdentityMap map = (DocumentIdentityMap) getUnitOfWork().getIdentityMap();

            String documentId = getDocumentID();
            Document document = map.get(getSourceDocument().getPublication(), getSourceDocument()
                    .getArea(), documentId, language);

            documentManager.add(document,
                    documentType,
                    getParameterAsString(DublinCore.ELEMENT_TITLE),
                    allParameters);
        } finally {
            if (documentManager != null) {
View Full Code Here

     * Publishes a document.
     * @param authoringDocument The authoring document.
     */
    protected void publish(Document authoringDocument) {

        DocumentManager documentManager = null;
        try {
            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
            documentManager.copyToArea(authoringDocument, Publication.LIVE_AREA);
            WorkflowUtil.invoke(this.manager, getLogger(), authoringDocument, getEvent());
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            if (documentManager != null) {
View Full Code Here

     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
     */
    protected void doExecute() throws Exception {
        super.doExecute();
       
        DocumentManager documentManager = null;
        try {
            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
            Document[] documents = getTrashDocuments();
            DocumentSet set = new DocumentSet(documents);
            documentManager.delete(set);
        }
        finally {
            if (documentManager != null) {
                this.manager.release(documentManager);
            }
View Full Code Here

        if (!Arrays.asList(getSupportedRelations()).contains(relation)) {
            addErrorMessage("The relation '" + relation + "' is not supported.");
        }

        DocumentManager documentManager = null;
        try {
            documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
            Document parent = getSourceDocument();
            Publication publication = getSourceDocument().getPublication();
            Document document = getSourceDocument().getIdentityMap().get(publication,
View Full Code Here

TOP

Related Classes of org.apache.lenya.cms.publication.DocumentManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.