Package org.apache.lenya.cms.publication

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


      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


     *            languages are to be published.
     *
     * @throws PublishingException if the publication failed.
     */
    public void publish(String documentId, String language) throws PublishingException {
        SiteTree authoringTree = null;
        SiteTree liveTree = null;

        try {
            authoringTree = getPublication().getTree(Publication.AUTHORING_AREA);
            liveTree = getPublication().getTree(Publication.LIVE_AREA);

            SiteTreeNode authoringNode = authoringTree.getNode(documentId);
            SiteTreeNode[] siblings = authoringNode.getNextSiblings();
            String parentId = authoringNode.getAbsoluteParentId();
            SiteTreeNode sibling = null;
            String siblingDocId = null;
            for (int i = 0; i < siblings.length; i++) {
                String docId = parentId + "/" + siblings[i].getId();
                sibling = liveTree.getNode(docId);
                if (sibling != null) {
                    siblingDocId = docId;
                    break;
                }
            }

            if (language == null) {
                // no language was specified. Simply publish the
                // node including all languages.
                try {
                    liveTree.addNode(authoringNode, siblingDocId);
                } catch (SiteTreeException e1) {
                    throw new ParentNodeNotFoundException("Couldn't add document: " + documentId
                            + " to live tree.", e1);
                }
            } else {
                // a language was specified. Let's see if this
                // node even has an entry for the specified
                // language.
                Label label = authoringNode.getLabel(language);
                if (label != null) {
                    // check if this node has already been
                    // published
                    SiteTreeNode liveNode = liveTree.getNode(documentId);
                    if (liveNode != null) {
                        // if the node already exists in the live
                        // tree simply insert the label in the
                        // live tree
                        liveTree.setLabel(documentId, label);
                    } else {
                        // if the node doesn't exist, add it and
                        // add the specified label to it.
                        Label[] labels = { label };
                        try {
                            liveTree.addNode(documentId, labels, authoringNode.visibleInNav(),
                                authoringNode.getHref(),authoringNode.getSuffix(),
                  authoringNode.hasLink(),siblingDocId);
                        } catch (SiteTreeException e1) {
                            throw new ParentNodeNotFoundException("Couldn't add document: "
                                    + documentId + " to live tree.", e1);
                        }
                    }
                } else {
                    // the node that we're trying to publish
                    // doesn't have this language
                    throw new PublishingException("The node " + documentId
                            + " doesn't contain a label for language " + language);
                }
            }
            liveTree.save();
        } catch (PublishingException e) {
            throw e;
        } catch (Exception e) {
            throw new PublishingException("Couldn't publish to live tree :", e);
        }
View Full Code Here

    try {
      log("document-id for the source" + this.getFirstdocumentid());
      log("area for the source" + this.getFirstarea());

      Publication publication= getPublication();
      SiteTree tree = publication.getTree(getFirstarea());
      SiteTreeNode node = tree.getNode(getFirstdocumentid());

      node.acceptSubtree(this);
    } catch (Exception e) {
      throw new BuildException(e);
    }
View Full Code Here

        Publication publication = pageEnvelope.getPublication();
        String area = pageEnvelope.getDocument().getArea();
        String language = pageEnvelope.getDocument().getLanguage();
        String id = pageEnvelope.getDocument().getId();

        SiteTree siteTree = publication.getTree(area);
        SiteTreeNode node = siteTree.getNode(id);

        if (node == null) {
            throw new DocumentDoesNotExistException("The document " + pageEnvelope.getDocument().getId() + " does not exist. Check sitetree, it might need to be reloaded.");
        }
       
View Full Code Here

    public void changeVisibility(
        String documentid,
        String area)
        throws SiteTreeException, DocumentException {

        SiteTree tree = null;
        tree = getPublication().getTree(area);
        SiteTreeNode node = tree.getNode(documentid);

        if (node == null) {
            throw new DocumentException(
                "Document-id " + documentid + " not found.");
        }
        //if node is visible change to fale and vice versa
        String visibility = "false";
        if (!node.visibleInNav()) visibility = "true";
        node.setNodeAttribute(SiteTreeNodeImpl.VISIBLEINNAV_ATTRIBUTE_NAME, visibility);       

        tree.save();
    }
View Full Code Here

    Publication publication = getPublication();

    String language = null;
    String url = null;
    SiteTree tree;

    try {
      tree = publication.getTree(area);
    } catch (SiteTreeException e) {
      throw new BuildException(e);
    }
    SiteTreeNode node = tree.getNode(documentid);
    Label[] labels = node.getLabels();

    DocumentBuilder builder = publication.getDocumentBuilder();

    try {
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("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(getFirstarea());
      SiteTreeNode node = tree.getNode(getFirstdocumentid());

      node.acceptSubtree(this);
    } catch (Exception e) {
      throw new BuildException(e);
    }
View Full Code Here

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

        SiteTree tree = null;
        Label label = null;
        try {
            tree = getPublication().getTree(area);
            SiteTreeNode node = tree.getNode(documentid);
            // if there is only one label left do not delete it.
            if (node.getLabels().length > 1) {
                // if there are more than one labels in this node
                // try to delete the label specified by the labelName.
                label = new Label(labelName, language);
                tree.removeLabel(documentid, label);
                tree.save();
            }

        } catch (Exception e) {
            throw new SiteTreeException(
                "Cannot remove label " + label + " from tree " + area,
View Full Code Here

        try {
            log("Document ID: [" + documentId + "]");
            log("Area:        [" + area + "]");

            Publication publication = getPublication();
            SiteTree tree = publication.getTree(area);
            SiteTreeNode node = tree.getNode(documentId);

            node.acceptSubtree(this);
        } catch (Exception e) {
            throw new BuildException(e);
        }
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.