Package org.apache.lenya.cms.publication

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


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

        try {
            tree = getPublication().getSiteTree(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


     *
     * @throws PublishingException DOCUMENT ME!
     */
    public void publish(String documentid, String absolutetreeauthoringpath,
        String absolutetreelivepath) throws PublishingException {
        DefaultSiteTree authoringTree = null;
        DefaultSiteTree liveTree = null;

        try {
            authoringTree = new DefaultSiteTree(absolutetreeauthoringpath);
            liveTree = new DefaultSiteTree(absolutetreelivepath);

            SiteTreeNode documentNode = authoringTree.getNode(documentid);

            if (documentNode != null) {
                liveTree.addNode(documentNode);
            } else {
                throw new PublishingException("No node found for the document " +
                    documentid);
            }

            liveTree.serialize();
        } catch (Exception e) {
            throw new PublishingException("Couldn't publish the tree :" +
                absolutetreelivepath, e);
        }
    }
View Full Code Here

 
  // add a node to the tree
        getLogger().debug("invoking DefaultSiteTree(" + publication.getDirectory() +
        File.separator + treeAuthoringPath + ")");
 
  DefaultSiteTree siteTree = new DefaultSiteTree(new File(publication.getDirectory(),
                treeAuthoringPath));
  Label[] labels = new Label[1];
   labels[0] = new Label(childname, null);
   siteTree.addNode(parentid, creator.generateTreeId(childid, childType), labels);

        // 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, allParameters);
        } catch (Exception e) {
            getLogger().error(".act(): Creator threw exception: " + e);
        }

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

  HashMap actionMap = new HashMap();
  return actionMap;
    }
View Full Code Here

     *
     */
     public DefaultSiteTreeTestCase(String test) {
         super(test);
   try {
       sitetree = new DefaultSiteTree("");
      
   } catch (Exception e) {
       System.err.println(e);
   }
     }
View Full Code Here

        }

        creator.init(doctypeConf);

        // add a node to the tree
        DefaultSiteTree siteTree = publication.getSiteTree(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

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

        try {
            tree = getPublication().getSiteTree(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 labelName,
        String language,
        String area)
        throws SiteTreeException, DocumentException {

        DefaultSiteTree tree = null;
        tree = getPublication().getSiteTree(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

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

      try {
      tree = getPublication().getSiteTree(area);
      SiteTreeNode node = tree.removeNode(documentid);
      if (node == null) {
        throw new SiteTreeException("Node " + node + " couldn't be removed");
      }
      tree.save();
    } catch (Exception e) {
      throw new SiteTreeException(e);
    }
    }  
View Full Code Here

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

        DefaultSiteTree tree = null;
        Label label = null;
        try {
            tree = getPublication().getSiteTree(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

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

        try {
            DefaultSiteTree tree = getPublication().getSiteTree(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

TOP

Related Classes of org.apache.lenya.cms.publication.DefaultSiteTree

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.