Package org.apache.lenya.cms.publication

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


     */
    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());
               
                // lock the authoring site to avoid having live nodes for which no corresponding
                // authoring node exists
                nodes.add(doc.area().getSite().getRepositoryNode());
               
                // lock the live site to avoid overriding changes made by others
                SiteStructure liveSite = doc.getPublication().getArea(Publication.LIVE_AREA).getSite();
                nodes.add(liveSite.getRepositoryNode());
            }

            return (org.apache.lenya.cms.repository.Node[]) nodes
                    .toArray(new org.apache.lenya.cms.repository.Node[nodes.size()]);
View Full Code Here


     */
    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;
            }

            checkMissingAncestors();
View Full Code Here

       
        if (!getParameterAsBoolean(PARAM_CHECK_MISSING_ANCESTORS, true)) {
            return;
        }
       
        Document document = getSourceDocument();
        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

        Session aliceSession = login("alice");
        Publication alicePub = getPublication(aliceSession, "test");
        final SiteStructure authSite = alicePub.getArea("authoring").getSite();
        assertTrue(authSite.contains("/tutorial"));
        final Document index = authSite.getNode("/index").getLink("en").getDocument();
        final org.w3c.dom.Document indexDoc = DocumentHelper.readDocument(index.getRepositoryNode()
                .getInputStream());

        // https://issues.apache.org/bugzilla/show_bug.cgi?id=50493
        assertNotNull("No rewritten links found.",
                XPathAPI.selectSingleNode(indexDoc, "//*[starts-with(@href, 'lenya-document:')]"));
View Full Code Here

        Publication pub = getPublication("test");
        Area area = pub.getArea("authoring");
        SiteStructure site = area.getSite();

        Document source = site.getNode("/index").getLink("en").getDocument();
        Document target = site.getNode("/tutorial").getLink("en").getDocument();

        LinkManager linkManager = null;
        LinkResolver resolver = null;
        try {
            linkManager = (LinkManager) getManager().lookup(LinkManager.ROLE);
View Full Code Here

        if (docs.length == 0) {
            getLogger().warn("To run this test, the default publication has to contain documents.");
            return;
        }

        final Document source = docs[0];

        final Publication pub = getPublication("test");
        final Area area = pub.getArea("authoring");
        final SiteStructure site = area.getSite();

        final Document target = site.getNode("/index").getLink("en").getDocument();
        final String queryString = "?format=xhtml";
        final String baseLink = "lenya-document:" + target.getUUID() + ",lang="
                + target.getLanguage();
        final String relativeLink = baseLink;
        final String absoluteLink = relativeLink + ",pub=test";

        SourceResolver sourceResolver = null;
        LinkResolver resolver = null;
View Full Code Here

            resourceTypeSelector = (ServiceSelector) getManager().lookup(
                    ResourceType.ROLE + "Selector");
            ResourceType type = (ResourceType) resourceTypeSelector.select("entry");
            String contentSourceUri = "context://sitemap.xmap";

            Document doc = docManager.add(factory, type, contentSourceUri, pub,
                    Publication.AUTHORING_AREA, "en", "xml");

            structure.add(PATH, doc);
            assertTrue(structure.contains(PATH));
            Document linkDoc = structure.getNode(PATH).getLink("en").getDocument();
            assertSame(linkDoc, doc);

            if (!(structure instanceof DocumentStore)) {
                Link link = doc.getLink();
                checkSetLabel(link);
View Full Code Here

            Link link = node.getLink(languages[i]);
            assertEquals(link.getLanguage(), languages[i]);
            assertNotNull(link.getLabel());
           
            if (node.getUuid() != null) {
                Document doc = link.getDocument();
                assertNotNull(doc);
   
                String docUuid = doc.getUUID();
                String nodeUuid = node.getUuid();
   
                assertNotNull(doc.getUUID());
                assertEquals(docUuid, nodeUuid);
                assertEquals(doc.getLanguage(), link.getLanguage());
   
                // it may not be allowed to insert the doc twice
                try {
                    siteManager.add("/sidebar", doc);
                    assertTrue("No exception thrown", 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.