Package org.apache.lenya.cms.publication

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


    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.move(node, parentNode, newid, this.getRefdocumentid());
      } else {
        throw new SiteTreeException(
          "The parent node "
            + parentNode
            + " where the removed node shall be inserted not found");
      }
    } else {
      throw new SiteTreeException(
        "Node " + node + " couldn't be removed");
    }

    if (firstArea.equals(secArea)) {
      firsttree.save();
    } else {
      firsttree.save();
      sectree.save();
    }
  }
View Full Code Here


        String language,
        String area,
        String href)
        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.");
        }
        if (href.equals("")) href = null;
          // FIXME: This is somewhat of a hack. See also RenameLabelTask.java
        tree.removeLabel(documentid, label);
        label.setHref(href);
        tree.addLabel(documentid, label);
        tree.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

            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 {
            DocumentIdToPathMapper mapper = publication.getPathMapper();
            log.debug("Parent directory: " + mapper.getFile(publication, "authoring", parentId, language));
            creator.create(
                publication,
                new File(doctypesDirectory, "samples"),
                mapper.getDirectory(publication, "authoring", parentId, language),
                //new File(authoringDirectory, parentId),
                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

        File documentFile = new File(authoringDirectory, CREATED_FILE);
        assertTrue(documentFile.exists());
        System.out.println("File was created: " + documentFile.getAbsolutePath());

        SiteTree sitetree = publication.getTree(AREA);
        SiteTreeNode node = sitetree.getNode(PARENT_ID + "/" + CHILD_ID);
        assertNotNull(node);
        System.out.println("Sitetree node was created: " + node.getId() + " (label: " +
            node.getLabel(DOCUMENT_LANGUAGE) + ")");
    }
View Full Code Here

       
        publication.copyDocument(sourceDocument, destinationDocument);
       
        assertTrue(destinationDocument.exists());
       
        SiteTree destinationTree = publication.getTree(destinationArea);
        SiteTreeNode destinationNode = destinationTree.getNode(destinationDocumentId);
        assertNotNull(destinationNode);
        Label destinationLabel = destinationNode.getLabel(destinationLanguage);
        assertNotNull(destinationLabel);
       
        SiteTreeNode sourceNode = destinationTree.getNode(sourceDocumentId);
        Label sourceLabel = sourceNode.getLabel(sourceLanguage);
       
        assertTrue(destinationLabel.getLabel().equals(sourceLabel.getLabel()));
       
    }
View Full Code Here

    System.out.println("Backup was deleted: " + firstRcbakFile.getAbsolutePath());

    //TODO evaluation of meta, workflow
       
        //evaluate the node
    SiteTree sitetree = PublicationHelper.getPublication().getTree(Publication.AUTHORING_AREA);
    SiteTreeNode node = sitetree.getNode(secdocumentid);
    assertNotNull(node);
        System.out.println(
            "Sitetree node with id "
                + node.getId()
                + " was created as child of node with id: "
                + node.getAbsoluteParentId());
    SiteTreeNode firstnode = sitetree.getNode(FIRST_DOCUMENT_ID);
    assertNull(firstnode);
    System.out.println("Sitetree node for document id "+FIRST_DOCUMENT_ID+" was deleted");

    }
View Full Code Here

    assertFalse(firstRcbakFile.exists());
    System.out.println("Backup was deleted: " + firstRcbakFile.getAbsolutePath());
       
        //TODO evaluation of meta, workflow
       
    SiteTree sitetree = PublicationHelper.getPublication().getTree(Publication.AUTHORING_AREA);
    SiteTreeNode node = sitetree.getNode(secdocumentid);
    assertNotNull(node);
    System.out.println("Sitetree node with id "+node.getId()+" was created as child of node with id: " + node.getAbsoluteParentId());
    SiteTreeNode firstnode = sitetree.getNode(FIRST_DOCUMENT_ID);
    assertNull(firstnode);
    System.out.println("Sitetree node for document id "+FIRST_DOCUMENT_ID+" was deleted");
  }
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.