clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r923363 - in /incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src: main/java/org/apache/clerezza/platform/content/hierarchy/ test/java/org/apache/clerezza/platform/content/hierarchy/
Date Mon, 15 Mar 2010 17:53:47 GMT
Author: mir
Date: Mon Mar 15 17:53:47 2010
New Revision: 923363

URL: http://svn.apache.org/viewvc?rev=923363&view=rev
Log:
CLEREZZA-121: encoding now only in HierarchyManager

Modified:
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/CollectionNode.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyManager.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyNode.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyService.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/test/java/org/apache/clerezza/platform/content/hierarchy/HierarchyTest.java

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/CollectionNode.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/CollectionNode.java?rev=923363&r1=923362&r2=923363&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/CollectionNode.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/CollectionNode.java
Mon Mar 15 17:53:47 2010
@@ -30,7 +30,6 @@ import org.apache.clerezza.rdf.core.UriR
 import org.apache.clerezza.rdf.ontologies.HIERARCHY;
 import org.apache.clerezza.rdf.ontologies.RDF;
 import org.apache.clerezza.rdf.utils.RdfList;
-import org.apache.clerezza.utils.UriException;
 
 /**
  * This class represents a collection in a hierarchy. A collection can have
@@ -43,7 +42,7 @@ public class CollectionNode extends Hier
 	private HierarchyService hierarchyService;
 
 	CollectionNode(UriRef collectionNode, TripleCollection graph,
-			HierarchyService hierarchyService) throws UriException {
+			HierarchyService hierarchyService) {
 		super(collectionNode, graph, hierarchyService);
 		this.hierarchyService = hierarchyService;
 	}
@@ -122,11 +121,7 @@ public class CollectionNode extends Hier
 		HierarchyUtils.ensureCollectionUri(newUri);
 		super.replaceWith(newUri);
 		CollectionNode movedNode;
-		try {
-			movedNode = new CollectionNode(newUri, getGraph(), hierarchyService);
-		} catch (UriException ex) {
-			throw new IllegalArgumentException(ex);
-		}
+		movedNode = new CollectionNode(newUri, getGraph(), hierarchyService);
 		movedNode.updateMembers();
 		return movedNode;
 	}
@@ -150,23 +145,19 @@ public class CollectionNode extends Hier
 	}
 
 	private void updateMember(UriRef memberUri) {
-		try {
-			CollectionNode memberCollection = new CollectionNode(memberUri,
+		CollectionNode memberCollection = new CollectionNode(memberUri,
+				getGraph(), hierarchyService);
+		if (memberCollection.isValid()) {
+			UriRef newUri = new UriRef(getNode().getUnicodeString()
+					+ memberCollection.getName() + "/");
+			memberCollection.replaceWith(newUri);
+			memberCollection.updateMembers();
+		} else {
+			HierarchyNode memberResource = new HierarchyNode(memberUri,
 					getGraph(), hierarchyService);
-			if (memberCollection.isValid()) {
-				UriRef newUri = new UriRef(getNode().getUnicodeString()
-						+ memberCollection.getName() + "/");
-				memberCollection.replaceWith(newUri);
-				memberCollection.updateMembers();
-			} else {
-				HierarchyNode memberResource = new HierarchyNode(memberUri,
-						getGraph(), hierarchyService);
-				UriRef newUri = new UriRef(getNode().getUnicodeString()
-						+ memberResource.getName());
-				memberResource.replaceWith(newUri);
-			}
-		} catch (UriException e) {
-			throw new IllegalArgumentException(e);
+			UriRef newUri = new UriRef(getNode().getUnicodeString()
+					+ memberResource.getName());
+			memberResource.replaceWith(newUri);
 		}
 	}
 
@@ -195,5 +186,4 @@ public class CollectionNode extends Hier
 				collection.getNode().getUnicodeString());
 				
 	}
-
 }

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyManager.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyManager.java?rev=923363&r1=923362&r2=923363&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyManager.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyManager.java
Mon Mar 15 17:53:47 2010
@@ -45,6 +45,9 @@ import org.apache.clerezza.rdf.core.impl
 import org.apache.clerezza.rdf.ontologies.HIERARCHY;
 import org.apache.clerezza.rdf.ontologies.RDF;
 import org.apache.clerezza.rdf.ontologies.RDFS;
+import org.apache.clerezza.rdf.utils.EncodedUriRef;
+import org.apache.clerezza.utils.UriException;
+import org.apache.clerezza.utils.UriUtil;
 
 
 /**
@@ -70,7 +73,8 @@ public class HierarchyManager {
 	 * Creates a new resource as a member of the specified parent collection.
 	 * It will be on the specified position in the members list of the parent,
 	 * if no position is specified, then it is appended to the end of the list.
-	 * The new resource will have the specified name.
+	 * The new resource will have the specified name. The specified URI and
+	 * the name will be encoded according RFC 1738.
 	 * This resource method has the path "createResource"
 	 * 
 	 * @param parentCollectionUri The uri of the parent collection.
@@ -85,13 +89,15 @@ public class HierarchyManager {
 			@FormParam(value = "pos") Integer pos,
 			@FormParam(value = "name") String name) {
 		HierarchyNode node = null;
-		try {			
+		try {
+			UriRef encodedParentCollectionUri = new EncodedUriRef(parentCollectionUri);
+			String encodedName = UriUtil.encodeWithinPath(name, "UTF-8");
 			if (pos == null) {
 				node = hierarchyService.
-						createNonCollectionNode(parentCollectionUri, name);
+						createNonCollectionNode(encodedParentCollectionUri, encodedName);
 			} else {
 				node = hierarchyService.
-						createNonCollectionNode(parentCollectionUri, name, pos);
+						createNonCollectionNode(encodedParentCollectionUri, encodedName, pos);
 			}
 		} catch (NodeAlreadyExistsException ex) {
 			return Response.status(Response.Status.CONFLICT).entity(ex.toString()).
@@ -99,6 +105,9 @@ public class HierarchyManager {
 		} catch (IllegalArgumentException e) {
 			return Response.status(Response.Status.BAD_REQUEST).entity(e.toString()).
 					type(MediaType.TEXT_PLAIN_TYPE).build();
+		} catch (UriException ex) {
+			return Response.status(Response.Status.BAD_REQUEST).entity(ex.toString()).
+					type(MediaType.TEXT_PLAIN_TYPE).build();
 		}
 		return Response.created(URI.create(node.getNode().getUnicodeString())).build();
 	}
@@ -107,7 +116,8 @@ public class HierarchyManager {
 	 * Creates a new collection as a member of the specified parent collection.
 	 * It will be on the specified position in the members list of the parent,
 	 * if no position is specified, then it is appended to the end of the list.
-	 * The new collection will have the specified name.
+	 * The new collection will have the specified name. The specified URI and
+	 * the name will be encoded according RFC 1738.
 	 * This resource method has the path "createCollection"
 	 *
 	 * @param parentCollectionUri The uri of the parent collection.
@@ -124,11 +134,12 @@ public class HierarchyManager {
 			@FormParam(value = "name") String name) {
 		CollectionNode node = null;
 		try {
-			
+			UriRef encodedParentCollectionUri = new EncodedUriRef(parentCollectionUri);
+			String encodedName = UriUtil.encodeWithinPath(name, "UTF-8");
 			if (pos == null) {
-				node = hierarchyService.createCollectionNode(parentCollectionUri, name);
+				node = hierarchyService.createCollectionNode(encodedParentCollectionUri, encodedName);
 			} else {
-				node = hierarchyService.createCollectionNode(parentCollectionUri, name, pos);
+				node = hierarchyService.createCollectionNode(encodedParentCollectionUri, encodedName,
pos);
 			}
 		} catch (NodeAlreadyExistsException e) {
 			return Response.status(Response.Status.CONFLICT).entity(e.toString()).
@@ -136,12 +147,16 @@ public class HierarchyManager {
 		} catch (IllegalArgumentException e) {
 			return Response.status(Response.Status.BAD_REQUEST).entity(e.toString()).
 					type(MediaType.TEXT_PLAIN_TYPE).build();
+		} catch (UriException ex) {
+			return Response.status(Response.Status.BAD_REQUEST).entity(ex.toString()).
+					type(MediaType.TEXT_PLAIN_TYPE).build();
 		}
 		return Response.created(URI.create(node.getNode().getUnicodeString())).build();
 	}
 
 	/**
-	 * Deletes the resource/collection of the specified URI.
+	 * Deletes the resource/collection of the specified URI. The specified URI
+	 * will be encoded according RFC 1738.
 	 * This resource method has the path "delete"
 	 *
 	 * @param nodeUri
@@ -154,25 +169,28 @@ public class HierarchyManager {
 	public Response delete(@FormParam(value = "nodeUri") UriRef nodeUri) {
 		HierarchyNode hierarchyNode;
 		try {
-			hierarchyNode = hierarchyService.getHierarchyNode(nodeUri);
+			hierarchyNode = hierarchyService.getHierarchyNode(new EncodedUriRef(nodeUri));
 		} catch (NodeDoesNotExistException ex) {
 			return Response.status(Response.Status.NOT_FOUND).build();
 		} catch (UnknownRootExcetpion ex) {
 			return Response.status(Response.Status.BAD_REQUEST).entity(ex.toString()).
 					type(MediaType.TEXT_PLAIN_TYPE).build();
+		} catch (UriException ex) {
+			return Response.status(Response.Status.BAD_REQUEST).entity(ex.toString()).
+					type(MediaType.TEXT_PLAIN_TYPE).build();
 		}
-
 		hierarchyNode.delete();
 		return Response.noContent().build();		
 	}
 
 	/**
 	 * Moves the node into the specified collection as the member at
-	 * the specified position pos. 
+	 * the specified position pos. The specified URIs and the new
+	 * name will be encoded according RFC 1738.
 	 * This resource method has the path "move"
 	 *
-	 * @param oldPos
-	 * @param newPos
+	 * @param target the node to be moved
+	 * @param newParent the parent into which the node will be moved
 	 * @param newName The new name of the moved node. This parameter is optionally.
 	 * @return if sucessfully moved then a Created (201) HTTP Response is returned.
 	 *		if the specified targetCollection is not a collection then a
@@ -182,45 +200,58 @@ public class HierarchyManager {
 	 */
 	@POST
 	@Path("move")
