lenya/src/java/org/apache/lenya/cms/publication DefaultSiteTree.java,1.6,1.7

Edith Chevrier <[email protected]> Wed, 14 May 2003 15:57:08 +0200
Newsgroups gmane.comp.cms.wyona.cvs
Message-ID <[email protected]>
Update of /usr/local/repositories/lenya/src/java/org/apache/lenya/cms/publication
In directory erbium:/tmp/cvs-serv25463/src/java/org/apache/lenya/cms/publication

Modified Files:
	DefaultSiteTree.java 
Log Message:
Create the tree and add node only once

Index: DefaultSiteTree.java
===================================================================
RCS file: /usr/local/repositories/lenya/src/java/org/apache/lenya/cms/publication/DefaultSiteTree.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** DefaultSiteTree.java	13 May 2003 15:56:04 -0000	1.6
--- DefaultSiteTree.java	14 May 2003 13:57:06 -0000	1.7
***************
*** 58,61 ****
--- 58,62 ----
  
  import org.w3c.dom.Document;
+ import org.w3c.dom.DOMException;
  import org.w3c.dom.Element;
  import org.w3c.dom.Node;
***************
*** 89,95 ****
      public DefaultSiteTree(File treefile)
  	throws ParserConfigurationException, SAXException, IOException {
-         // Read tree
  	this.treefile = treefile;
! 	document = DocumentHelper.readDocument(treefile);
      }
  
--- 90,111 ----
      public DefaultSiteTree(File treefile)
  	throws ParserConfigurationException, SAXException, IOException {
  	this.treefile = treefile;
!         if (!treefile.isFile()) {
!           //the treefile does'nt exists, so create it
!           document = createDocument();
!         } else {
!           // Read tree
! 	  document = DocumentHelper.readDocument(treefile);
!         }
!     }
! 
!     public Document createDocument()
!         throws DOMException, ParserConfigurationException {
! 
!         document = DocumentHelper.createDocument(NAMESPACE_URI, "site", null);
!         Element root=document.getDocumentElement();
!         root.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
!         root.setAttribute("xsi:schemaLocation", "http://www.lenya.org/2003/sitetree  ../../../../resources/entities/sitetree.xsd"); 
!         return document;
      }
  
***************
*** 135,148 ****
  	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
--- 151,160 ----
  	log.debug("PARENT ELEMENT: " + parentNode);
  	
!         // Check if child already exists
!         Node childNode = getNodeInternal(id); 
!         if (childNode != null) {
!           log.info("This node (id = "+ id +") was already insert");
!           return;
!         }          
  
          // Add node