Package org.apache.lenya.cms.publication

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


     */
    protected void doCheckPreconditions() throws Exception {
        super.doCheckPreconditions();
        if (!hasErrors()) {

            Document document = getSourceDocument();

            if (!document.getArea().equals(Publication.AUTHORING_AREA)) {
                addErrorMessage("This usecase can only be invoked from the authoring area.");
                return;
            }

            Publication publication = document.getPublication();
            DocumentFactory map = document.getFactory();
            SiteStructure liveSite = publication.getArea(Publication.LIVE_AREA).getSite();

            List missingDocuments = new ArrayList();

            ServiceSelector selector = null;
            SiteManager siteManager = null;
            try {
                selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
                siteManager = (SiteManager) selector.select(publication.getSiteManagerHint());

                if (!liveSite.contains(document.getPath())) {
                    DocumentLocator liveLoc = document.getLocator().getAreaVersion(
                            Publication.LIVE_AREA);
                    DocumentLocator[] requiredNodes = siteManager
                            .getRequiredResources(map, liveLoc);
                    for (int i = 0; i < requiredNodes.length; i++) {
                        String path = requiredNodes[i].getPath();
                        if (!liveSite.contains(path)) {
                            Link link = getExistingLink(path, document);
                            if (link != null) {
                                missingDocuments.add(link.getDocument());
                            }
                        }

                    }
                }
            } catch (Exception e) {
                throw new RuntimeException(e);
            } finally {
                if (selector != null) {
                    if (siteManager != null) {
                        selector.release(siteManager);
                    }
                    this.manager.release(selector);
                }
            }

            if (!missingDocuments.isEmpty()) {
                addErrorMessage("publish-missing-documents");
                for (Iterator i = missingDocuments.iterator(); i.hasNext();) {
                    Document doc = (Document) i.next();
                    /*
                     * This doesn't work yet, see
                     * https://issues.apache.org/jira/browse/COCOON-2057
                     * String[] params = { doc.getCanonicalWebappURL(),
                     * doc.getPath() + " (" + doc.getLanguage() + ")" };
                     */
                    String[] params = { doc.getPath() + ":" + doc.getLanguage(),
                            DublinCoreHelper.getTitle(doc, true) };
                    addErrorMessage("missing-document", params);
                }
            }
           
View Full Code Here


        User user = PolicyUtil.getUser(this.manager, authoringDocument.getCanonicalWebappURL(),
                userId, getLogger());

        Identifiable[] recipients = { user };

        Document liveVersion = authoringDocument.getAreaVersion(Publication.LIVE_AREA);
        String url;

        url = getWebUrl(liveVersion);
        User sender = getSession().getIdentity().getUser();
       
View Full Code Here

                resolver = (LinkResolver) this.manager.lookup(LinkResolver.ROLE);
                org.apache.lenya.cms.linking.Link[] links = linkMgr.getLinksFrom(this.document);
                for (int i = 0; i < links.length; i++) {
                    LinkTarget target = resolver.resolve(this.document, links[i].getUri());
                    if (target.exists()) {
                        Document doc = target.getDocument();
                        if (!doc.existsAreaVersion(Publication.LIVE_AREA)) {
                            docs.add(doc);
                        }
                    }
                }
            } catch (Exception e) {
View Full Code Here

    protected void doCheckPreconditions() throws Exception {
        super.doCheckPreconditions();

        if (!hasErrors()) {
           
            Document doc = getSourceDocument();

            if (!doc.getArea().equals(Publication.AUTHORING_AREA)) {
                addErrorMessage("This usecase can only be invoked from the authoring area.");
                return;
            }

            if (!doc.existsAreaVersion(Publication.LIVE_AREA)) {
                addErrorMessage("This usecase can only be invoked when the live version exists.");
            } else {
                Document liveDoc = doc.getAreaVersion(Publication.LIVE_AREA);
                NodeSet subSite = SiteUtil.getSubSite(this.manager, liveDoc.getLink().getNode());
                SiteNode node = liveDoc.getLink().getNode();
                subSite.remove(node);

                if (!subSite.isEmpty()) {
                    addErrorMessage("You can't deactivate this document because it has children.");
                }
View Full Code Here

     */
    protected org.apache.lenya.cms.repository.Node[] getNodesToLock() throws UsecaseException {
        try {
            List nodes = new ArrayList();

            Document doc = getSourceDocument();
            if (doc != null) {
                nodes.add(doc.getRepositoryNode());
                Document liveDoc = doc.getAreaVersion(Publication.LIVE_AREA);
                nodes.add(liveDoc.getRepositoryNode());
                nodes.add(liveDoc.area().getSite().getRepositoryNode());
            }
            return (org.apache.lenya.cms.repository.Node[]) nodes.toArray(new org.apache.lenya.cms.repository.Node[nodes.size()]);

        } catch (Exception e) {
            throw new UsecaseException(e);
View Full Code Here

        boolean success = false;

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

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

            success = true;
View Full Code Here

        return "edit";
    }

    public Object getParameter(String name) {
        if (name.equals(Usecase.PARAMETER_ITEM_STATE)) {
            Document doc = getSourceDocument();
            try {
                return doc != null ? Boolean.valueOf(doc.getLink().getNode().isVisible()) : null;
            } catch (DocumentException e) {
                throw new RuntimeException(e);
            }
        }
        else {
View Full Code Here

        super.doCheckPreconditions();
        if (hasErrors()) {
            return;
        }

        Document doc = getSourceDocument();
        if (!getSourceDocument().getArea().equals(Publication.AUTHORING_AREA)) {
            addErrorMessage("This usecase can only be invoked in the authoring area!");
        }

        String[] languages = doc.getLanguages();
        for (int i = 0; i < languages.length; i++) {
            Document version = doc.getTranslation(languages[i]);
            UsecaseWorkflowHelper.checkWorkflow(this.manager, this, getEvent(), version,
                    getLogger());
        }
    }
View Full Code Here

        }
    }

    protected void doExecute() throws Exception {
        super.doExecute();
        Document doc = getSourceDocument();
        SiteNode node = doc.getLink().getNode();
        node.setVisible(!node.isVisible());

        String[] languages = doc.getLanguages();
        for (int i = 0; i < languages.length; i++) {
            Document version = doc.getTranslation(languages[i]);
            WorkflowUtil.invoke(this.manager, getSession(), getLogger(), version, getEvent());
        }
    }
View Full Code Here

            User user = PolicyUtil.getUser(this.manager, authoringDocument.getCanonicalWebappURL(),
                    userId, getLogger());

            Identifiable[] recipients = { user };

            Document authoringVersion = authoringDocument
                    .getAreaVersion(Publication.AUTHORING_AREA);
            String url;

            Proxy proxy = authoringVersion.getPublication().getProxy(authoringVersion, false);
            if (proxy != null) {
                url = proxy.getURL(authoringVersion);
            } else {
                Request request = ContextHelper.getRequest(this.context);
                final String serverUrl = "http://" + request.getServerName() + ":"
                        + request.getServerPort();
                final String webappUrl = authoringVersion.getCanonicalWebappURL();
                url = serverUrl + request.getContextPath() + webappUrl;
            }
           
            Text[] subjectParams = { new Text(getEvent(), true) };
            Text[] params = { new Text(reason, false), new Text(url, false) };
View Full Code Here

TOP

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

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.