You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2006/08/09 18:33:32 UTC

svn commit: r430088 [2/2] - in /lenya/trunk/src: impl/java/org/apache/lenya/cms/publication/ impl/test/org/apache/lenya/cms/publication/ impl/test/org/apache/lenya/cms/publication/util/ java/org/apache/lenya/cms/cocoon/components/modules/input/ java/or...

Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTree.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTree.java?rev=430088&r1=430087&r2=430088&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTree.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTree.java Wed Aug  9 09:33:26 2006
@@ -17,7 +17,6 @@
 
 package org.apache.lenya.cms.site.tree;
 
-import org.apache.lenya.cms.site.Label;
 import org.apache.lenya.cms.site.SiteException;
 import org.apache.lenya.cms.site.SiteStructure;
 
@@ -44,7 +43,7 @@
      * 
      * @throws SiteException if the addition failed
      */
-    void addNode(String parentid, String id, String uuid, Label[] labels, boolean visibleInNav) throws SiteException;
+    void addNode(String parentid, String id, String uuid, boolean visibleInNav) throws SiteException;
 
     /**
      * Add a node. TODO: Lenya 1.2.X supports argument visibleInNav
@@ -52,15 +51,15 @@
      * @param parentid the node where the new node is to be inserted
      * @param id the node id
      * @param uuid The UUID.
-     * @param labels the labels
      * @param visibleInNav determines the visibility of a node in the navigation. It is meant to hide specific nodes within the "public" navigation whereas the node is visible within the info/site area.
      * @param href the href of the new node (internal and external references)     
      * @param suffix the suffix of the new node
      * @param link Visibility of link respectively href. It is meant to support "grouping" nodes in the navigation which do not relate to a document (internal) or external link (www).
+     * @return A node.
      * 
      * @throws SiteException if the addition failed
      */