-	public Response move(@FormParam(value = "nodeUri") UriRef nodeUri,
-			@FormParam(value = "targetCollection") UriRef targetCollection,
+	public Response move(@FormParam(value = "targetUri") UriRef target,
+			@FormParam(value = "newParentUri") UriRef newParent,
 			@FormParam(value = "pos") Integer newPos,
 			@FormParam(value = "newName") String newName) {
-		HierarchyNode hierarchyNode;
-		CollectionNode targetCollectionNode;
+		HierarchyNode targetNode;
+		CollectionNode newParentNode;
 		try {
-			hierarchyNode = hierarchyService.getHierarchyNode(nodeUri);
-			targetCollectionNode = hierarchyService.getCollectionNode(targetCollection);
+			targetNode = hierarchyService.getHierarchyNode(
+					new EncodedUriRef(target));
+			newParentNode = hierarchyService.getCollectionNode(
+					new EncodedUriRef(newParent));
+		} catch (UriException ex) {
+			return Response.status(Response.Status.BAD_REQUEST).entity(ex.toString()).
+					type(MediaType.TEXT_PLAIN_TYPE).build();
 		} catch (NodeDoesNotExistException ex) {
 			return Response.status(Response.Status.NOT_FOUND).build();
 		} catch (IllegalArgumentException e) {
 			return Response.status(Response.Status.CONFLICT).entity(
-					targetCollection.getUnicodeString() + " is not a Collection.").
+					newParent.getUnicodeString() + " is not a Collection.").
 					type(MediaType.TEXT_PLAIN_TYPE).build();
 		} catch (UnknownRootExcetpion ex) {
 			return Response.status(Response.Status.BAD_REQUEST).entity(ex.toString()).
 					type(MediaType.TEXT_PLAIN_TYPE).build();
 		}
 		try {
-			hierarchyNode = hierarchyNode.move(targetCollectionNode, newName, newPos);
+			String encodedNewName = null;
+			if (newName != null) {
+				encodedNewName = UriUtil.encodeWithinPath(newName, "UTF-8");
+			}
+			targetNode = targetNode.move(newParentNode, encodedNewName, newPos);
 		} catch (NodeAlreadyExistsException ex) {
 			return Response.status(Response.Status.CONFLICT).entity(
-					nodeUri.getUnicodeString() + " already exists in " +
+					target.getUnicodeString() + " already exists in " +
 					"collection.").
 					type(MediaType.TEXT_PLAIN_TYPE).build();
 		} catch (IllegalMoveException ex) {
 			return Response.status(Response.Status.CONFLICT).entity(ex.getMessage()).
 					type(MediaType.TEXT_PLAIN_TYPE).build();
+		} catch (UriException ex) {
+			return Response.status(Response.Status.BAD_REQUEST).entity(ex.toString()).
+					type(MediaType.TEXT_PLAIN_TYPE).build();
 		}
 		return Response.created(
-				URI.create(hierarchyNode.getNode().getUnicodeString())).build();
+				URI.create(targetNode.getNode().getUnicodeString())).build();
 	}
 	
 	/**
 	 * Renames the specified node to the given name. E.g. if you rename 
 	 * "http://localhost:8080/foo/bar" to "test" the new URI will be 
 	 * "http://localhost:8080/foo/test".
-	 * This resource method has the path "rename".
+	 * This resource method has the path "rename". The specified URI and
+	 * name will be encoded according RFC 1738.
 	 * 
 	 * @param newName The new name of the moved node.
 	 * @return if sucessfully renamed then a Created (201) HTTP Response is returned.
@@ -235,14 +266,13 @@ public class HierarchyManager {
 			HierarchyNode hierarchyNode = hierarchyService.getHierarchyNode(nodeUri);
 			CollectionNode parent = hierarchyNode.getParent();
 			int pos = parent.getMembers().indexOf(hierarchyNode);
-			return move(nodeUri, parent.getNode(), pos, newName);
+			return move(nodeUri, parent.getNode() , pos, newName);
 		} catch (NodeDoesNotExistException ex) {
 			return Response.status(Response.Status.NOT_FOUND).build();
 		} catch (UnknownRootExcetpion ex) {
 			return Response.status(Response.Status.BAD_REQUEST).entity(ex.toString()).
 					type(MediaType.TEXT_PLAIN_TYPE).build();
-		}
-		
+		}		
 	}
 
 	/**
@@ -251,7 +281,8 @@ public class HierarchyManager {
 	 * If the specified hierarchy node is not collection node then a
 	 * WebApplicationException containing a Bad Request (400) HTTP Response is
 	 * thrown. The returned graph is enriched with HIERARCHY:membersNumber for
-	 * the contained collections.
+	 * the contained collections. The specified URI will be encoded according
+	 * RFC 1738.
 	 * This resource method has the path "getCollection"
 	 *
 	 * @param node a collection node
@@ -263,13 +294,16 @@ public class HierarchyManager {
 			@QueryParam(value = "collectionNode") UriRef node) {
 		CollectionNode collectionNode;
 		try {
-			collectionNode = hierarchyService.getCollectionNode(node);
+			collectionNode = hierarchyService.getCollectionNode(new EncodedUriRef(node));
 		} catch (NodeDoesNotExistException ex) {
 			throw new WebApplicationException(
 					Response.status(Response.Status.BAD_REQUEST).build());
 		} catch (UnknownRootExcetpion ex) {
 			throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST)
 					.entity(ex.toString()).type(MediaType.TEXT_PLAIN_TYPE).build());
+		} catch (UriException ex) {
+			throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).
+					entity(ex.toString()).type(MediaType.TEXT_PLAIN_TYPE).build());
 		}
 		MGraph result = new SimpleMGraph();
 		result.addAll(collectionNode.getNodeContext());

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyNode.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyNode.java?rev=923363&r1=923362&r2=923363&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyNode.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyNode.java
Mon Mar 15 17:53:47 2010
@@ -23,7 +23,6 @@ import org.apache.clerezza.rdf.core.NonL
 import org.apache.clerezza.rdf.core.Resource;
 import org.apache.clerezza.rdf.core.TripleCollection;
 import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.utils.EncodedUriRef;
 import org.apache.clerezza.rdf.utils.GraphNode;
 import org.apache.clerezza.utils.UriException;
 import org.apache.clerezza.utils.UriUtil;
@@ -39,8 +38,8 @@ public class HierarchyNode extends Graph
 	private HierarchyService hierarchyService;
 
 	HierarchyNode(UriRef hierarchyNode, TripleCollection graph,
-			HierarchyService hierarchyService) throws UriException {
-		super(new EncodedUriRef(hierarchyNode), graph);
+			HierarchyService hierarchyService) {
+		super(hierarchyNode, graph);
 		this.hierarchyService = hierarchyService;
 	}
 
@@ -103,7 +102,7 @@ public class HierarchyNode extends Graph
 	 * Moves this node into the specified parent collection at the specified
 	 * position pos. Optionally you can specifiy a new name.
 	 *
-	 * @param newParentCollection the collection into which this node should be moved
+	 * @param newParent the collection into which this node should be moved
 	 * @param newName the new name of the moved node. Can be null.
 	 * @param pos the member position of the moved node in the members list of
 	 * the new parent collection.
@@ -112,7 +111,7 @@ public class HierarchyNode extends Graph
 	 * @throws IllegalMoveException is thrown if the move operation is not allowed
 	 * @return the HierarchyNode at the new location
 	 */
