lenya/src/java/org/apache/lenya/cms/publication SiteTree.java,1.1,1.2 DefaultSiteTree.java,1.2,1.3
Christian Egli <[email protected]> Mon, 12 May 2003 14:57:22 +0200
| Newsgroups | gmane.comp.cms.wyona.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /repository/lenya/src/java/org/apache/lenya/cms/publication
In directory erbium:/tmp/cvs-serv18578/src/java/org/apache/lenya/cms/publication
Modified Files:
SiteTree.java DefaultSiteTree.java
Log Message:
Added two more methods to find a node given a document-id and to add a
Node given an existing Node. This is usefull for publishing where you
need to replicate nodes.
Index: SiteTree.java
===================================================================
RCS file: /repository/lenya/src/java/org/apache/lenya/cms/publication/SiteTree.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** SiteTree.java 7 May 2003 07:45:16 -0000 1.1
--- SiteTree.java 12 May 2003 12:57:19 -0000 1.2
***************
*** 46,49 ****
--- 46,51 ----
import java.util.Map;
+ import org.w3c.dom.Node;
+
public interface SiteTree {
***************
*** 53,56 ****
--- 55,62 ----
String href, String suffix, boolean link);
+ public void addNode(Node node);
+
public void deleteNode(String id);
+
+ public Node getNode(String documentId);
}
Index: DefaultSiteTree.java
===================================================================
RCS file: /repository/lenya/src/java/org/apache/lenya/cms/publication/DefaultSiteTree.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DefaultSiteTree.java 7 May 2003 16:44:57 -0000 1.2
--- DefaultSiteTree.java 12 May 2003 12:57:19 -0000 1.3
***************
*** 143,147 ****
log.debug("PARENT ELEMENT: " + parentNode);
- System.out.println("Parent node " + parentNode);
// // Check if child already exists
--- 143,146 ----
***************
*** 182,186 ****
--- 181,234 ----
}
+ public void addNode(Node node) {
+ // Get parent element
+ String parentId = "FIXME:"; // node.getParentId();
+ StringTokenizer st = new StringTokenizer(parentId, "/");
+ ArrayList ids = new ArrayList();
+ while (st.hasMoreTokens()) {
+ ids.add(st.nextToken());
+ }
+
+ Element root = document.getDocumentElement();
+
+ Node parentNode = findNode(root, ids);
+
+ if (parentNode == null) {
+ log.error("No nodes: " + parentId + ". No child added");
+
+ return;
+ }
+
+ log.debug("PARENT ELEMENT: " + parentNode);
+
+ // // Check if child already exists
+ // String newChildXPath = xpath_string + "/" + "node";
+ // log.debug("CHECK: " + newChildXPath);
+
+ // if (doc.selectSingleNode(newChildXPath + "[@id='" + id + "']") != null) {
+ // log.error("Exception: XPath exists: " + newChildXPath + "[@id='" + id + "']");
+ // log.error("No child added");
+
+ // return;
+ // }
+
+ // Add node
+ parentNode.appendChild(node.cloneNode(true));
+ log.debug("Tree has been modified: " + root);
+ }
+
public void deleteNode(String id) {}
+
+ public Node getNode(String documentId) {
+ StringTokenizer st = new StringTokenizer(documentId, "/");
+ ArrayList ids = new ArrayList();
+ while (st.hasMoreTokens()) {
+ ids.add(st.nextToken());
+ }
+
+ Element root = document.getDocumentElement();
+
+ return findNode(root, ids);
+ }
public void serialize()