-    void addNode(String parentid, String id, String uuid, Label[] labels, boolean visibleInNav, String href, String suffix,
+    SiteTreeNode addNode(String parentid, String id, String uuid, boolean visibleInNav, String href, String suffix,
             boolean link) throws SiteException;
 
     /**
@@ -69,16 +68,16 @@
      * @param parentid the node where the new node is to be inserted
      * @param id the node id
      * @param uuid The UUID.
-     * @param labels the labels
      * @param visibleInNav determines the visibility of a node in the navigation
      * @param href the href of the new node
      * @param suffix the suffix of the new node
      * @param link the link
      * @param refDocumentId document-id of the node, before which the new node will be inserted.
+     * @return A node.
      * 
      * @throws SiteException if the addition failed
      */
-    void addNode(String parentid, String id, String uuid, Label[] labels, boolean visibleInNav, String href, String suffix,
+    SiteTreeNode addNode(String parentid, String id, String uuid, boolean visibleInNav, String href, String suffix,
             boolean link, String refDocumentId) throws SiteException;
 
     /**
@@ -87,15 +86,15 @@
      * @param documentid the document-id of the new node. From this the parent-id and the id are
      *            computed
      * @param uuid The UUID.
-     * @param labels the labels
      * @param visibleInNav determines the visibility of a node in the navigation
      * @param href the href
      * @param suffix the suffix
      * @param link the link
+     * @return A node.
      * 
      * @throws SiteException if the addition failed
      */
-    void addNode(String documentid, String uuid, Label[] labels, boolean visibleInNav, String href, String suffix, boolean link)
+    SiteTreeNode addNode(String documentid, String uuid, boolean visibleInNav, String href, String suffix, boolean link)
             throws SiteException;
 
     /**
@@ -105,16 +104,16 @@
      * @param documentid the document-id of the new node. From this the parent-id and the id are
      *            computed
      * @param uuid The UUID.
-     * @param labels the labels
      * @param visibleInNav determines the visibility of a node in the navigation
      * @param href the href
      * @param suffix the suffix
      * @param link the link
      * @param refDocumentId document-id of the node, before which the new node will be inserted.
+     * @return A node.
      * 
      * @throws SiteException if the addition failed
      */
-    void addNode(String documentid, String uuid, Label[] labels, boolean visibleInNav, String href, String suffix, boolean link,
+    SiteTreeNode addNode(String documentid, String uuid, boolean visibleInNav, String href, String suffix, boolean link,
             String refDocumentId) throws SiteException;
 
     /**
@@ -145,19 +144,21 @@
     /**
      * Add a label to an existing node
      * 
-     * @param documentId the document-id to which the label is to be added.
+     * @param path the path to which the label is to be added.
+     * @param language The language.
      * @param label the label to add
      */
-    void addLabel(String documentId, Label label);
+    void addLabel(String path, String language, String label);
 
     /**
      * Sets a label of an existing node. If the label does not exist, it is added. Otherwise, the
      * existing label is replaced.
      * 
-     * @param documentId the document-id to which the label is to be added.
+     * @param path the path to which the label is to be added.
+     * @param language The language.
      * @param label the label to add
      */
-    void setLabel(String documentId, Label label);
+    void setLabel(String path, String language, String label);
 
     /**
      * Sets the visibility in the navigation of an existing node. 
@@ -180,10 +181,10 @@
     /**
      * Remove a label from a node
      * 
-     * @param documentId the document-id from which the label is to be removed.
-     * @param label the label to remove
+     * @param path the path from which the label is to be removed.
+     * @param language The language.
      */
-    void removeLabel(String documentId, Label label);
+    void removeLabel(String path, String language);
 
     /**
      * Removes the node corresponding to the given document-id from the tree, and returns it.
@@ -195,16 +196,6 @@
     SiteTreeNode removeNode(String documentId);
 
     /**
-     * Return the Node for a given document-id.
-     * 
-     * @param documentId the document-id of the node that is requested
-     * 
-     * @return a <code>SiteTreeNode</code> if there is a node for the given document-id, null
-     *         otherwise.
-     */
-    SiteTreeNode getNode(String documentId);
-
-    /**
      * Return the top level nodes in the sitetree.
      * @return the top nodes in the sitetree, or empty array if there are none
      */
@@ -244,11 +235,4 @@
      */
     void save() throws SiteException;
     
-    /**
-     * @param uuid The UUID.
-     * @return A node.
-     * @throws SiteException 
-     */
-    SiteTreeNode getNodeByUUID(String uuid) throws SiteException;
-
 }

Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeFactory.java?rev=430088&r1=430087&r2=430088&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeFactory.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeFactory.java Wed Aug  9 09:33:26 2006
@@ -20,6 +20,8 @@
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.lenya.cms.publication.DocumentFactory;
+import org.apache.lenya.cms.publication.DocumentUtil;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationUtil;
 import org.apache.lenya.cms.repository.RepositoryException;
@@ -53,7 +55,8 @@
         DefaultSiteTree tree;
         try {
             Publication publication = PublicationUtil.getPublication(this.manager, publicationId);
-            tree = new DefaultSiteTree(publication, area, this.manager, getLogger());
+            DocumentFactory factory = DocumentUtil.createDocumentIdentityMap(this.manager, session);
+            tree = new DefaultSiteTree(factory, publication, area, this.manager, getLogger());
         } catch (Exception e) {
             throw new RepositoryException(e);
         }

Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNode.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNode.java?rev=430088&r1=430087&r2=430088&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNode.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNode.java Wed Aug  9 09:33:26 2006
@@ -23,19 +23,14 @@
 
 import org.apache.lenya.cms.publication.DocumentException;
 import org.apache.lenya.cms.site.Label;
+import org.apache.lenya.cms.site.SiteNode;
 
 /**
  * This interface is a wrapper around the more general w3c.Node which
  * hides some details which are irrelevant for site tree nodes. It basically
  * delegates everything to the Node.
  */
-public interface SiteTreeNode {
-
-    /**
-     * Returns the parent node of this node.
-     * @return A sitetree node.
-     */
-    SiteTreeNode getParent();
+public interface SiteTreeNode extends SiteNode {
 
     /**
      * Returns the parent node of this node or null if the parent has no label for the given language.
@@ -45,30 +40,10 @@
     SiteTreeNode getParent(String language);
 
     /**
-     * Get the absolute id of this node.
-     * 
-     * @return  the absolute id.
-     */
-    String getAbsoluteId();
-
-    /**
-     * Get the id of this node.
-     * 
-     * @return the node id.
-     */
-    String getId();
-
-    /**
-     * Get the uuid of this node.
-     * 
-     * @return the uuid.
-     */
-    String getUUID();
-
-    /**
      * Get all labels for this node (independent of their language attribute).
      * 
      * @return an <code>Array</code> of labels.
+     * @deprecated use {@link SiteNode#getLanguages()} instead.
      */
     Label[] getLabels();
 
@@ -79,6 +54,7 @@
      * 
      * @return a <code>Label</code> if there is one for the given language, 
      * null otherwise. 
+     * @deprecated use {@link #getLink()} instead.
      */
     Label getLabel(String xmlLanguage);
 
@@ -92,9 +68,9 @@
     /**
      * Remove a label from this node.
      * 
-     * @param label the label to be removed.
+     * @param language the label to be removed.
      */
-    void removeLabel(Label label);
+    void removeLabel(String language);
 
     /**
      * Check whether this node is visible in the navigation 

Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNodeImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNodeImpl.java?rev=430088&r1=430087&r2=430088&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNodeImpl.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/SiteTreeNodeImpl.java Wed Aug  9 09:33:26 2006
@@ -23,7 +23,12 @@
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.lenya.cms.publication.DocumentException;
+import org.apache.lenya.cms.publication.DocumentFactory;
 import org.apache.lenya.cms.site.Label;
+import org.apache.lenya.cms.site.Link;
+import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.SiteNode;
+import org.apache.lenya.cms.site.SiteStructure;
 import org.apache.lenya.xml.DocumentHelper;
 import org.apache.lenya.xml.NamespaceHelper;
 import org.w3c.dom.Element;
@@ -50,7 +55,7 @@
     /**
      * <code>ISIBLEINNAV_ATTRIBUTE_NAME</code>The visibleinnav attribute
      */
-    public static final String VISIBLEINNAV_ATTRIBUTE_NAME="visibleinnav";
+    public static final String VISIBLEINNAV_ATTRIBUTE_NAME = "visibleinnav";
     /**
      * <code>HREF_ATTRIBUTE_NAME</code> The href attribute
      */
@@ -77,30 +82,29 @@
     public static final String LABEL_NAME = "label";
 
     private Node node = null;
+    private SiteTree tree;
+
+    private DocumentFactory factory;
 
     /**
      * Creates a new SiteTreeNodeImpl object.
      * 
      * @param _node the node which is to be wrapped by this SiteTreeNode
      */
-    protected SiteTreeNodeImpl(Node _node) {
+    protected SiteTreeNodeImpl(DocumentFactory factory, SiteTree tree, Node _node) {
         this.node = _node;
+        this.tree = tree;
+        this.factory = factory;
     }
 
-    /**
-     * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getId()
-     */
-    public String getId() {
+    public String getName() {
         if (this.node == this.node.getOwnerDocument().getDocumentElement()) {
             return "";
         }
         return this.node.getAttributes().getNamedItem(ID_ATTRIBUTE_NAME).getNodeValue();
     }
 
-    /**
-     * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getUUID()
-     */
-    public String getUUID() {
+    public String getUuid() {
         if (this.node == this.node.getOwnerDocument().getDocumentElement()) {
             getLogger().warn("Node equals OwnerDocument: " + this);
             return "";
@@ -108,16 +112,12 @@
         Element element = (Element) this.node;
         if (element.hasAttribute(UUID_ATTRIBUTE_NAME)) {
             return element.getAttribute(UUID_ATTRIBUTE_NAME);
-        }
-        else {
-            return getAbsoluteId();
+        } else {
+            return getPath();
         }
     }
 
-    /**
-     * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getAbsoluteId()
-     */
-    public String getAbsoluteId() {
+    public String getPath() {
         String absoluteId = "";
         Node currentNode = this.node;
         NamedNodeMap attributes = null;
@@ -165,7 +165,7 @@
                     labelLanguage = languageAttribute.getNodeValue();
                 }
 
-                labels.add(new Label(labelName, labelLanguage));
+                labels.add(new Label(this.factory, this, labelName, labelLanguage));
             }
         }
 
@@ -217,8 +217,10 @@
     /**
      * @see org.apache.lenya.cms.site.tree.SiteTreeNode#removeLabel(org.apache.lenya.cms.site.Label)
      */
-    public void removeLabel(Label label) {
-        if (getLabel(label.getLanguage()) != null) {
+    public void removeLabel(String language) {
+        if (!hasLink(language)) {
+            throw new RuntimeException(this + " does not contain the language [" + language + "]");
+        } else {
             // this node doesn't contain this label
 
             NodeList children = this.node.getChildNodes();
@@ -233,7 +235,7 @@
                             .getNamedItem(LANGUAGE_ATTRIBUTE_NAME);
 
                     if (languageAttribute != null
-                            && languageAttribute.getNodeValue().equals(label.getLanguage())) {
+                            && languageAttribute.getNodeValue().equals(language)) {
                         this.node.removeChild(child);
                         break;
                     }
@@ -241,19 +243,19 @@
             }
         }
     }
-    
+
     /**
      * @see org.apache.lenya.cms.site.tree.SiteTreeNode#visibleInNav()
      */
     public boolean visibleInNav() {
         Node attribute = this.node.getAttributes().getNamedItem(VISIBLEINNAV_ATTRIBUTE_NAME);
-        
-        if (attribute != null){
+
+        if (attribute != null) {
             return attribute.getNodeValue().equals("true");
         }
         return true;
     }
-    
+
     /**
      * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getHref()
      */
@@ -300,7 +302,7 @@
         Element[] elements = helper.getChildren((Element) this.node, SiteTreeNodeImpl.NODE_NAME);
 
         for (int i = 0; i < elements.length; i++) {
-            SiteTreeNode newNode = new SiteTreeNodeImpl(elements[i]);
+            SiteTreeNode newNode = new SiteTreeNodeImpl(this.factory, getTree(), elements[i]);
             // FIXME: the if is a workaround
             if (getLogger() != null)
                 ContainerUtil.enableLogging(newNode, getLogger());
@@ -319,7 +321,7 @@
         Element[] elements = helper.getChildren((Element) this.node, SiteTreeNodeImpl.NODE_NAME);
         for (int i = 0; i < elements.length; i++) {
             this.node.removeChild(elements[i]);
-            SiteTreeNode newNode = new SiteTreeNodeImpl(elements[i]);
+            SiteTreeNode newNode = new SiteTreeNodeImpl(this.factory, getTree(), elements[i]);
             ContainerUtil.enableLogging(newNode, getLogger());
             childElements.add(newNode);
         }
@@ -333,11 +335,10 @@
         List siblingElements = new ArrayList();
 
         NamespaceHelper helper = getNamespaceHelper();
-        Element[] elements = helper
-                .getNextSiblings((Element) this.node, SiteTreeNodeImpl.NODE_NAME);
+        Element[] elements = helper.getNextSiblings((Element) this.node, SiteTreeNodeImpl.NODE_NAME);
 
         for (int i = 0; i < elements.length; i++) {
-            SiteTreeNode newNode = new SiteTreeNodeImpl(elements[i]);
+            SiteTreeNode newNode = new SiteTreeNodeImpl(this.factory, getTree(), elements[i]);
             ContainerUtil.enableLogging(newNode, getLogger());
             siblingElements.add(newNode);
         }
@@ -356,7 +357,7 @@
                 SiteTreeNodeImpl.NODE_NAME);
 
         for (int i = 0; i < elements.length; i++) {
-            SiteTreeNode newNode = new SiteTreeNodeImpl(elements[i]);
+            SiteTreeNode newNode = new SiteTreeNodeImpl(this.factory, getTree(), elements[i]);
             ContainerUtil.enableLogging(newNode, getLogger());
             siblingElements.add(newNode);
         }
@@ -370,7 +371,7 @@
     public String getNextSiblingDocumentId() {
         SiteTreeNode[] siblings = getNextSiblings();
         if (siblings != null && siblings.length > 0) {
-            return siblings[0].getAbsoluteId();
+            return siblings[0].getPath();
         }
         return null;
     }
@@ -389,7 +390,7 @@
         this.accept(visitor);
         SiteTreeNode[] children = this.getChildren();
         if (children == null) {
-            getLogger().info("The node " + this.getId() + " has no children");
+            getLogger().info("The node " + getPath() + " has no children");
             return;
         }
         for (int i = 0; i < children.length; i++) {
@@ -428,19 +429,19 @@
     public void setLabel(Label label) {
         Label existingLabel = getLabel(label.getLanguage());
         if (existingLabel != null) {
-            removeLabel(existingLabel);
+            removeLabel(label.getLanguage());
         }
         addLabel(label);
     }
 
     /**
      * @see org.apache.lenya.cms.site.tree.SiteTreeNode#setNodeAttribute(String, String)
-     */    
-    public void setNodeAttribute (String attributeName, String attributeValue) {
+     */
+    public void setNodeAttribute(String attributeName, String attributeValue) {
         Element element = (Element) this.node;
         element.setAttribute(attributeName, attributeValue);
     }
-    
+
     /**
      * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getChildren(java.lang.String)
      */
@@ -449,7 +450,7 @@
         List languageChildren = new ArrayList();
 
         for (int i = 0; i < children.length; i++) {
-            if (children[i].getLabel(language) != null) {
+            if (children[i].hasLink(language)) {
                 languageChildren.add(children[i]);
             }
         }
@@ -460,13 +461,13 @@
     /**
      * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getParent()
      */
-    public SiteTreeNode getParent() {
+    public SiteNode getParent() {
         SiteTreeNode parent = null;
 
         Node parentNode = this.node.getParentNode();
         if (parentNode.getNodeType() == Node.ELEMENT_NODE
                 && parentNode.getLocalName().equals(NODE_NAME)) {
-            parent = new SiteTreeNodeImpl(parentNode);
+            parent = new SiteTreeNodeImpl(this.factory, getTree(), parentNode);
             ContainerUtil.enableLogging(parent, getLogger());
         }
 
@@ -478,8 +479,9 @@
      * @return A namespace helper.
      */
     protected NamespaceHelper getNamespaceHelper() {
-        NamespaceHelper helper = new NamespaceHelper(DefaultSiteTree.NAMESPACE_URI, "", this.node
-                .getOwnerDocument());
+        NamespaceHelper helper = new NamespaceHelper(DefaultSiteTree.NAMESPACE_URI,
+                "",
+                this.node.getOwnerDocument());
         return helper;
     }
 
@@ -487,13 +489,10 @@
      * @see org.apache.lenya.cms.site.tree.SiteTreeNode#getParent(java.lang.String)
      */
     public SiteTreeNode getParent(String language) {
-        SiteTreeNode parent = getParent();
-
-        Label label = parent.getLabel(language);
-        if (label == null) {
+        SiteTreeNode parent = (SiteTreeNode) getParent();
+        if (!parent.hasLink(language)) {
             parent = null;
         }
-
         return parent;
     }
 
@@ -518,6 +517,38 @@
 
     public void setUUID(String uuid) {
         setNodeAttribute(UUID_ATTRIBUTE_NAME, uuid);
+    }
+
+    public SiteStructure getStructure() {
+        return getTree();
+    }
+
+    protected SiteTree getTree() {
+        return this.tree;
+    }
+
+    public String[] getLanguages() {
+        Label[] labels = getLabels();
+        String[] languages = new String[labels.length];
+        for (int i = 0; i < labels.length; i++) {
+            languages[i] = labels[i].getLanguage();
+        }
+        return languages;
+    }
+
+    public Link getLink(String language) throws SiteException {
+        Label[] labels = getLabels();
+        for (int i = 0; i < labels.length; i++) {
+            if (labels[i].getLanguage().equals(language)) {
+                return labels[i];
+            }
+        }
+        throw new SiteException("The node [" + this + "] doesn't contain the language [" + language
+                + "].");
+    }
+
+    public boolean hasLink(String language) {
+        return getLabel(language) != null;
     }
 
 }

Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/TreeSiteManager.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/TreeSiteManager.java?rev=430088&r1=430087&r2=430088&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/TreeSiteManager.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/tree/TreeSiteManager.java Wed Aug  9 09:33:26 2006
@@ -24,6 +24,7 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.DocumentException;
 import org.apache.lenya.cms.publication.DocumentFactory;
 import org.apache.lenya.cms.publication.DocumentLocator;
 import org.apache.lenya.cms.publication.Publication;
@@ -32,8 +33,8 @@
 import org.apache.lenya.cms.repository.RepositoryItemFactory;
 import org.apache.lenya.cms.site.AbstractSiteManager;
 import org.apache.lenya.cms.site.Label;
+import org.apache.lenya.cms.site.Link;
 import org.apache.lenya.cms.site.SiteNode;
-import org.apache.lenya.cms.site.NodeFactory;
 import org.apache.lenya.cms.site.NodeSet;
 import org.apache.lenya.cms.site.SiteException;
 import org.apache.lenya.cms.site.SiteStructure;
@@ -136,11 +137,11 @@
         }
 
         NodeSet nodes = new NodeSet();
-        Publication pub = resource.getPublication();
-        String area = resource.getArea();
+        Publication pub = resource.getStructure().getPublication();
+        String area = resource.getStructure().getArea();
         SiteTree tree = getTree(map, pub, area);
 
-        SiteTreeNode node = tree.getNode(resource.getPath());
+        SiteTreeNode node = (SiteTreeNode) tree.getNode(resource.getPath());
         if (node != null) {
             List preOrder = node.preOrder();
 
@@ -149,8 +150,7 @@
 
             for (int i = 0; i < preOrder.size(); i++) {
                 SiteTreeNode descendant = (SiteTreeNode) preOrder.get(i);
-                SiteNode descendantNode = NodeFactory.getNode(pub, area, descendant.getAbsoluteId());
-                nodes.add(descendantNode);
+                nodes.add(descendant);
             }
 
             if (getLogger().isDebugEnabled()) {
@@ -165,9 +165,12 @@
      * @see org.apache.lenya.cms.site.SiteManager#contains(org.apache.lenya.cms.publication.Document)
      */
     public boolean contains(Document resource) throws SiteException {
+        boolean exists = false;
         SiteTree tree = getTree(resource);
-        SiteTreeNode node = tree.getNodeByUUID(resource.getUUID());
-        boolean exists = node != null && node.getLabel(resource.getLanguage()) != null;
+        if (tree.containsUuid(resource.getUUID())) {
+            SiteTreeNode node = (SiteTreeNode) tree.getByUuid(resource.getUUID());
+            exists = node != null && node.hasLink(resource.getLanguage());
+        }
         return exists;
     }
 
@@ -176,8 +179,7 @@
      */
     public boolean containsInAnyLanguage(Document resource) throws SiteException {
         SiteTree tree = getTree(resource);
-        SiteTreeNode node = tree.getNode(resource.getPath());
-        return node != null;
+        return tree.containsUuid(resource.getUUID());
     }
 
     /**
@@ -188,68 +190,77 @@
         SiteTree sourceTree = getTree(sourceDocument);
         SiteTree destinationTree = getTree(destinationDocument);
 
-        SiteTreeNode sourceNode = sourceTree.getNode(sourceDocument.getPath());
+        SiteTreeNode sourceNode = (SiteTreeNode) sourceTree.getByUuid(sourceDocument.getUUID());
         if (sourceNode == null) {
             throw new SiteException("The node for source document [" + sourceDocument
                     + "] doesn't exist!");
         }
 
         SiteTreeNode[] siblings = sourceNode.getNextSiblings();
-        SiteTreeNode parent = sourceNode.getParent();
+        SiteNode parent = sourceNode.getParent();
         String parentId = "";
         if (parent != null) {
-            parentId = parent.getAbsoluteId();
+            parentId = parent.getPath();
         }
         SiteTreeNode sibling = null;
-        String siblingDocId = null;
+        String siblingPath = null;
 
-        // same document ID -> insert at the same position
-        if (sourceDocument.getPath().equals(destinationDocument.getPath())) {
+        // same UUID -> insert at the same position
+        if (sourceDocument.getUUID().equals(destinationDocument.getUUID())) {
             for (int i = 0; i < siblings.length; i++) {
-                String docId = parentId + "/" + siblings[i].getId();
-                sibling = destinationTree.getNode(docId);
+                String path = parentId + "/" + siblings[i].getName();
+                sibling = (SiteTreeNode) destinationTree.getNode(path);
                 if (sibling != null) {
-                    siblingDocId = docId;
+                    siblingPath = path;
                     break;
                 }
             }
         }
 
-        Label label = sourceNode.getLabel(sourceDocument.getLanguage());
-        if (label == null) {
-            // the node that we're trying to publish
-            // doesn't have this language
-            throw new SiteException("The node " + sourceDocument.getPath()
-                    + " doesn't contain a label for language " + sourceDocument.getLanguage());
-        }
-        SiteTreeNode destinationNode = destinationTree.getNode(destinationDocument.getPath());
-        if (destinationNode == null) {
-            Label[] labels = { label };
-
-            if (siblingDocId == null) {
-                destinationTree.addNode(destinationDocument.getPath(),
-                        destinationDocument.getUUID(),
-                        labels,
-                        sourceNode.visibleInNav(),
-                        sourceNode.getHref(),
-                        sourceNode.getSuffix(),
-                        sourceNode.hasLink());
+        try {
+
+            if (!sourceNode.hasLink(sourceDocument.getLanguage())) {
+                // the node that we're trying to publish
+                // doesn't have this language
+                throw new SiteException("The node " + sourceDocument.getPath()
+                        + " doesn't contain a label for language " + sourceDocument.getLanguage());
+            }
+            Link link = sourceNode.getLink(sourceDocument.getLanguage());
+            SiteTreeNode destinationNode = (SiteTreeNode) destinationTree.getNode(destinationDocument.getPath());
+            if (destinationNode == null) {
+                if (siblingPath == null) {
+                    destinationTree.addNode(destinationDocument.getPath(),
+                            destinationDocument.getUUID(),
+                            sourceNode.visibleInNav(),
+                            sourceNode.getHref(),
+                            sourceNode.getSuffix(),
+                            sourceNode.hasLink());
+                    destinationTree.addLabel(destinationDocument.getPath(),
+                            destinationDocument.getLanguage(),
+                            link.getLabel());
+                } else {
+                    destinationTree.addNode(destinationDocument.getPath(),
+                            destinationDocument.getUUID(),
+                            sourceNode.visibleInNav(),
+                            sourceNode.getHref(),
+                            sourceNode.getSuffix(),
+                            sourceNode.hasLink(),
+                            siblingPath);
+                    destinationTree.addLabel(destinationDocument.getPath(),
+                            destinationDocument.getLanguage(),
+                            link.getLabel());
+                }
+
             } else {
-                destinationTree.addNode(destinationDocument.getPath(),
-                        destinationDocument.getUUID(),
-                        labels,
-                        sourceNode.visibleInNav(),
-                        sourceNode.getHref(),
-                        sourceNode.getSuffix(),
-                        sourceNode.hasLink(),
-                        siblingDocId);
+                // if the node already exists in the live
+                // tree simply insert the label in the
+                // live tree
+                destinationTree.setLabel(destinationDocument.getPath(),
+                        link.getLanguage(),
+                        link.getLabel());
             }
-
-        } else {
-            // if the node already exists in the live
-            // tree simply insert the label in the
-            // live tree
-            destinationTree.setLabel(destinationDocument.getPath(), label);
+        } catch (DocumentException e) {
+            throw new SiteException(e);
         }
 
     }
@@ -262,28 +273,30 @@
                 document.getPublication(),
                 document.getArea());
 
-        SiteTreeNode node = tree.getNode(document.getPath());
+        SiteTreeNode node = (SiteTreeNode) tree.getByUuid(document.getUUID());
 
         if (node == null) {
             throw new SiteException("Sitetree node for document [" + document + "] does not exist!");
         }
 
-        Label label = node.getLabel(document.getLanguage());
-
-        if (label == null) {
+        if (!node.hasLink(document.getLanguage())) {
             throw new SiteException("Sitetree label for document [" + document + "] in language ["
                     + document.getLanguage() + "]does not exist!");
         }
 
-        if (node.getLabels().length == 1 && node.getChildren().length > 0) {
+        if (node.getLanguages().length == 1 && node.getChildren().length > 0) {
             throw new SiteException("Cannot delete last language version of document [" + document
                     + "] because this node has children.");
         }
 
-        node.removeLabel(label);
+        node.removeLabel(document.getLanguage());
 
-        if (node.getLabels().length == 0) {
-            tree.removeNode(document.getPath());
+        if (node.getLanguages().length == 0) {
+            try {
+                tree.removeNode(document.getPath());
+            } catch (DocumentException e) {
+                throw new SiteException(e);
+            }
         } else {
             tree.save();
         }
@@ -302,11 +315,12 @@
      *      java.lang.String)
      */
     public void setLabel(Document document, String label) throws SiteException {
-        Label labelObject = getLabelObject(document);
-        labelObject.setLabel(label);
-
         SiteTree tree = getTree(document);
-        tree.setLabel(document.getPath(), labelObject);
+        try {
+            tree.setLabel(document.getPath(), document.getLanguage(), label);
+        } catch (DocumentException e) {
+            throw new SiteException(e);
+        }
     }
 
     /**
@@ -315,7 +329,11 @@
      */
     public void setVisibleInNav(Document document, boolean visibleInNav) throws SiteException {
         SiteTree tree = getTree(document);
-        tree.setVisibleInNav(document.getPath(), visibleInNav);
+        try {
+            tree.setVisibleInNav(document.getPath(), visibleInNav);
+        } catch (DocumentException e) {
+            throw new SiteException(e);
+        }
     }
 
     /**
@@ -329,7 +347,7 @@
         Label label = null;
         SiteTree siteTree = getTree(document);
         if (siteTree != null) {
-            SiteTreeNode node = siteTree.getNodeByUUID(document.getUUID());
+            SiteTreeNode node = (SiteTreeNode) siteTree.getByUuid(document.getUUID());
             if (node == null) {
                 throw new SiteException("Node for document [" + document + "] does not exist!");
             }
@@ -350,15 +368,16 @@
     public Document[] getDocuments(DocumentFactory map, Publication publication, String area)
             throws SiteException {
         try {
-            List allNodes = getTree(map, publication, area).getNode("/").preOrder();
+            SiteTreeNode root = (SiteTreeNode) getTree(map, publication, area).getNode("/");
+            List allNodes = root.preOrder();
             List documents = new ArrayList();
 
             for (int i = 1; i < allNodes.size(); i++) {
                 SiteTreeNode node = (SiteTreeNode) allNodes.get(i);
-                Document doc = map.get(publication, area, node.getUUID());
+                Document doc = map.get(publication, area, node.getUuid());
                 String[] languages = doc.getLanguages();
                 for (int l = 0; l < languages.length; l++) {
-                    documents.add(map.getLanguageVersion(doc, languages[l]));
+                    documents.add(doc.getTranslation(languages[l]));
                 }
             }
             return (Document[]) documents.toArray(new Document[documents.size()]);
@@ -376,19 +395,17 @@
             throw new SiteException("The document [" + document + "] is already contained!");
         }
         SiteTree tree = getTree(document);
-        Label label = new Label("", document.getLanguage());
 
-        SiteTreeNode node = tree.getNode(path);
-        if (node == null) {
-            Label[] labels = { label };
-            tree.addNode(path, document.getUUID(), labels, true, null, null, false);
+        SiteTreeNode node;
+        if (!tree.contains(path)) {
+            node = tree.addNode(path, document.getUUID(), true, null, null, false);
         } else {
-            if (node.getUUID() != null) {
+            node = (SiteTreeNode) tree.getNode(path);
+            if (node.getUuid() != null) {
                 ((SiteTreeNodeImpl) node).setUUID(document.getUUID());
             }
-            tree.addLabel(path, label);
         }
-
+        tree.addLabel(path, document.getLanguage(), "");
     }
 
     /**
@@ -400,7 +417,7 @@
             throw new SiteException("The document [" + document + "] is already contained!");
         }
         SiteTree tree = getTree(document);
-        SiteTreeNode node = tree.getNode(path);
+        SiteTreeNode node = (SiteTreeNode) tree.getNode(path);
         node.setUUID(document.getUUID());
         tree.save();
     }
@@ -463,7 +480,7 @@
         }
         SiteTree tree = getTree(factory, pub, locator.getArea());
 
-        SiteTreeNode node = tree.getNode(path);
+        SiteTreeNode node = (SiteTreeNode) tree.getNode(path);
         String suffix = null;
         int version = 0;
         String idwithoutsuffix = null;
@@ -490,7 +507,7 @@
             while (node != null) {
                 version = version + 1;
                 path = idwithoutsuffix + "-" + version;
-                node = tree.getNode(path);
+                node = (SiteTreeNode) tree.getNode(path);
             }
         }
 
@@ -499,29 +516,33 @@
 
     public boolean isVisibleInNav(Document document) throws SiteException {
         SiteTree tree = getTree(document);
-        return tree.isVisibleInNav(document.getPath());
+        try {
+            return tree.isVisibleInNav(document.getPath());
+        } catch (DocumentException e) {
+            throw new SiteException(e);
+        }
     }
 
     public String getPath(DocumentFactory factory, Publication pub, String area, String uuid)
             throws SiteException {
         SiteTree tree = getTree(factory, pub, area);
-        SiteTreeNode node = tree.getNodeByUUID(uuid);
+        SiteNode node = tree.getByUuid(uuid);
         if (node == null) {
             throw new SiteException("No node found for [" + pub.getId() + ":" + area + ":" + uuid
                     + "]");
         }
-        return node.getAbsoluteId();
+        return node.getPath();
     }
 
     public String getUUID(DocumentFactory factory, Publication pub, String area, String path)
             throws SiteException {
         SiteTree tree = getTree(factory, pub, area);
-        SiteTreeNode node = tree.getNode(path);
+        SiteNode node = tree.getNode(path);
         if (node == null) {
             throw new SiteException("No node found for [" + pub.getId() + ":" + area + ":" + path
                     + "]");
         }
-        return node.getUUID();
+        return node.getUuid();
     }
 
     public boolean contains(DocumentFactory factory, Publication pub, String area, String path)
@@ -538,11 +559,11 @@
             throw new SiteException(e);
         }
         SiteTree tree = getTree(factory, pub, locator.getArea());
-        SiteTreeNode node = tree.getNode(locator.getPath());
-        if (node == null) {
-            return false;
+        if (tree.contains(locator.getPath())) {
+            SiteNode node = tree.getNode(locator.getPath());
+            return node.hasLink(locator.getLanguage());
         } else {
-            return node.getLabel(locator.getLanguage()) != null;
+            return false;
         }
     }
 

Modified: lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/usecases/Nudge.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/usecases/Nudge.java?rev=430088&r1=430087&r2=430088&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/usecases/Nudge.java (original)
+++ lenya/trunk/src/modules/sitetree/java/src/org/apache/lenya/cms/site/usecases/Nudge.java Wed Aug  9 09:33:26 2006
@@ -60,8 +60,7 @@
                     .getFactory(), publication, getSourceDocument().getArea());
             if (structure instanceof SiteTree) {
 
-                SiteTree tree = (SiteTree) structure;
-                SiteTreeNode node = tree.getNode(SiteUtil.getPath(this.manager, getSourceDocument()));
+                SiteTreeNode node = (SiteTreeNode) getSourceDocument().getLink().getNode();
                 SiteTreeNode[] siblings = null;
 
                 String direction = getParameterAsString(DIRECTION);

Modified: lenya/trunk/src/modules/sitetree/java/test/org/apache/lenya/cms/site/tree/DefaultSiteTreeTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/test/org/apache/lenya/cms/site/tree/DefaultSiteTreeTest.java?rev=430088&r1=430087&r2=430088&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/test/org/apache/lenya/cms/site/tree/DefaultSiteTreeTest.java (original)
+++ lenya/trunk/src/modules/sitetree/java/test/org/apache/lenya/cms/site/tree/DefaultSiteTreeTest.java Wed Aug  9 09:33:26 2006
@@ -29,6 +29,7 @@
 import org.apache.lenya.cms.repository.RepositoryException;
 import org.apache.lenya.cms.site.Label;
 import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.cms.site.SiteNode;
 import org.apache.lenya.cms.site.tree.DefaultSiteTree;
 import org.apache.lenya.cms.site.tree.SiteTreeNode;
 
@@ -45,30 +46,19 @@
     public void setUp() throws Exception {
         super.setUp();
         Publication pub = PublicationUtil.getPublication(getManager(), "test");
-        this.siteTree = new DefaultSiteTree(pub, "test", getManager(), getLogger());
+        this.siteTree = new DefaultSiteTree(getIdentityMap(),
+                pub,
+                "test",
+                getManager(),
+                getLogger());
         ContainerUtil.enableLogging(this.siteTree, getLogger());
 
         this.siteTree.getRepositoryNode().lock();
 
-        Label label = new Label("Foo", "en");
-        Label[] fooLabels = { label };
-        this.siteTree.addNode("/foo", "foo-uuid", fooLabels, true, null, null, false);
-        label = new Label("Home", "en");
-        Label[] homeLabels = { label };
-        this.siteTree.addNode("/index", "index-uuid", homeLabels, true, null, null, false);
-        label = new Label("Bar", "en");
-        Label label_de = new Label("Stab", "de");
-        Label[] barLabels = { label, label_de };
-        this.siteTree.addNode("/foo/bar",
-                "foo-bar-uuid",
-                barLabels,
-                true,
-                "http://exact.biz",
-                "suffix",
-                true);
-        label = new Label("Lala", "en");
-        Label[] lalaLabels = { label };
-        this.siteTree.addNode("/foo/lala", "foo-lala-uuid", lalaLabels, true, null, null, false);
+        this.siteTree.addNode("/foo", "foo-uuid", true, null, null, false);
+        this.siteTree.addNode("/index", "index-uuid", true, null, null, false);
+        this.siteTree.addNode("/foo/bar", "foo-bar-uuid", true, "http://exact.biz", "suffix", true);
+        this.siteTree.addNode("/foo/lala", "foo-lala-uuid", true, null, null, false);
     }
 
     /**
@@ -99,15 +89,13 @@
      * @throws SiteException if an error occurs
      */
     final public void testAddNodeStringStringLabelArray() throws SiteException {
-        Label label = new Label("Tutorial", null);
-        Label[] labels = { label };
-
         String uuid = "12345";
-        this.siteTree.addNode("/foo", "tutorial", uuid, labels, true);
-        SiteTreeNode node = this.siteTree.getNode("/foo/tutorial");
+        this.siteTree.addNode("/foo", "tutorial", uuid, true);
+        this.siteTree.addLabel("/foo", "en", "Tutorial");
+        SiteNode node = this.siteTree.getNode("/foo/tutorial");
         assertNotNull(node);
-        assertEquals(node.getId(), "tutorial");
-        assertEquals(node.getUUID(), uuid);
+        assertEquals(node.getName(), "tutorial");
+        assertEquals(node.getUuid(), uuid);
     }
 
     /**
@@ -123,14 +111,12 @@
      * @throws SiteException if an error occurs
      */
     final public void testAddNodeStringLabelArrayStringStringboolean() throws SiteException {
-        Label label1 = new Label("Doh", "en");
-        Label label2 = new Label("Ding", "en");
-        Label[] labels = { label1, label2 };
-
-        this.siteTree.addNode("/foo/ding", "foo-ding-uuid", labels, true, null, null, false);
+        this.siteTree.addNode("/foo/ding", "foo-ding-uuid", true, null, null, false);
+        this.siteTree.addLabel("/foo/ding", "en", "Doh");
+        this.siteTree.addLabel("/foo/ding", "de", "Ding");
 
         assertNotNull(this.siteTree.getNode("/foo/ding"));
-        assertEquals(this.siteTree.getNode("/foo/ding").getId(), "ding");
+        assertEquals(this.siteTree.getNode("/foo/ding").getName(), "ding");
     }
 
     /**
@@ -138,47 +124,45 @@
      * @throws SiteException if an error occurs
      */
     final public void testAddNodeStringStringLabelArrayStringStringboolean() throws SiteException {
-        Label label1 = new Label("Doh", "en");
-        Label label2 = new Label("Ding", "en");
-        Label[] labels = { label1, label2 };
-        
+
         String uuid = "123";
 
-        this.siteTree.addNode("/foo", "baz", uuid, labels, true, null, null, false);
+        this.siteTree.addNode("/foo", "baz", uuid, true, null, null, false);
 
         assertNotNull(this.siteTree.getNode("/foo/baz"));
-        assertEquals(this.siteTree.getNode("/foo/baz").getId(), "baz");
+        assertEquals(this.siteTree.getNode("/foo/baz").getName(), "baz");
     }
 
     /**
      * Test addLabel
+     * @throws SiteException
      */
-    final public void testAddLabel() {
-        Label label = new Label("Tutorial", null);
-        Label[] labels = null;
-
-        this.siteTree.addLabel("/foo/bar", label);
-        labels = this.siteTree.getNode("/foo/bar").getLabels();
-        assertEquals(labels.length, 3);
-        label = this.siteTree.getNode("/foo/bar").getLabel("");
+    final public void testAddLabel() throws SiteException {
+        this.siteTree.addLabel("/foo/bar", "en", "Tutorial");
+        Label[] labels = ((SiteTreeNode) this.siteTree.getNode("/foo/bar")).getLabels();
+        assertEquals(labels.length, 1);
+        Label label = ((SiteTreeNode) this.siteTree.getNode("/foo/bar")).getLabel("en");
         assertNotNull(label);
         assertEquals(label.getLabel(), "Tutorial");
     }
 
     /**
      * Test removeLabel
+     * @throws SiteException
      */
-    final public void testRemoveLabel() {
-        assertEquals(this.siteTree.getNode("/foo/bar").getLabels().length, 2);
+    final public void testRemoveLabel() throws SiteException {
+        this.siteTree.addLabel("/foo/bar", "de", "Hello");
+        this.siteTree.addLabel("/foo/bar", "en", "World");
+        assertEquals(((SiteTreeNode) this.siteTree.getNode("/foo/bar")).getLabels().length, 2);
 
-        Label label = new Label("Stab", "de");
-        this.siteTree.removeLabel("/foo/bar", label);
-        assertEquals(this.siteTree.getNode("/foo/bar").getLabels().length, 1);
+        this.siteTree.removeLabel("/foo/bar", "de");
+        assertEquals(((SiteTreeNode) this.siteTree.getNode("/foo/bar")).getLabels().length, 1);
 
-        assertEquals(this.siteTree.getNode("/foo/bar").getLabels()[0], new Label("Bar", "en"));
+        assertEquals(((SiteTreeNode) this.siteTree.getNode("/foo/bar")).getLabels()[0].getLanguage(),
+                "en");
 
-        this.siteTree.addLabel("/foo/bar", label);
-        assertEquals(this.siteTree.getNode("/foo/bar").getLabels().length, 2);
+        this.siteTree.addLabel("/foo/bar", "de", "Foo");
+        assertEquals(((SiteTreeNode) this.siteTree.getNode("/foo/bar")).getLabels().length, 2);
     }
 
     /**
@@ -187,32 +171,28 @@
      * @throws SiteException if an error occurs
      */
     final public void testRemoveNode() throws SiteException {
-        Label label1 = new Label("Hi", "en");
-        Label label2 = new Label("Ho", "en");
-        Label[] labels1 = { label1, label2 };
 
-        this.siteTree.addNode("/hi", "hi-uuid", labels1, true, null, null, false);
+        this.siteTree.addNode("/hi", "hi-uuid", true, null, null, false);
 
-        Label[] labels2 = { label1, label2 };
 
-        this.siteTree.addNode("/hi/ho", "hi-ho-uuid", labels2, true, null, null, false);
+        this.siteTree.addNode("/hi/ho", "hi-ho-uuid", true, null, null, false);
 
         assertNotNull(this.siteTree.getNode("/hi/ho"));
 
         this.siteTree.removeNode("/hi");
 
-        assertNull(this.siteTree.getNode("/hi/ho"));
-        assertNull(this.siteTree.getNode("/hi"));
+        assertFalse(this.siteTree.contains("/hi/ho"));
+        assertFalse(this.siteTree.contains("/hi"));
     }
 
     /**
      * Test getNode
+     * @throws SiteException
      * 
      */
-    final public void testGetNode() {
+    final public void testGetNode() throws SiteException {
         assertNotNull(this.siteTree.getNode("/foo/bar"));
-
-        assertNull(this.siteTree.getNode("/foo/baz"));
+        assertFalse(this.siteTree.contains("/foo/baz"));
     }
 
     /**
@@ -250,32 +230,36 @@
      */
     final public void testImportSubtree() throws PublicationException, RepositoryException {
         Publication pub = PublicationUtil.getPublication(getManager(), "test");
-        DefaultSiteTree newSiteTree = new DefaultSiteTree(pub, "test1", getManager(), getLogger());
+        DefaultSiteTree newSiteTree = new DefaultSiteTree(getIdentityMap(),
+                pub,
+                "test1",
+                getManager(),
+                getLogger());
         ContainerUtil.enableLogging(newSiteTree, getLogger());
 
         newSiteTree.getRepositoryNode().lock();
 
-        Label label = new Label("root", "en");
-        Label[] rootLabels = { label };
-        newSiteTree.addNode("/root", "root-uuid", rootLabels, true, null, null, false);
-        label = new Label("foo", "en");
-        Label[] fooLabels = { label };
-        newSiteTree.addNode("/root/foo", "root-foo-uuid", fooLabels, true, null, null, false);
-        label = new Label("subtree", "en");
-        Label[] subtreeLabels = { label };
+        newSiteTree.addNode("/root", "root-uuid", true, null, null, false);
+        newSiteTree.addLabel("/root", "en", "root");
+        newSiteTree.addNode("/root/foo", "root-foo-uuid", true, null, null, false);
+        newSiteTree.addLabel("/root/foo", "en", "foo");
         newSiteTree.addNode("/root/subtree",
                 "root-subtree-uuid",
-                subtreeLabels,
                 true,
                 "http://exact.biz",
                 "suffix",
                 true);
-        label = new Label("child", "en");
-        Label[] childLabels = { label };
-        newSiteTree.addNode("/root/subtree/child", "root-subtree-child-uuid", childLabels, true, null, null, false);
-        SiteTreeNode node = newSiteTree.getNode("/root/subtree");
+        newSiteTree.addLabel("/root/subtree", "en", "subtree");
+        newSiteTree.addNode("/root/subtree/child",
+                "root-subtree-child-uuid",
+                true,
+                null,
+                null,
+                false);
+        newSiteTree.addLabel("/root/subtree/child", "en", "child");
+        SiteTreeNode node = (SiteTreeNode) newSiteTree.getNode("/root/subtree");
         assertNotNull(node);
-        SiteTreeNode parentNode = this.siteTree.getNode("/foo/lala");
+        SiteTreeNode parentNode = (SiteTreeNode) this.siteTree.getNode("/foo/lala");
         assertNotNull(parentNode);
         this.siteTree.importSubtree(parentNode, node, "subtree", null);
         this.siteTree.save();

Modified: lenya/trunk/src/modules/sitetree/java/test/org/apache/lenya/cms/site/tree/SiteTreeNodeImplTest.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/sitetree/java/test/org/apache/lenya/cms/site/tree/SiteTreeNodeImplTest.java?rev=430088&r1=430087&r2=430088&view=diff
==============================================================================
--- lenya/trunk/src/modules/sitetree/java/test/org/apache/lenya/cms/site/tree/SiteTreeNodeImplTest.java (original)
+++ lenya/trunk/src/modules/sitetree/java/test/org/apache/lenya/cms/site/tree/SiteTreeNodeImplTest.java Wed Aug  9 09:33:26 2006
@@ -20,7 +20,7 @@
 package org.apache.lenya.cms.site.tree;
 
 import org.apache.avalon.framework.container.ContainerUtil;
-import org.apache.lenya.cms.LenyaTestCase;
+import org.apache.lenya.ac.impl.AbstractAccessControlTest;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationUtil;
 import org.apache.lenya.cms.site.Label;
@@ -32,7 +32,7 @@
 /**
  * Tests the site tree
  */
-public class SiteTreeNodeImplTest extends LenyaTestCase {
+public class SiteTreeNodeImplTest extends AbstractAccessControlTest {
 
     private SiteTreeNode node = null;
     private DefaultSiteTree siteTree = null;
@@ -43,26 +43,25 @@
     public void setUp() throws Exception {
         super.setUp();
         Publication pub = PublicationUtil.getPublication(getManager(), "test");
-        this.siteTree = new DefaultSiteTree(pub, "testArea", getManager(), getLogger());
+        this.siteTree = new DefaultSiteTree(getIdentityMap(), pub, "testArea", getManager(), getLogger());
         ContainerUtil.enableLogging(siteTree, getLogger());
         
         siteTree.getRepositoryNode().lock();
         
-        Label label = new Label("Foo", "en");
-        Label[] fooLabels = { label };
-        siteTree.addNode("/foo", "foo-uuid", fooLabels, true, null, null, false);
-        label = new Label("Bar", "en");
-        Label label_de = new Label("Stab", "de");
-        Label[] barLabels = { label, label_de };
-        siteTree.addNode("/foo/bar", "foo-bar-uuid", barLabels, true, "http://exact.biz", "suffix", true);
+        siteTree.addNode("/foo", "foo-uuid", true, null, null, false);
+        siteTree.addLabel("/foo", "en", "Foo");
+        
+        siteTree.addNode("/foo/bar", "foo-bar-uuid", true, "http://exact.biz", "suffix", true);
+        siteTree.addLabel("/foo/bar", "en", "Bar");
+        siteTree.addLabel("/foo/bar", "de", "Stab");
 
-        this.node = siteTree.getNode("/foo/bar");
+        this.node = (SiteTreeNode) siteTree.getNode("/foo/bar");
     }
 
     /**
      * @see TestCase#tearDown()
      */
-    protected void tearDown() throws Exception {
+    public void tearDown() throws Exception {
         super.tearDown();
         this.siteTree.getRepositoryNode().unlock();
     }
@@ -72,7 +71,7 @@
      * 
      */
     final public void testGetAbsoluteId() {
-        assertEquals(this.node.getAbsoluteId(), "/foo/bar");
+        assertEquals(this.node.getPath(), "/foo/bar");
     }
 
     /**
@@ -80,7 +79,7 @@
      * 
      */
     final public void testGetId() {
-        assertEquals(this.node.getId(), "bar");
+        assertEquals(this.node.getName(), "bar");
     }
 
     /**
@@ -91,8 +90,8 @@
         assertEquals(this.node.getLabels().length, 2);
         for (int i = 0; i < this.node.getLabels().length; i++) {
             Label label = this.node.getLabels()[i];
-            Label label1 = new Label("Bar", "en");
-            Label label2 = new Label("Stab", "de");
+            Label label1 = new Label(getIdentityMap(), node, "Bar", "en");
+            Label label2 = new Label(getIdentityMap(), node, "Stab", "de");
             assertTrue(label.equals(label1) || label.equals(label2));
         }
     }
@@ -112,7 +111,7 @@
      * 
      */
     final public void testAddLabel() {
-        Label label = new Label("Barolo", "it");
+        Label label = new Label(getIdentityMap(), this.node, "Barolo", "it");
         this.node.addLabel(label);
         label = this.node.getLabel("it");
         assertNotNull(label);
@@ -126,9 +125,8 @@
      * 
      */
     final public void testRemoveLabel() {
-        Label label = new Label("Bar", "en");
         assertNotNull(this.node.getLabel("en"));
-        this.node.removeLabel(label);
+        this.node.removeLabel("en");
         assertNull(this.node.getLabel("en"));
     }
 

Modified: lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Mkcol.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Mkcol.java?rev=430088&r1=430087&r2=430088&view=diff
==============================================================================
--- lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Mkcol.java (original)
+++ lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Mkcol.java Wed Aug  9 09:33:26 2006
@@ -20,16 +20,13 @@
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.excalibur.source.SourceResolver;
-import org.apache.lenya.cms.cocoon.source.SourceUtil;
 import org.apache.lenya.cms.metadata.MetaData;
 import org.apache.lenya.cms.metadata.MetaDataException;
 import org.apache.lenya.cms.metadata.dublincore.DublinCore;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentFactory;
-import org.apache.lenya.cms.publication.DocumentLocator;
 import org.apache.lenya.cms.publication.DocumentManager;
 import org.apache.lenya.cms.publication.ResourceType;
-import org.apache.lenya.cms.site.SiteUtil;
 import org.apache.lenya.cms.site.usecases.Create;
 import org.apache.lenya.workflow.WorkflowManager;
 
@@ -80,7 +77,7 @@
                     documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
 
                     DocumentFactory map = getDocumentFactory();
-                    String path = SiteUtil.getPath(this.manager, doc);
+                    String path = doc.getPath();
 
                     resourceType = (ResourceType) selector.select(TYPE);
                     String sampleUri = resourceType.getSampleURI(resourceType.getSampleNames()[0]);

Modified: lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Put.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Put.java?rev=430088&r1=430087&r2=430088&view=diff
==============================================================================
--- lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Put.java (original)
+++ lenya/trunk/src/modules/webdav/java/src/org/apache/lenya/cms/usecases/webdav/Put.java Wed Aug  9 09:33:26 2006
@@ -108,7 +108,7 @@
                     documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
 
                     DocumentFactory map = getDocumentFactory();
-                    String path = SiteUtil.getPath(this.manager, doc);
+                    String path = doc.getPath();
                     // lookupResourceType(extension)
                     resourceType = lookUpExtension(extension, selector);
                     String sampleUri = resourceType.getSampleURI(resourceType.getSampleNames()[0]);

Modified: lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java?rev=430088&r1=430087&r2=430088&view=diff
==============================================================================
--- lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java (original)
+++ lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java Wed Aug  9 09:33:26 2006
@@ -26,7 +26,6 @@
 import org.apache.lenya.cms.publication.PublicationException;
 import org.apache.lenya.cms.publication.util.DocumentSet;
 import org.apache.lenya.cms.publication.util.DocumentVisitor;
-import org.apache.lenya.cms.site.NodeFactory;
 import org.apache.lenya.cms.site.SiteNode;
 import org.apache.lenya.cms.site.SiteUtil;
 import org.apache.lenya.cms.site.usecases.AssetUtil;
@@ -79,7 +78,7 @@
                 DocumentFactory map = getSourceDocument().getFactory();
                 Document liveDoc = getSourceDocument().getAreaVersion(Publication.LIVE_AREA);
                 DocumentSet subSite = SiteUtil.getSubSite(this.manager, liveDoc);
-                SiteNode node = NodeFactory.getNode(liveDoc);
+                SiteNode node = liveDoc.getLink().getNode();
                 subSite.removeAll(SiteUtil.getExistingDocuments(this.manager, map, node));
 
                 if (!subSite.isEmpty()) {

Modified: lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java?rev=430088&r1=430087&r2=430088&view=diff
==============================================================================
--- lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java (original)
+++ lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java Wed Aug  9 09:33:26 2006
@@ -39,9 +39,9 @@
 import org.apache.lenya.cms.publication.PublicationException;
 import org.apache.lenya.cms.publication.util.DocumentSet;
 import org.apache.lenya.cms.publication.util.DocumentVisitor;
-import org.apache.lenya.cms.site.NodeFactory;
 import org.apache.lenya.cms.site.SiteManager;
 import org.apache.lenya.cms.site.SiteNode;
+import org.apache.lenya.cms.site.SiteStructure;
 import org.apache.lenya.cms.site.SiteUtil;
 import org.apache.lenya.cms.usecase.DocumentUsecase;
 import org.apache.lenya.cms.usecase.UsecaseException;
@@ -143,10 +143,11 @@
                 selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
                 siteManager = (SiteManager) selector.select(publication.getSiteManagerHint());
 
-                String path = SiteUtil.getPath(this.manager, document);
-                SiteNode liveNode = NodeFactory.getNode(document.getPublication(),
-                        Publication.LIVE_AREA,
-                        path);
+                String path = document.getPath();
+                SiteStructure structure = siteManager.getSiteStructure(getDocumentFactory(),
+                        publication,
+                        Publication.LIVE_AREA);
+                SiteNode liveNode = structure.getNode(path);
                 SiteNode[] requiredNodes = siteManager.getRequiredResources(map, liveNode);
 
                 for (int i = 0; i < requiredNodes.length; i++) {
@@ -155,7 +156,8 @@
                             map,
                             requiredNodes[i]);
                     if (liveDocs.isEmpty()) {
-                        Document authoringDoc = map.get(requiredNodes[i].getPublication(),
+                        Document authoringDoc = map.get(requiredNodes[i].getStructure()
+                                .getPublication(),
                                 Publication.AUTHORING_AREA,
                                 requiredNodes[i].getPath());
                         if (authoringDoc.exists()) {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org