Package org.apache.lenya.cms.publication

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


            throw new CreatorException(e);
        }

        ParentChildCreatorInterface creator = type.getCreator();

        SiteTree siteTree;

        try {
            log.debug("Get sitetree of area: " + area);
            siteTree = publication.getTree(area);
        } catch (Exception e) {
            throw new CreatorException(e);
        }

        Label[] labels = new Label[1];
        labels[0] = new Label(childName, language);

        try {
            siteTree.addNode(
                parentId,
                creator.generateTreeId(childId, childType),
                labels,
        visibleInNav);
        } catch (Exception e) {
            throw new CreatorException(e);
        }

        File doctypesDirectory =
            new File(
                publication.getDirectory(),
                DocumentTypeBuilder.DOCTYPE_DIRECTORY);

        try {
            creator.create(
                new File(doctypesDirectory, "samples"),
                new File(authoringDirectory, parentId),
                childId,
                childType,
                childName,
                language,
                Collections.EMPTY_MAP);
        } catch (Exception e) {
            throw new CreatorException(e);
        }

        // commit (sort of)
        try {
            siteTree.save();
        } catch (Exception e) {
            throw new CreatorException(e);
        }
    }
View Full Code Here


        try {
            PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
            Publication publication = envelope.getPublication();

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

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

            if (name.equals(TRASH_NODE)) {
                SiteTree trashTree = publication.getTree(Publication.TRASH_AREA);
                value = trashTree.getNode(envelope.getDocument().getId());
            }
           
            if (name.equals(ARCHIVE_NODE)) {
                SiteTree archiveTree = publication.getTree(Publication.ARCHIVE_AREA);
                value = archiveTree.getNode(envelope.getDocument().getId());
            }
           
            if (name.equals(FIRST_CHILD_ID)) {
                SiteTree siteTree = publication.getTree(envelope.getDocument().getArea());
                SiteTreeNode node = siteTree.getNode(envelope.getDocument().getId());
                SiteTreeNode[] children = node.getChildren(envelope.getDocument().getLanguage());
                if (children.length > 0){
                    value = children[0].getId();
                } else {
                    value = null;  
View Full Code Here

        }

        creator.init(doctypeConf);

        // add a node to the tree
        SiteTree siteTree = publication.getTree(Publication.AUTHORING_AREA);
        Label[] labels = new Label[1];
        labels[0] = new Label(childname, language);
        siteTree.addNode(parentid, creator.generateTreeId(childid, childType), labels, visibleInNav);

        // Transaction should actually be finished here!
        // Create actual document
        // grab all the parameters from session, request params and
        // sitemap params
        HashMap allParameters = new HashMap();
        String[] names = parameters.getNames();

        for (int i = 0; i < names.length; i++) {
            String name = names[i];
            String value = null;

            try {
                value = parameters.getParameter(name);
            } catch (ParameterException pe) {
                value = null;
            }

            allParameters.put(name, value);
        }

        Enumeration requestParameters = request.getParameterNames();

        while (requestParameters.hasMoreElements()) {
            String requestParameterName = (String) requestParameters.nextElement();

            if (allParameters.containsKey(requestParameterName)) {
                // we do not allow name clashes
                throw new ProcessingException("Name clash in request parameter " +
                    "and sitemap parameter: " + requestParameterName);
            }

            allParameters.put(requestParameterName, request.getParameter(requestParameterName));
        }

        Enumeration sessionAttributeNames = session.getAttributeNames();

        while (sessionAttributeNames.hasMoreElements()) {
            String sessionAttributeName = (String) sessionAttributeNames.nextElement();

            if (allParameters.containsKey(sessionAttributeName)) {
                // we do not allow name clashes
                throw new ProcessingException("Name clash in session attribute " +
                    "and request parameter or sitemap parameter: " + sessionAttributeName);
            }

            allParameters.put(sessionAttributeName, session.getAttribute(sessionAttributeName));
        }

        try {
            creator.create(new File(absoluteDoctypesPath + "samples"),
                new File(publication.getDirectory(), docsPath + parentid), childid, childType,
                childname, language, allParameters);
        } catch (Exception e) {
            log.error("Creator threw exception: " + e);
            return null;
        }

        // commit (sort of)
        siteTree.save();

        HashMap actionMap = new HashMap();

        return actionMap;
    }
View Full Code Here

        String area = parameters.getParameter(AREA_PARAMETER_NAME, Publication.AUTHORING_AREA);

        PageEnvelope pageEnvelope =
            PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);

        SiteTree siteTree =
            pageEnvelope.getPublication().getTree(area);

        if (siteTree.getNode(documentId) != null) {
            return Collections.EMPTY_MAP;
        } else {
            return null;
        }
    }
