Package org.apache.lenya.cms.site.tree

Examples of org.apache.lenya.cms.site.tree.SiteTree


            _manager = (TreeSiteManager) selector.select(publication.getSiteManagerHint());
           
            DocumentIdentityMap map = new DocumentIdentityMap(this.manager, getLogger());

            if (name.equals(AUTHORING_NODE)) {
                SiteTree authoringTree = _manager.getTree(map,
                        publication,
                        Publication.AUTHORING_AREA);
                value = authoringTree.getNode(envelope.getDocument().getId());
            }

            if (name.equals(LIVE_NODE)) {
                SiteTree liveTree = _manager.getTree(map, publication, Publication.LIVE_AREA);
                value = liveTree.getNode(envelope.getDocument().getId());
            }

            if (name.equals(TRASH_NODE)) {
                SiteTree trashTree = _manager.getTree(map, publication, Publication.TRASH_AREA);
                value = trashTree.getNode(envelope.getDocument().getId());
            }

            if (name.equals(ARCHIVE_NODE)) {
                SiteTree archiveTree = _manager.getTree(map, publication, Publication.ARCHIVE_AREA);
                value = archiveTree.getNode(envelope.getDocument().getId());
            }
        } catch (Exception e) {
            throw new ConfigurationException("Obtaining value for [" + name + "] failed: ", e);
        }
        finally {
View Full Code Here


            siteManager = (SiteManager) selector.select(publication.getSiteManagerHint());
            SiteStructure structure = siteManager.getSiteStructure(getSourceDocument()
                    .getIdentityMap(), publication, getSourceDocument().getArea());
            if (structure instanceof SiteTree) {

                SiteTree tree = (SiteTree) structure;
                SiteTreeNode node = tree.getNode(getSourceDocument().getId());
                SiteTreeNode[] siblings = null;

                String direction = getParameterAsString(DIRECTION);
                if (direction.equals(UP)) {
                    siblings = node.getPrecedingSiblings();
View Full Code Here

            siteManager = (SiteManager) selector.select(publication.getSiteManagerHint());
            SiteStructure structure = siteManager.getSiteStructure(getSourceDocument()
                    .getIdentityMap(), publication, getSourceDocument().getArea());
            if (structure instanceof SiteTree) {

                SiteTree tree = (SiteTree) structure;
                String direction = getParameterAsString(DIRECTION);
                if (direction.equals(UP)) {
                    tree.moveUp(getSourceDocument().getId());
                } else if (direction.equals(DOWN)) {
                    tree.moveDown(getSourceDocument().getId());
                } else {
                    throw new IllegalArgumentException("The direction [" + direction
                            + "] is not supported.");
                }
            } else {
View Full Code Here

     * @throws SiteException if an error occurs.
     */
    protected SiteTree getTree(Area area) throws SiteException {

        String key = getKey(area);
        SiteTree sitetree;
        RepositoryItemFactory factory = new SiteTreeFactory(this.manager, getLogger());
        try {
            sitetree = (SiteTree) area.getPublication().getFactory().getSession()
                    .getRepositoryItem(factory, key);
        } catch (Exception e) {
View Full Code Here

    public boolean containsInAnyLanguage(Document doc) throws SiteException {
        return getTree(doc.area()).containsInAnyLanguage(doc.getUUID());
    }

    public void copy(Document srcDoc, Document destDoc) throws SiteException {
        SiteTree destinationTree = getTree(destDoc.area());

        try {
            TreeNodeImpl sourceNode = (TreeNodeImpl) srcDoc.getLink().getNode();

            SiteTreeNode[] siblings = sourceNode.getNextSiblings();
            SiteNode parent = sourceNode.getParent();
            String parentId = "";
            if (parent != null) {
                parentId = parent.getPath();
            }
            TreeNodeImpl sibling = null;
            String siblingPath = null;

            // same UUID -> insert at the same position
            if (srcDoc.getUUID().equals(destDoc.getUUID())) {
                for (int i = 0; i < siblings.length; i++) {
                    String path = parentId + "/" + siblings[i].getName();
                    sibling = (TreeNodeImpl) destinationTree.getNode(path);
                    if (sibling != null) {
                        siblingPath = path;
                        break;
                    }
                }
            }

            if (!sourceNode.hasLink(srcDoc.getLanguage())) {
                // the node that we're trying to publish
                // doesn't have this language
                throw new SiteException("The node " + srcDoc.getPath()
                        + " doesn't contain a label for language " + srcDoc.getLanguage());
            }

            String destPath = destDoc.getPath();

            Link link = sourceNode.getLink(srcDoc.getLanguage());
            SiteNode destNode = destinationTree.getNode(destPath);
            if (destNode == null) {
                if (siblingPath == null) {
                    // called for side effect of add, not return result
                    destNode = destinationTree.add(destPath);
                } else {
                    // called for side effect of add, not return result
                    destNode = destinationTree.add(destPath, siblingPath);
                }
                destinationTree.add(destPath, destDoc);
            } else {
                destDoc.getLink().setLabel(link.getLabel());
            }
        } catch (DocumentException e) {
            throw new SiteException(e);
View Full Code Here

    protected String computeUniquePath(DocumentFactory factory, DocumentLocator locator)
            throws SiteException {
        String path = locator.getPath();

        Publication pub;
        SiteTree tree;
        try {
            pub = factory.getPublication(locator.getPublicationId());
            tree = getTree(pub.getArea(locator.getArea()));
        } catch (PublicationException e) {
            throw new SiteException(e);
        }

        String suffix = null;
        int version = 0;
        String idwithoutsuffix = null;

        if (tree.contains(path)) {
            int n = path.lastIndexOf("/");
            String lastToken = "";
            String substring = path;
            lastToken = path.substring(n);
            substring = path.substring(0, n);

            int l = lastToken.length();
            int index = lastToken.lastIndexOf("-");
            if (0 < index && index < l && lastToken.substring(index + 1).matches("[\\d]*")) {
                suffix = lastToken.substring(index + 1);
                idwithoutsuffix = substring + lastToken.substring(0, index);
                version = Integer.parseInt(suffix);
            } else {
                idwithoutsuffix = substring + lastToken;
            }

            while (tree.contains(path)) {
                version = version + 1;
                path = idwithoutsuffix + "-" + version;
            }
        }

View Full Code Here

        try {
            areaObj = pub.getArea(area);
        } catch (PublicationException e) {
            throw new SiteException(e);
        }
        SiteTree tree = getTree(areaObj);
        SiteNode[] preOrder = tree.preOrder();
        List docs = new ArrayList();
        for (int i = 0; i < preOrder.length; i++) {
            String[] langs = preOrder[i].getLanguages();
            for (int l = 0; l < langs.length; l++) {
                docs.add(preOrder[i].getLink(langs[l]).getDocument());
View Full Code Here

    }

    public SiteNode[] getRequiringResources(DocumentFactory map, SiteNode resource)
            throws SiteException {
        NodeSet nodes = new NodeSet(this.manager);
        SiteTree tree = (SiteTree) resource.getStructure();

        TreeNode node = (TreeNode) tree.getNode(resource.getPath());
        if (node != null) {
            SiteNode[] preOrder = node.preOrder();

            // exclude original resource (does not require itself)
            for (int i = 1; i < preOrder.length; i++) {
View Full Code Here

    public RepositoryItem buildItem(Session session, String key) throws RepositoryException {
        String[] snippets = key.split(":");
        String publicationId = snippets[0];
        String areaName = snippets[1];
        SiteTree tree;
        SharedItemStore store = null;
        try {
            DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, session);
            Publication publication = factory.getPublication(publicationId);
            Area area = publication.getArea(areaName);
View Full Code Here

            Request request = ObjectModelHelper.getRequest(objectModel);
            Session session = RepositoryUtil.getSession(this.manager, request);
            DocumentFactory map = DocumentUtil.createDocumentFactory(this.manager, session);

            if (name.equals(AUTHORING_NODE)) {
                SiteTree authoringTree = _manager.getTree(map,
                        publication,
                        Publication.AUTHORING_AREA);
                value = authoringTree.getNode(envelope.getDocument().getPath());
            }

            if (name.equals(LIVE_NODE)) {
                SiteTree liveTree = _manager.getTree(map, publication, Publication.LIVE_AREA);
                value = liveTree.getNode(envelope.getDocument().getPath());
            }

            if (name.equals(TRASH_NODE)) {
                SiteTree trashTree = _manager.getTree(map, publication, Publication.TRASH_AREA);
                value = trashTree.getNode(envelope.getDocument().getPath());
            }

            if (name.equals(ARCHIVE_NODE)) {
                SiteTree archiveTree = _manager.getTree(map, publication, Publication.ARCHIVE_AREA);
                value = archiveTree.getNode(envelope.getDocument().getPath());
            }
        } catch (Exception e) {
            throw new ConfigurationException("Obtaining value for [" + name + "] failed: ", e);
        }
        finally {
View Full Code Here

TOP

Related Classes of org.apache.lenya.cms.site.tree.SiteTree

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.