Package org.apache.lenya.cms.site

Examples of org.apache.lenya.cms.site.SiteStructure


                        + "] must start with at least one slash.");
            }

            DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
            Publication pub = factory.getPublication(pubId);
            SiteStructure site = pub.getArea(areaName).getSite();

            String[] steps = relativePath.substring(1).split("/");

            String language = steps[0];
            String prefix = "/" + language;
            String path = relativePath.substring(prefix.length());

            if (site.contains(path, language)) {
                Document doc = site.getNode(path).getLink(language).getDocument();
                if (locationSteps.hasMoreTokens()) {
                    Query query = new Query(locationSteps.nextToken());
                    String format = query.getValue("format");
                    if (format != null) {
                        this.delegate = getFormatSource(doc, format);
View Full Code Here


     * @see org.apache.lenya.cms.usecase.AbstractUsecase#getNodesToLock()
     */
    protected Node[] getNodesToLock() throws UsecaseException {
        List nodes = new ArrayList();
        if(getSourceDocument() != null) {
            SiteStructure structure = getSourceDocument().area().getSite();
            nodes.add(structure.getRepositoryNode());
        }

        return (Node[]) nodes.toArray(new Node[nodes.size()]);
    }
View Full Code Here

            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

    }

    public Document get(DocumentLocator locator) throws DocumentBuildException {
        try {
            Publication pub = getPublication(locator.getPublicationId());
            SiteStructure site = pub.getArea(locator.getArea()).getSite();
            String uuid = site.getNode(locator.getPath()).getUuid();
            return get(pub, locator.getArea(), uuid, locator.getLanguage());
        } catch (PublicationException e) {
            throw new DocumentBuildException(e);
        }
    }
View Full Code Here

        if (!builder.isValidDocumentName(nodeId)) {
            addErrorMessage("The document ID is not valid.");
        } else {
            DocumentLocator target = getTargetLocator();
            Publication pub = getDocumentFactory().getPublication(target.getPublicationId());
            SiteStructure site = pub.getArea(target.getArea()).getSite();
            if (site.contains(target.getPath(), target.getLanguage())) {
                addErrorMessage("The document does already exist.");
            }
        }
    }
View Full Code Here

            throw new DocumentException(e);
        }
    }

    public DocumentLocator getLocator() {
        SiteStructure structure = area().getSite();
        if (!structure.containsByUuid(getUUID(), getLanguage())) {
            throw new RuntimeException("The document [" + this
                    + "] is not referenced in the site structure.");
        }
        try {
            return DocumentLocator.getLocator(getPublication().getId(), getArea(), structure
                    .getByUuid(getUUID(), getLanguage()).getNode().getPath(), getLanguage());
        } catch (SiteException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

            throw new DocumentException(e);
        }
    }

    public Link getLink() throws DocumentException {
        SiteStructure structure = area().getSite();
        try {
            if (structure.containsByUuid(getUUID(), getLanguage())) {
                return structure.getByUuid(getUUID(), getLanguage());
            } else {
                throw new DocumentException("The document [" + this
                        + "] is not referenced in the site structure [" + structure + "].");
            }
        } catch (Exception e) {
View Full Code Here

            Document[] documents = set.getDocuments();
            for (int i = 0; i < documents.length; i++) {
                nodes.add(documents[i].getRepositoryNode());
            }

            SiteStructure structure = getSourceDocument().area().getSite();
            nodes.add(structure.getRepositoryNode());
            return (Node[]) nodes.toArray(new Node[nodes.size()]);

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

                        + "] must start with at least one slash.");
            }

            DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
            Publication pub = factory.getPublication(pubId);
            SiteStructure site = pub.getArea(areaName).getSite();

            String[] steps = relativePath.substring(1).split("/");

            String language = steps[0];
            String prefix = "/" + language;
            String path = relativePath.substring(prefix.length());

            if (site.contains(path, language)) {
                Document doc = site.getNode(path).getLink(language).getDocument();
                String docUri = "lenya-document:" + doc.getUUID() + ",lang=" + doc.getLanguage()
                        + ",area=" + doc.getArea() + ",pub=" + doc.getPublication().getId();

                if (locationSteps.hasMoreTokens()) {
                    String queryString = locationSteps.nextToken();
View Full Code Here

            String destAreaName, String path1, String path2) throws PublicationException,
            SiteException {
       
        DocumentFactory factory = getFactory();
        Publication pub = factory.getPublication("test");
        SiteStructure sourceArea = pub.getArea(sourceAreaName).getSite();
        SiteStructure destArea = pub.getArea(destAreaName).getSite();

        if (destArea.contains(path1)) {
            destArea.getNode(path1).delete();
        }
        if (destArea.contains(path2)) {
            destArea.getNode(path2).delete();
        }
       
        assertFalse(destArea.contains(path1));
        assertFalse(destArea.contains(path2));
       
        // copy second node first to test correct ordering
        doTestCopyToArea(docManager, path2, sourceAreaName, destAreaName);
        doTestCopyToArea(docManager, path1, sourceAreaName, destAreaName);

        List sourceNodes = Arrays.asList(sourceArea.getNodes());

        SiteNode authoringNode1 = sourceArea.getNode(path1);
        assertTrue(sourceNodes.contains(authoringNode1));
        int sourcePos1 = sourceNodes.indexOf(authoringNode1);

        SiteNode sourceNode2 = sourceArea.getNode(path2);
        int sourcePos2 = sourceNodes.indexOf(sourceNode2);

        assertTrue(sourcePos1 < sourcePos2);

        assertTrue(destArea.contains(path1));
        List liveNodes = Arrays.asList(destArea.getNodes());
        SiteNode liveNode1 = destArea.getNode(path1);
        assertTrue(liveNodes.contains(liveNode1));
        int livePos1 = liveNodes.indexOf(liveNode1);

        SiteNode liveNode2 = destArea.getNode(path2);
        int livePos2 = liveNodes.indexOf(liveNode2);

        assertTrue(livePos1 < livePos2);
    }
View Full Code Here

TOP

Related Classes of org.apache.lenya.cms.site.SiteStructure

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.