Author: reto
Date: Wed Feb 17 15:16:35 2010
New Revision: 911013

URL: http://svn.apache.org/viewvc?rev=911013&view=rev
Log:
CLEREZZA-113: merged down trunk

Modified:
    
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/   
(props changed)
    
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/AbstractDiscobitsHandler.java
    
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitsTypeHandler.java
    
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/SimpleDiscobitsHandler.java
    
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/TitledContentRenderlet.java
    
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyManager.java
    
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyService.java
    
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/test/java/org/apache/clerezza/platform/content/hierarchy/HierarchyTest.java

Propchange: 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Feb 17 15:16:35 2010
@@ -1,3 +1,5 @@
+/incubator/clerezza/issues/CLEREZZA-103/org.apache.clerezza.platform.content:907223-909027
 
/incubator/clerezza/issues/CLEREZZA-25/org.apache.clerezza.platform.content:891178-892849
 
/incubator/clerezza/issues/CLEREZZA-65/org.apache.clerezza.platform.content:897875-897920
 
/incubator/clerezza/issues/CLEREZZA-70/org.apache.clerezza.platform.content:897917-903631
+/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.content:908544-910847

Modified: 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/AbstractDiscobitsHandler.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/AbstractDiscobitsHandler.java?rev=911013&r1=911012&r2=911013&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/AbstractDiscobitsHandler.java
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/AbstractDiscobitsHandler.java
 Wed Feb 17 15:16:35 2010
@@ -23,6 +23,10 @@
 
 import java.util.Set;
 import javax.ws.rs.core.MediaType;
+import org.apache.clerezza.platform.content.hierarchy.HierarchyNode;
+import org.apache.clerezza.platform.content.hierarchy.HierarchyService;
+import 
org.apache.clerezza.platform.content.hierarchy.NodeAlreadyExistsException;
+import 
org.apache.clerezza.platform.content.hierarchy.NodeDoesNotExistException;
 
 import org.apache.clerezza.rdf.core.LiteralFactory;
 import org.apache.clerezza.rdf.core.MGraph;
@@ -58,11 +62,29 @@
         */
        protected abstract Set<MetaDataGenerator> getMetaDataGenerators();
 
+       /**
+        * Returns the hierarchy service used to manage hierachy in the content
+        * graph
+        * @return the hierarchy service
+        */
+       protected abstract HierarchyService getHierarchyService();
+       
        @Override
        public void put(UriRef infoDiscoBitUri, MediaType mediaType,
                        byte[] data) {
-               MGraph mGraph = getMGraph();
-               GraphNode infoDiscoBitNode = new GraphNode(infoDiscoBitUri, 
mGraph);
+
+               GraphNode infoDiscoBitNode;
+               try {
+                       HierarchyService hierarchyService = 
getHierarchyService();
+                       if (hierarchyService == null) {
+                               infoDiscoBitNode = new 
GraphNode(infoDiscoBitUri, getMGraph());
+                       } else {
+                               infoDiscoBitNode = 
hierarchyService.createNonCollectionNode(infoDiscoBitUri);
+                       }
+                       
+               } catch (NodeAlreadyExistsException ex) {
+                       infoDiscoBitNode = new GraphNode(infoDiscoBitUri, 
getMGraph());
+               }
                infoDiscoBitNode.addProperty(RDF.type, DISCOBITS.InfoDiscoBit);
                TypedLiteral dataLiteral = 
LiteralFactory.getInstance().createTypedLiteral(data);
                infoDiscoBitNode.deleteProperties(DISCOBITS.infoBit);
@@ -105,7 +127,18 @@
                                return;
                        }                       
                }
-               GraphNode graphNode = new GraphNode(node, mGraph);
+               GraphNode graphNode;
+               try {
+                       HierarchyService hierarchyService = 
getHierarchyService();
+                       if (hierarchyService == null) {
+                               graphNode = new GraphNode(node, mGraph);        
                        
+                       } else {
+                               graphNode = 
hierarchyService.getHierarchyNode((UriRef) node);
+                               ((HierarchyNode) graphNode).delete();
+                       }
+               } catch (NodeDoesNotExistException ex) {
+                       graphNode = new GraphNode(node, mGraph);
+               }
                graphNode.deleteNodeContext();
        }
 

