Package org.apache.lenya.cms.site

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


    protected void copyInSiteStructure(Document sourceDoc, Document destDoc, String destPath)
            throws PublicationException, DocumentException, SiteException {

        String destArea = destDoc.getArea();

        SiteStructure destSite = sourceDoc.getPublication().getArea(destArea).getSite();

        if (sourceDoc.hasLink()) {
            if (destDoc.hasLink()) {
                Link srcLink = sourceDoc.getLink();
                Link destLink = destDoc.getLink();
                destLink.setLabel(srcLink.getLabel());
                destLink.getNode().setVisible(srcLink.getNode().isVisible());
            } else {
                String label = sourceDoc.getLink().getLabel();
                boolean visible = sourceDoc.getLink().getNode().isVisible();
                if (destSite.contains(sourceDoc.getLink().getNode().getPath())) {
                    addToSiteManager(destPath, destDoc, label, visible);
                } else {

                    String followingSiblingPath = null;

                    if (sourceDoc.getPath().equals(destPath)) {
                        SiteStructure sourceSite = sourceDoc.area().getSite();

                        SiteNode[] sourceSiblings;
                        SiteNode sourceNode = sourceDoc.getLink().getNode();
                        if (sourceNode.isTopLevel()) {
                            sourceSiblings = sourceSite.getTopLevelNodes();
                        } else if (sourceNode.getParent() != null) {
                            sourceSiblings = sourceNode.getParent().getChildren();
                        } else {
                            sourceSiblings = new SiteNode[1];
                            sourceSiblings[0] = sourceNode;
View Full Code Here


        if (!destination.getArea().equals(sourceDocument.getArea())) {
            throw new PublicationException("Can't move to a different area!");
        }

        SiteStructure site = sourceDocument.area().getSite();
        if (site.contains(destination.getPath())) {
            throw new PublicationException("The path [" + destination
                    + "] is already contained in this publication!");
        }

        String label = sourceDocument.getLink().getLabel();
        boolean visible = sourceDocument.getLink().getNode().isVisible();
        sourceDocument.getLink().delete();

        site.add(destination.getPath(), sourceDocument);
        sourceDocument.getLink().setLabel(label);
        sourceDocument.getLink().getNode().setVisible(visible);

    }
View Full Code Here

        return this.context;
    }

    public void moveAll(Area sourceArea, String sourcePath, Area targetArea, String targetPath)
            throws PublicationException {
        SiteStructure site = sourceArea.getSite();

        SiteNode root = site.getNode(sourcePath);
        List subsite = preOrder(root);

        for (Iterator n = subsite.iterator(); n.hasNext();) {
            SiteNode node = (SiteNode) n.next();
            String subPath = node.getPath().substring(sourcePath.length());
View Full Code Here

    }

    public void copyAll(Area sourceArea, String sourcePath, Area targetArea, String targetPath)
            throws PublicationException {

        SiteStructure site = sourceArea.getSite();
        SiteNode root = site.getNode(sourcePath);
       
        List preOrder = preOrder(root);
        for (Iterator i = preOrder.iterator(); i.hasNext(); ) {
            SiteNode node = (SiteNode) i.next();
            String nodeSourcePath = node.getPath();
View Full Code Here

     */
    public void testLinks() throws Exception {

        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

        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";
View Full Code Here

        ServiceSelector resourceTypeSelector = null;

        try {
            selector = (ServiceSelector) getManager().lookup(SiteManager.ROLE + "Selector");
            siteManager = (SiteManager) selector.select(pub.getSiteManagerHint());
            SiteStructure structure = siteManager.getSiteStructure(factory, pub,
                    Publication.AUTHORING_AREA);

            docManager = (DocumentManager) getManager().lookup(DocumentManager.ROLE);

            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);
            }

            SiteNode[] nodes = structure.getNodes();
            assertTrue(nodes.length > 0);

            for (int i = 0; i < nodes.length; i++) {

                assertTrue(structure.contains(nodes[i].getPath()));

                SiteNode node = structure.getNode(nodes[i].getPath());
                assertNotNull(node);
                assertEquals(nodes[i], node);

                checkLinks(siteManager, node);
            }
           
            doc.getLink().delete();
            assertFalse(structure.containsByUuid(doc.getUUID(), doc.getLanguage()));
            assertFalse(structure.contains(PATH));
            assertFalse(structure.contains(PARENT_PATH));
           
        } finally {
            if (selector != null) {
                if (siteManager != null) {
                    selector.release(siteManager);
View Full Code Here

        verifyMigration(area, path2langs);
    }

    protected void verifyMigration(Area area, Map path2langs) throws SiteException,
            DocumentException {
        SiteStructure site = area.getSite();
        for (Iterator i = path2langs.keySet().iterator(); i.hasNext();) {
            String path = (String) i.next();
            String[] langs = (String[]) path2langs.get(path);
            SiteNode node = site.getNode(path);
            Document migratedDoc = node.getLink(node.getLanguages()[0]).getDocument();
            String[] migratedLangs = migratedDoc.getLanguages();
            assertEquals(Arrays.asList(langs), Arrays.asList(migratedLangs));
        }
    }
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

                // 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

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.