lenya/src/java/org/apache/lenya/cms/publication DefaultSiteTree.java,1.4,1.5

Christian Egli <[email protected]> Tue, 13 May 2003 15:22:44 +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-serv5731/src/java/org/apache/lenya/cms/publication

Modified Files:
	DefaultSiteTree.java 
Log Message:
Code cleanup.


Index: DefaultSiteTree.java
===================================================================
RCS file: /repository/lenya/src/java/org/apache/lenya/cms/publication/DefaultSiteTree.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** DefaultSiteTree.java	13 May 2003 12:28:53 -0000	1.4
--- DefaultSiteTree.java	13 May 2003 13:22:42 -0000	1.5
***************
*** 94,101 ****
      }
  
-     public void addNode(String parentid, String id, Label[] labels) {
- 	addNode(parentid, id, labels, null, null, false);
-     }
- 
      protected Node findNode(Node node, List ids) {
  	if (ids.size() < 1) {
--- 94,97 ----
***************
*** 117,137 ****
      }
  
      public void addNode(String parentid, String id, Label[] labels,
  			String href, String suffix, boolean link) {
-         // Get parent element
-         StringTokenizer st = new StringTokenizer(parentid, "/");
- 	ArrayList ids = new ArrayList();
- 	while (st.hasMoreTokens()) {
- 	    ids.add(st.nextToken());
- 	}
- 
- 	Element root = document.getDocumentElement();
- 	
- 	NamespaceHelper helper = new NamespaceHelper(NAMESPACE_URI, "", document);
- 	
- 	Element elements[] = helper.getChildren(root);
  	
! 	Node parentNode = findNode(root, ids);
! 
          if (parentNode == null) {
              log.error("No nodes: " + parentid + ". No child added");
--- 113,124 ----
      }
  
+     public void addNode(String parentid, String id, Label[] labels) {
+ 	addNode(parentid, id, labels, null, null, false);
+     }
+ 
      public void addNode(String parentid, String id, Label[] labels,
  			String href, String suffix, boolean link) {
  	
! 	Node parentNode = getNodeInternal(parentid);
          if (parentNode == null) {
              log.error("No nodes: " + parentid + ". No child added");
***************
*** 154,157 ****
--- 141,145 ----
  
          // Add node
+ 	NamespaceHelper helper = new NamespaceHelper(NAMESPACE_URI, "", document);
  	Element child = helper.createElement(SiteTreeNodeImpl.NODE_NAME);
  	child.setAttribute(SiteTreeNodeImpl.ID_ATTRIBUTE_NAME, id);
***************
*** 176,180 ****
  
  	parentNode.appendChild(child);
! 	log.debug("Tree has been modified: " + root);
      }
  
--- 164,168 ----
  
  	parentNode.appendChild(child);
! 	log.debug("Tree has been modified: " + document.getDocumentElement());
      }
  
***************
*** 186,190 ****
      public void deleteNode(String id) {}
  
!     public SiteTreeNode getNode(String documentId) {
          StringTokenizer st = new StringTokenizer(documentId, "/");
  	ArrayList ids = new ArrayList();
--- 174,178 ----
      public void deleteNode(String id) {}
  
!     private Node getNodeInternal(String documentId) {
          StringTokenizer st = new StringTokenizer(documentId, "/");
  	ArrayList ids = new ArrayList();
***************
*** 192,197 ****
  	    ids.add(st.nextToken());
  	}
! 
  	Node node = findNode(document.getDocumentElement(), ids);
  	if (node == null) {
  	    return null;
--- 180,193 ----
  	    ids.add(st.nextToken());
  	}
! 	
  	Node node = findNode(document.getDocumentElement(), ids);
+ 	if (node == null) {
+ 	    return null;
+ 	}
+ 	return node;
+     }
+ 
+     public SiteTreeNode getNode(String documentId) {
+ 	Node node = getNodeInternal(documentId);
  	if (node == null) {
  	    return null;