Package org.apache.lenya.cms.publication

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


        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;  
                }
            }
           
            if (name.equals(LABEL_HREF)) {
                Document document = envelope.getDocument();
                SiteTree siteTree = publication.getTree(document.getArea());
                value = siteTree.getNode(document.getId()).getLabel(document.getLanguage()).getHref();
                if (value == null) value = "";
            }

        } catch (Exception e) {
            throw new ConfigurationException("Obtaining value for [" + name + "] failed: ", e);
View Full Code Here


   */
  public void execute() throws BuildException {
    try {
      log("area : " + this.getArea());
      Publication publication= getPublication();
      SiteTree tree = publication.getTree(getArea());
          
      SiteTreeNode node = tree.getNode("/");
            node.deleteChildren();      
      tree.save();
      } catch (
        Exception e) {
      throw new BuildException(e);
    }
  }
View Full Code Here

     *
     * @throws SiteTreeException if an error occurs
     */
    public void deleteLanguageNode(String language, String documentid, String area)
        throws SiteTreeException {
        SiteTree tree = null;

        try {
            tree = getPublication().getTree(area);
            SiteTreeNode node = tree.getNode(documentid);
            node.removeLabel(node.getLabel(language));
            Label[] labels = node.getLabels();
            if (labels.length < 1 ){
                deleteNode(documentid,area);  
            } else {
                tree.save();
            }
        } catch (Exception e) {
            throw new SiteTreeException(e);
        }
    }  
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

    public Document[] getInternalReferences() throws ProcessingException {
        ArrayList unpublishedReferences = new ArrayList();
        DocumentBuilder builder = publication.getDocumentBuilder();

        try {
            SiteTree sitetree = publication.getTree(Publication.LIVE_AREA);
            String[] links = getInternalLinks(this.document.getFile());
           
            for (int linkIndex = 0; linkIndex < links.length; linkIndex++) {
                if (builder.isDocument(publication, links[linkIndex])) {
                    Document targetDocument = builder.buildDocument(publication, links[linkIndex]);

                    SiteTreeNode documentNode = sitetree.getNode(targetDocument.getId());

                    if (documentNode == null || documentNode.getLabel(targetDocument.getLanguage()) == null) {
                        // the document has not been published for the given language
                        if (log.isDebugEnabled()) {
                            log.debug("found reference to unpublished document: " + targetDocument);
View Full Code Here

     *
     * @throws SiteTreeException if an error occurs
     */
    public void deleteNode(String documentid, String area)
        throws SiteTreeException {
    SiteTree tree = null;

      try {
      tree = getPublication().getTree(area);
      tree.deleteNode(documentid);
      tree.save();
    } catch (Exception e) {
      throw new SiteTreeException(e);
    }
    }  
View Full Code Here

        log("Moving sitetree node:");
        log("    Document ID: [" + getDocumentId() + "]");
        log("    Direction:   [" + getDirection() + "]");

        try {
            SiteTree tree = getPublication().getTree(Publication.AUTHORING_AREA);
            if (getDirection().equals(UP)) {
                tree.moveUp(getDocumentId());
            } else if (getDirection().equals(DOWN)) {
                tree.moveDown(getDocumentId());
            } else {
                throw new BuildException(
                    "The direction in which the node should be moved isn't specified.");
            }
            tree.save();
        } catch (BuildException e) {
            throw e;
        } catch (Exception e) {
            throw new BuildException(e);
        }
View Full Code Here

   *             if an error occurs
   */
  public void deactivateResources(String language, String documentid, String area)
    throws SiteTreeException {
    Publication publication = getPublication();
    SiteTree tree = null;

    try {
      tree = publication.getTree(area);
      SiteTreeNode node = tree.getNode(documentid);
      Label[] labels = null;
      if (node != null) {
        labels = node.getLabels();
      }
      if (node == null || (labels != null && labels.length < 1)) {
View Full Code Here

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

        SiteTree tree = null;
        Label label = null;
        try {
            tree = getPublication().getTree(area);
            label = new Label(labelName, language);
            tree.addLabel(documentid, label);
            tree.save();
        } catch (Exception e) {
            throw new SiteTreeException(
                "Cannot insert label "
                    + label
                    + " into tree "
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);
       
        StringTokenizer st = new StringTokenizer(secDocumentId, "/");
        int length = st.countTokens() - 1;
        StringBuffer parentId = new StringBuffer(secDocumentId.length());
        for (int i = 0; i < length; i++) {
            parentId.append("/").append(st.nextToken());
        }
        String newid = st.nextToken();
        SiteTreeNode node = firsttree.getNode(firstDocumentId);

        if (node != null) {
            SiteTreeNode parentNode = sectree.getNode(parentId.toString());
            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

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.