View Full Code Here

     * @throws ProcessingException
     */
    protected void generateFragment() throws SiteTreeException, SAXException,
            ProcessingException {

        SiteTree siteTree = null;
        if (!this.area.equals(Publication.AUTHORING_AREA)
                && !this.area.equals(Publication.ARCHIVE_AREA)
                && !this.area.equals(Publication.TRASH_AREA)
                && !this.area.equals(Publication.STAGING_AREA)
                && !this.area.equals(Publication.LIVE_AREA)) {
            throw new ProcessingException("Invalid area: " + this.area);
        }
        siteTree = publication.getTree(this.area);

        SiteTreeNode node = siteTree.getNode(this.documentid);
        if (this.getLogger().isDebugEnabled()) {
            this.getLogger().debug(
                    "Node with documentid " + documentid + " found.");
        }
        if (node == null)
View Full Code Here

     * @throws ProcessingException
     */
    protected void generateFragmentInitial(String siteArea)
            throws SiteTreeException, SAXException, ProcessingException {

        SiteTree siteTree = publication.getTree(siteArea);

        String label = "";
        String isFolder = "";

        // FIXME: don't hardcode area label
        if (siteArea.equals(Publication.AUTHORING_AREA))
            label = "Authoring";
        if (siteArea.equals(Publication.ARCHIVE_AREA))
            label = "Archive";
        if (siteArea.equals(Publication.TRASH_AREA))
            label = "Trash";
        if (siteArea.equals(Publication.LIVE_AREA))
            label = "Live";
        if (siteArea.equals(Publication.STAGING_AREA))
            label = "Staging";

        if (siteTree.getTopNodes().length > 0)
            isFolder = "true";
        else
            isFolder = "false";

        this.attributes.clear();
        this.attributes.addAttribute("", ATTR_AREA, ATTR_AREA, "CDATA",
                siteArea);
        this.attributes.addAttribute("", ATTR_FOLDER, ATTR_FOLDER, "CDATA",
                isFolder);
        this.attributes
                .addAttribute("", ATTR_LABEL, ATTR_LABEL, "CDATA", label);

        startNode(NODE_SITE);

        if (area.equals(siteArea)) {
            generateFragmentRecursive(siteTree.getTopNodes(), this.documentid);
        }

        endNode(NODE_SITE);
    }
View Full Code Here

     */
    public void manipulateTree(String firstdocumentid, String secdocumentid, String firstarea,
            String secarea) throws SiteTreeException {

        Publication publication = getPublication();
        SiteTree firsttree = publication.getTree(firstarea);
        SiteTree sectree = publication.getTree(secarea);

        String parentid = "";
        StringTokenizer st = new StringTokenizer(secdocumentid, "/");
        int length = st.countTokens();

        for (int i = 0; i < (length - 1); i++) {
            parentid = parentid + "/" + st.nextToken();
        }
        String newid = st.nextToken();

        SiteTreeNode node = firsttree.getNode(firstdocumentid);

        if (node != null) {
            SiteTreeNode parentNode = sectree.getNode(parentid);
            if (parentNode != null) {
                sectree.copy(node, parentNode, newid, null);
            } else {
                throw new SiteTreeException("The parent node " + parentNode
                        + " where the copied node shall be inserted not found");
            }
        } else {
            throw new SiteTreeException("Node " + node + " couldn't be found");
        }
        if (firstarea.equals(secarea)) {
            firsttree.save();
        } else {
            firsttree.save();
            sectree.save();
        }
    }
View Full Code Here

      log("area for the source :" + this.getFirstarea());
      log("document-id for the destination :" + this.getSecdocumentid());
      log("area for the destination :" + this.getSecarea());

      Publication publication = getPublication();
      SiteTree tree = publication.getTree(this.getSecarea());
      SiteTreeNode node = tree.getNode(this.getSecdocumentid());
      node.acceptReverseSubtree(this);
    } catch (Exception e) {
      throw new BuildException(e);
    }
  }
View Full Code Here

      log("rcbak dir" + this.getRcbakdir());
      log("src area dir" + this.getSrcareadir());

      //visit the destination tree
      Publication publication = getPublication();
      SiteTree tree = publication.getTree(this.getSecarea());
      SiteTreeNode node = tree.getNode(this.getSecdocumentid());
      node.acceptReverseSubtree(this);

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

        String labelName,
        String language,
        String area)
        throws SiteTreeException, DocumentException {

        SiteTree tree = getPublication().getTree(area);
        SiteTreeNode node = tree.getNode(documentid);
        if (node == null) {
            throw new DocumentException(
                "Document-id " + documentid + " not found.");
        }
        Label label = node.getLabel(language);
        if (label == null) {
            throw new DocumentException(
                "Label for language " + language + " not found.");
        }
  // FIXME: This is somewhat of a hack. The change of the label
  // name should not be done by removing the label and readding
  // it. Instead the node should probably have a setLabel method
  // which could be invoked by the Label.setLabel() method.
        tree.removeLabel(documentid, label);
        label.setLabel(labelName);
        tree.addLabel(documentid, label);
        tree.save();
    }
View Full Code Here

TOP

Related Classes of org.apache.lenya.cms.publication.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.