Modified: 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitsTypeHandler.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitsTypeHandler.java?rev=911013&r1=911012&r2=911013&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitsTypeHandler.java
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitsTypeHandler.java
 Wed Feb 17 15:16:35 2010
@@ -20,7 +20,6 @@
 
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 
 import java.util.Set;
@@ -35,6 +34,7 @@
 import javax.ws.rs.core.UriInfo;
 import javax.ws.rs.core.Response.Status;
 import javax.ws.rs.ext.RuntimeDelegate;
+import org.apache.clerezza.platform.content.hierarchy.HierarchyService;
 
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Property;
@@ -48,9 +48,7 @@
 import org.apache.clerezza.platform.graphprovider.content.ContentGraphProvider;
 import org.apache.clerezza.platform.typehandlerspace.SupportedTypes;
 import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.Triple;
 import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.ontologies.RDF;
 import org.apache.clerezza.rdf.utils.GraphNode;
 
 /**
@@ -79,6 +77,9 @@
 
        @Reference
        private ContentGraphProvider cgProvider;
+
+       @Reference
+       private HierarchyService hierarchyService;
        
        private static final Logger logger = 
LoggerFactory.getLogger(DiscobitsTypeHandler.class);
 
@@ -98,7 +99,6 @@
                final MGraph mGraph = cgProvider.getContentGraph();
                final UriRef uri = new 
UriRef(uriInfo.getAbsolutePath().toString());
                final GraphNode graphNode = new GraphNode(uri, mGraph);
-               final Iterator<Triple> typeStmts = mGraph.filter(uri, RDF.type, 
null);
                InfoDiscobit infoDiscobit = 
InfoDiscobit.createInstance(graphNode);
                if (infoDiscobit != null) {
                        return infoDiscobit;
@@ -154,4 +154,9 @@
        protected Set<MetaDataGenerator> getMetaDataGenerators() {
                return metaDataGenerators;
        }
+
+       @Override
+       protected HierarchyService getHierarchyService() {
+               return hierarchyService;
+       }
 }

Modified: 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/SimpleDiscobitsHandler.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/SimpleDiscobitsHandler.java?rev=911013&r1=911012&r2=911013&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/SimpleDiscobitsHandler.java
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/SimpleDiscobitsHandler.java
 Wed Feb 17 15:16:35 2010
@@ -19,6 +19,7 @@
 package org.apache.clerezza.platform.content;
 
 import java.util.Set;
+import org.apache.clerezza.platform.content.hierarchy.HierarchyService;
 import org.apache.clerezza.rdf.core.MGraph;
 
 /**
@@ -43,4 +44,9 @@
                return null;
        }
 
+       @Override
+       protected HierarchyService getHierarchyService() {
+               return null;
+       }
+
 }

Modified: 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/TitledContentRenderlet.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/TitledContentRenderlet.java?rev=911013&r1=911012&r2=911013&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/TitledContentRenderlet.java
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/TitledContentRenderlet.java
 Wed Feb 17 15:16:35 2010
@@ -67,13 +67,13 @@
                        OutputStream os) throws IOException {
                PrintWriter writer = new PrintWriter(os);
                List<GraphNode> containedNodes = getContainedNodes(res);
+               writer.print("<div class='tx-titledcontent'>");
                writer.print(getHeaderOpen());
                writer.flush();
                callbackRenderer.render(
                                containedNodes.get(0),
                                context, mode, os);
                writer.println(getHeaderClose());
-               writer.print("<div>");
                headingLevel.set(headingLevel.get()+1);
                writer.flush();
                callbackRenderer.render(

Modified: 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyManager.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyManager.java?rev=911013&r1=911012&r2=911013&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyManager.java
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyManager.java
 Wed Feb 17 15:16:35 2010
@@ -18,9 +18,7 @@
  */
 package org.apache.clerezza.platform.content.hierarchy;
 