-	public HierarchyNode move(CollectionNode newParentCollection, String newName, int pos)
+	public HierarchyNode move(CollectionNode newParent, String newName, int pos)
 			throws NodeAlreadyExistsException, IllegalMoveException {
 		String name;
 		try {
@@ -120,9 +119,9 @@ public class HierarchyNode extends Graph
 		} catch (UriException ex) {
 			throw new RuntimeException(ex);
 		}
-		if (newParentCollection.equals(getParent())) {
+		if (newParent.equals(getParent())) {
 			UriRef nodeUri = getNode();
-			List<Resource> membersRdfList = newParentCollection.getMembersRdf();
+			List<Resource> membersRdfList = newParent.getMembersRdf();
 			int oldPos = membersRdfList.indexOf(nodeUri);			
 			if (oldPos < pos) {
 				pos -= 1;
@@ -135,7 +134,7 @@ public class HierarchyNode extends Graph
 				return this;
 			}
 		}		
-		String newUriString = newParentCollection.getNode().getUnicodeString() +
+		String newUriString = newParent.getNode().getUnicodeString() +
 				name;
 		String alternativeUriString = newUriString;
 		if (this instanceof CollectionNode) {
@@ -145,7 +144,7 @@ public class HierarchyNode extends Graph
 		}
 		UriRef newUri = new UriRef(newUriString);
 		UriRef alternativeUri = new UriRef(alternativeUriString);
-		List<Resource> parentMembers = newParentCollection.getMembersRdf();
+		List<Resource> parentMembers = newParent.getMembersRdf();
 		if (parentMembers.contains(newUri) || parentMembers.contains(alternativeUri)) {
 			HierarchyNode existingNode = null;
 			try {
@@ -166,7 +165,7 @@ public class HierarchyNode extends Graph
 		deleteFromParent();
 
 		HierarchyNode movedNode = replaceWith(newUri);
-		newParentCollection.addMember(movedNode, pos);
+		newParent.addMember(movedNode, pos);
 		return movedNode;
 	}
 
@@ -192,11 +191,7 @@ public class HierarchyNode extends Graph
 		}
 		UriRef newUri = (UriRef) replacement;
 		super.replaceWith(newUri);
-		try {
-			return new HierarchyNode(newUri, getGraph(), hierarchyService);
-		} catch (UriException ex) {
-			throw new IllegalArgumentException(ex);
-		}
+		return new HierarchyNode(newUri, getGraph(), hierarchyService);
 	}
 
 	/**

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyService.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyService.java?rev=923363&r1=923362&r2=923363&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyService.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/hierarchy/HierarchyService.java
Mon Mar 15 17:53:47 2010
@@ -49,7 +49,6 @@ import org.apache.clerezza.rdf.ontologie
 import org.apache.clerezza.rdf.ontologies.PLATFORM;
 import org.apache.clerezza.rdf.ontologies.RDF;
 import org.apache.clerezza.rdf.utils.GraphNode;
-import org.apache.clerezza.utils.UriException;
 
 /**
  * The hierarchy service is an OSGi service that provides methods for managing
@@ -97,19 +96,14 @@ public class HierarchyService {
 			throw new UnknownRootExcetpion(extractBaseUri(uri));
 		}
 		HierarchyNode hierarchyNode;
-		try {
-			CollectionNode collectionNode =
-					new CollectionNode(uri, cgProvider.getContentGraph(), this);
-			if (collectionNode.isValid()) {
-				hierarchyNode = collectionNode;
-			} else {
-				hierarchyNode = new HierarchyNode(uri, cgProvider.getContentGraph(), this);
-			}
-
-		} catch (UriException ex) {
-			throw new IllegalArgumentException(ex);
+		CollectionNode collectionNode =
+				new CollectionNode(uri, cgProvider.getContentGraph(), this);
+		if (collectionNode.isValid()) {
+			hierarchyNode = collectionNode;
+		} else {
+			hierarchyNode = new HierarchyNode(uri, cgProvider.getContentGraph(), this);
 		}
-		checkExistence(hierarchyNode);
+	checkExistence(hierarchyNode);
 		return hierarchyNode;
 	}
 
@@ -153,8 +147,6 @@ public class HierarchyService {
 					new CollectionNode(uri, cgProvider.getContentGraph(), this);
 		} catch (IllegalArgumentException ex) {
 			throw new NodeDoesNotExistException(uri);
-		} catch (UriException ex) {
-			throw new IllegalArgumentException(ex);
 		}
 		checkExistence(collectionNode);
 		return collectionNode;
@@ -180,11 +172,7 @@ public class HierarchyService {
 		HierarchyUtils.ensureNonCollectionUri(uri);
 		handleRootOfUri(uri);
 		HierarchyNode hierarchyNode;
-		try {
-			hierarchyNode = new HierarchyNode(uri, cgProvider.getContentGraph(), this);
-		} catch (UriException ex) {
-			throw new IllegalArgumentException(ex);
-		}
+		hierarchyNode = new HierarchyNode(uri, cgProvider.getContentGraph(), this);
 		addToParent(hierarchyNode, posInParent);
 		addCreationProperties(hierarchyNode);
 		return hierarchyNode;
@@ -340,11 +328,7 @@ public class HierarchyService {
 		HierarchyUtils.ensureCollectionUri(uri);
 		handleRootOfUri(uri);
 		CollectionNode collectionNode;
-		try {
-			collectionNode = new CollectionNode(uri, cgProvider.getContentGraph(), this);
-		} catch (UriException ex) {
-			throw new IllegalArgumentException(ex);
-		}
+		collectionNode = new CollectionNode(uri, cgProvider.getContentGraph(), this);
 		addCollectionTypeTriple(collectionNode);
 		addToParent(collectionNode, posInParent);
 		addCreationProperties(collectionNode);
@@ -443,13 +427,9 @@ public class HierarchyService {
 	}
 
 	private void addRoot(UriRef baseUri) {
-		try {
-			CollectionNode node = new CollectionNode(baseUri, cgProvider.getContentGraph(), this);
-			addCollectionTypeTriple(node);
-			roots.add(node);
-		} catch (UriException ex) {
-			throw new IllegalArgumentException(ex);
-		}
+		CollectionNode node = new CollectionNode(baseUri, cgProvider.getContentGraph(), this);
+		addCollectionTypeTriple(node);
+		roots.add(node);
 	}
 
 	protected void deactivate(ComponentContext componentContext) {

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/test/java/org/apache/clerezza/platform/content/hierarchy/HierarchyTest.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/test/java/org/apache/clerezza/platform/content/hierarchy/HierarchyTest.java?rev=923363&r1=923362&r2=923363&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/test/java/org/apache/clerezza/platform/content/hierarchy/HierarchyTest.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.content/src/test/java/org/apache/clerezza/platform/content/hierarchy/HierarchyTest.java
Mon Mar 15 17:53:47 2010
@@ -61,13 +61,7 @@ public class HierarchyTest{
 	private UriRef newRoot = new UriRef("http://newRoot/");
 	private UriRef newRootTest = new UriRef("http://newRoot/test/");
 	private UriRef newRoot2Resource = new UriRef("http://newRoot2/resource");
-	private UriRef newRoot2 = new UriRef("http://newRoot2/");
-	private UriRef unencodedResource = new UriRef("http://localhost:8282/t +");
-	private UriRef encodedResource = new UriRef("http://localhost:8282/t%20%2B");
-	private UriRef unencodedCollection = new UriRef("http://localhost:8282/t +/");
-	private UriRef encodedCollection = new UriRef("http://localhost:8282/t%20%2B/");
-
-        
+	private UriRef newRoot2 = new UriRef("http://newRoot2/"); 
 
 	@Test
 	public void listPositionTest() throws Exception{
@@ -141,22 +135,6 @@ public class HierarchyTest{
 	}
 
 	@Test
-	public void nonCollectionNodeCreationWithEncodedCharacters() throws Exception{
-		HierarchyService hierarchyService = getHierarchyService();
-		hierarchyService.createNonCollectionNode(unencodedResource, 0);
-        HierarchyNode encodedNode = hierarchyService.getHierarchyNode(unencodedResource);
-		Assert.assertEquals(encodedResource, encodedNode.getNode());
-	}
-
-	@Test
-	public void collectionNodeCreationWithEncodedCharacters() throws Exception{
-		HierarchyService hierarchyService = getHierarchyService();
-		hierarchyService.createCollectionNode(unencodedCollection, 0);
-        CollectionNode encodedNode = hierarchyService.getCollectionNode(unencodedCollection);
-		Assert.assertEquals(encodedCollection, encodedNode.getNode());
-	}
-
-	@Test
 	public void nonCollectionMoveTest() throws Exception{
 		HierarchyService hierarchyService = getHierarchyService();		
 		HierarchyNode resourceNode = hierarchyService.createNonCollectionNode(fooResource);
@@ -201,7 +179,6 @@ public class HierarchyTest{
 		Assert.assertEquals(barFooNode, barList.get(0));
 		List<HierarchyNode> barFooList = barFooNode.getMembers();
 		Assert.assertEquals(1, barFooList.size());
-		System.out.println(barFooList.get(0).toString());
 		HierarchyNode barFooResourceNode = hierarchyService.getHierarchyNode(barFooResource);
 		Assert.assertEquals(barFooResourceNode, barFooList.get(0));
 	}



Mime
View raw message