-import java.io.UnsupportedEncodingException;
 import java.net.URI;
-import java.net.URLEncoder;
 import java.util.Iterator;
 import java.util.List;
 import javax.ws.rs.FormParam;
@@ -86,7 +84,7 @@
                        @FormParam(value = "parentCollectionUri") UriRef 
parentCollectionUri,
                        @FormParam(value = "pos") Integer pos,
                        @FormParam(value = "name") String name) {
-               UriRef resourceUri = 
createNonCollectionUri(parentCollectionUri, name);
+               UriRef resourceUri = 
hierarchyService.createNonCollectionUri(parentCollectionUri, name);
                try {
                        HierarchyNode node;
                        if (pos == null) {
@@ -125,7 +123,7 @@
                        @FormParam(value = "parentCollectionUri") UriRef 
parentCollectionUri,
                        @FormParam(value = "pos") Integer pos,
                        @FormParam(value = "name") String name) {
-               UriRef collectionUri = createCollectionUri(parentCollectionUri, 
name);
+               UriRef collectionUri = 
hierarchyService.createCollectionUri(parentCollectionUri, name);
                try {
                        CollectionNode node;
                        if (pos == null) {
@@ -294,24 +292,4 @@
                }
                return count;
        }
-
-       /**
-        * Creates a uri that ends with a slash ('/').
-        * @param parrentCollectionUri the URI of the parent collection
-        * @param name the name of the collection
-        * @return
-        */
-       private UriRef createCollectionUri(UriRef parrentCollectionUri, String 
name) {
-               return new UriRef(
-                               createNonCollectionUri(parrentCollectionUri, 
name).getUnicodeString() + "/");
-       }
-
-       private UriRef createNonCollectionUri(UriRef parentCollectionUri, 
String name) {
-               try {
-                       return new 
UriRef(parentCollectionUri.getUnicodeString() +
-                                       URLEncoder.encode(name, "UTF-8"));
-               } catch (UnsupportedEncodingException ex) {
-                       throw new RuntimeException(ex);
-               }
-       }
 }

Modified: 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyService.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyService.java?rev=911013&r1=911012&r2=911013&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyService.java
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyService.java
 Wed Feb 17 15:16:35 2010
@@ -18,8 +18,10 @@
  */
 package org.apache.clerezza.platform.content.hierarchy;
 
+import java.io.UnsupportedEncodingException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.net.URLEncoder;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -100,8 +102,13 @@
 
        private void checkExistence(HierarchyNode node) throws 
NodeDoesNotExistException {
                if (!getRoots().contains(node)) {
-                       CollectionNode parent = node.getParent();
-                       UriRef nodeUri = node.getNode();
+                        CollectionNode parent;
+                        UriRef nodeUri = node.getNode();
+                        try {
+                            parent = node.getParent();
+                        } catch(IllegalArgumentException ex){
+                            throw new NodeDoesNotExistException(nodeUri);
+                        }                      
                        if (!parent.getMembersRdf().contains(nodeUri)) {
                                throw new NodeDoesNotExistException(nodeUri);
                        }
@@ -152,6 +159,47 @@
        }
 
        /**
+        * Creates a new {...@link HierarchyNode} which is not a {...@link 
CollectionNode}
+        * and adds it to its parent collections member list at the specified 
position
+        * posInParent.
+        * If the specified uri does not start with an existing root uri, then
+        * the base URI ('http://[host]/') of uri is added as root.
+        *
+        * @param parentCollection the uri of parent collection
+        * @param name the name of non collection node
+        * @param posInParent the position of the non collection node in the
+        *              members list of its parent collection
+        * @throws NodeAlreadyExistsException Thrown if the specified node 
already
+        *              exists.
+        * @throws IllegalArgumentException Thrown if uri ends with a '/'
+        * @return the created non collection node.
+        */
+       public HierarchyNode createNonCollectionNode(UriRef parentCollection, 
String name, int posInParent)
+                       throws NodeAlreadyExistsException {
+               UriRef uri = createNonCollectionUri(parentCollection, name);
+               return createNonCollectionNode(uri, posInParent);
+       }
+
+       /**
+        * Creates a new {...@link HierarchyNode} which is not a {...@link 
CollectionNode}
+        * and adds it at the end of its parent collections member list.
+        * If the specified uri does not start with an existing root uri, then
+        * the base URI ('http://[host]/') of uri is added as root.
+        *
+        * @param parentCollection the uri of parent collection
+        * @param name the name of non collection node
+        * @throws NodeAlreadyExistsException Thrown if the specified node 
already
+        *              exists.
+        * @throws IllegalArgumentException Thrown if uri ends with a '/'
+        * @return the created non collection node.
+        */
+       public HierarchyNode createNonCollectionNode(UriRef parentCollection, 
String name)
+                       throws NodeAlreadyExistsException {
+               UriRef uri = createNonCollectionUri(parentCollection, name);
+               return createNonCollectionNode(uri);
+       }
+
+       /**
         * Checks if the uri starts with one of the roots. If not, then it adds
         * the base URI of uri as new root.
         * @param uri The Uri to be checked.
@@ -258,6 +306,52 @@
                return collectionNode;
        }
 
+       /**
+        * Creates a new {...@link CollectionNode} in the specified parent 
collection with
+        * the specified name. If in the parent collection already contains a 
collection
+        * with that name, then a <code>NodeAlreadyExistsException</code> is 
thrown.
+        * The newly created collection node will be added to its parent 
collection's
+        * member list at the specified position posInParent. If the specified 
uri
+        * does not start with an existing root uri, then the base URI 
('http://[host]/')
+        * of uri is added as root.
+        *
+        * @param parentCollection the uri of the parent collection.
+        * @param name the name of the collection
+        * @param posInParent the position of the collection in the members 
list of
+        *              its parent collection.
+        * @throws NodeAlreadyExistsException Thrown if the specified node 
already
+        *              exists.
+        * @throws IllegalArgumentException Thrown if uri ends not with a '/'
+        * @return the created collection node.
+        */
+       public HierarchyNode createCollectionNode(UriRef parentCollection, 
String name, int posInParent)
+                       throws NodeAlreadyExistsException {
+               UriRef uri = createCollectionUri(parentCollection, name);
+               return createCollectionNode(uri, posInParent);
+       }
+
+       /**
+        * Creates a new {...@link CollectionNode} in the specified parent 
collection with
+        * the specified name. If in the parent collection already contains a 
collection
+        * with that name, then a <code>NodeAlreadyExistsException</code> is 
thrown.
+        * The newly created collection node will be added at the end of its 
parent
+        * collection's member list. If the specified uri does not start with an
+        * existing root uri, then the base URI ('http://[host]/') of uri is 
added
+        * as root.
+        *
+        * @param parentCollection the uri of the parent collection.
+        * @param name the name of the collection
+        * @throws NodeAlreadyExistsException Thrown if the specified node 
already
+        *              exists.
+        * @throws IllegalArgumentException Thrown if uri ends not with a '/'
+        * @return the created collection node.
+        */
+       public HierarchyNode createCollectionNode(UriRef parentCollection, 
String name)
+                       throws NodeAlreadyExistsException {
+               UriRef uri = createCollectionUri(parentCollection, name);
+               return createCollectionNode(uri);
+       }
+
        private void addCollectionTypeTriple(UriRef uri) {
                Triple collectionTypeTriple = new TripleImpl(uri, RDF.type,
                                HIERARCHY.Collection);
@@ -268,7 +362,7 @@
         * Creates a new CollectionNode at the specified uri. If at the 
specified
         * uri a collection node already exists, then a
         * <code>NodeAlreadyExistsException</code> is thrown. The newly
-        * created collection node will be added at the end of its parent 
collections
+        * created collection node will be added at the end of its parent 
collection's
         * member list.
         *
         * @param uri the uri where the collection should be created.
@@ -315,7 +409,7 @@
 
                        NonLiteral agent = null;
                        if(agents.hasNext()) {
-                               agent = (NonLiteral) agents.next();
+                               agent = (NonLiteral) agents.next().getSubject();
                        } else {
                                agent = (NonLiteral) agentNode.getNode();
                        }
@@ -336,4 +430,24 @@
                node.deleteProperties(FOAF.maker);
                node.deleteProperties(DCTERMS.created);
        }
+
+       /**
+        * Creates a uri that ends with a slash ('/').
+        * @param parrentCollectionUri the URI of the parent collection
+        * @param name the name of the collection
+        * @return
+        */
+       UriRef createCollectionUri(UriRef parrentCollectionUri, String name) {
+               return new UriRef(
+                               createNonCollectionUri(parrentCollectionUri, 
name).getUnicodeString() + "/");
+       }
+
+       UriRef createNonCollectionUri(UriRef parentCollectionUri, String name) {
+               try {
+                       return new 
UriRef(parentCollectionUri.getUnicodeString() +
+                                       URLEncoder.encode(name, "UTF-8"));
+               } catch (UnsupportedEncodingException ex) {
+                       throw new RuntimeException(ex);
+               }
+       }
 }

Modified: 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/test/java/org/apache/clerezza/platform/content/hierarchy/HierarchyTest.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/test/java/org/apache/clerezza/platform/content/hierarchy/HierarchyTest.java?rev=911013&r1=911012&r2=911013&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/test/java/org/apache/clerezza/platform/content/hierarchy/HierarchyTest.java
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-113/org.apache.clerezza.platform.content/src/test/java/org/apache/clerezza/platform/content/hierarchy/HierarchyTest.java
 Wed Feb 17 15:16:35 2010
@@ -49,6 +49,8 @@
        private UriRef fooResource = new 
UriRef("http://localhost:8282/foo/resource";);
        private UriRef fooResource2 = new 
UriRef("http://localhost:8282/foo/resource2";);
        private UriRef fooResource3 = new 
UriRef("http://localhost:8282/foo/resource3";);
+        private UriRef fooTest = new UriRef("http://localhost:8282/foo/test/";);
+        private UriRef fooTestResource4 = new 
UriRef("http://localhost:8282/foo/test/resource4";);
        private UriRef fooFolder1 = new 
UriRef("http://localhost:8282/foo/folder1/";);   
        private UriRef bar = new UriRef("http://localhost:8282/bar/";);
        private UriRef barResource = new 
UriRef("http://localhost:8282/bar/resource";);
@@ -58,6 +60,7 @@
        private UriRef newRootTest = new UriRef("http://newRoot/test/";);
        private UriRef newRoot2Resource = new 
UriRef("http://newRoot2/resource";);
        private UriRef newRoot2 = new UriRef("http://newRoot2/";);
+        
 
        @Test
        public void listPositionTest() throws Exception{
@@ -98,7 +101,7 @@
                exceptionThrown = false;
                try {
                        fooFolder1Node = (CollectionNode) 
hierarchyService.getHierarchyNode(fooFolder1);
-               } catch(RuntimeException e) {
+               } catch(NodeDoesNotExistException e) {
                        exceptionThrown = true;
                }
                Assert.assertTrue(exceptionThrown);
@@ -112,6 +115,17 @@
                Assert.assertTrue(exceptionThrown);
        }
 
+        @Test
+       public void nonCollectionNodeCreation() throws Exception{
+               HierarchyService hierarchyService = getHierarchyService();
+               HierarchyNode fooTestResource4Node = hierarchyService.
+                        createNonCollectionNode(fooTestResource4, 0);
+                CollectionNode fooTestNode = fooTestResource4Node.getParent();
+                Assert.assertEquals(fooTest, fooTestNode.getNode());
+                CollectionNode fooNode = fooTestNode.getParent();
+                Assert.assertEquals(foo, fooNode.getNode());
+       }
+
        @Test
        public void nonCollectionMoveTest() throws Exception{
                HierarchyService hierarchyService = getHierarchyService();      
        


Reply via email to