You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by mi...@apache.org on 2010/02/06 17:12:17 UTC

svn commit: r907245 - in /incubator/clerezza/issues/CLEREZZA-103/org.apache.clerezza.platform.content: ./ src/main/java/org/apache/clerezza/platform/content/

Author: mir
Date: Sat Feb  6 16:12:17 2010
New Revision: 907245

URL: http://svn.apache.org/viewvc?rev=907245&view=rev
Log:
CLEREZZA-103: infodiscobit now added to a collection when created

Added:
    incubator/clerezza/issues/CLEREZZA-103/org.apache.clerezza.platform.content/
      - copied from r907222, incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.content/
Modified:
    incubator/clerezza/issues/CLEREZZA-103/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/AbstractDiscobitsHandler.java
    incubator/clerezza/issues/CLEREZZA-103/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitsTypeHandler.java
    incubator/clerezza/issues/CLEREZZA-103/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/SimpleDiscobitsHandler.java

Modified: incubator/clerezza/issues/CLEREZZA-103/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-103/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/AbstractDiscobitsHandler.java?rev=907245&r1=907222&r2=907245&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-103/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/AbstractDiscobitsHandler.java (original)
+++ incubator/clerezza/issues/CLEREZZA-103/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/AbstractDiscobitsHandler.java Sat Feb  6 16:12:17 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,23 @@
 	 */
 	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 {
+			infoDiscoBitNode = getHierarchyService().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 +121,13 @@
 				return;
 			}			
 		}
-		GraphNode graphNode = new GraphNode(node, mGraph);
+		GraphNode graphNode;
+		try {
+			graphNode = getHierarchyService().getHierarchyNode((UriRef) node);
+			((HierarchyNode) graphNode).delete();
+		} catch (NodeDoesNotExistException ex) {
+			graphNode = new GraphNode(node, mGraph);
+		}
 		graphNode.deleteNodeContext();
 	}
 

Modified: incubator/clerezza/issues/CLEREZZA-103/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-103/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitsTypeHandler.java?rev=907245&r1=907222&r2=907245&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-103/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitsTypeHandler.java (original)
+++ incubator/clerezza/issues/CLEREZZA-103/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/DiscobitsTypeHandler.java Sat Feb  6 16:12:17 2010
@@ -35,6 +35,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;
@@ -79,6 +80,9 @@
 
 	@Reference
 	private ContentGraphProvider cgProvider;
+
+	@Reference
+	private HierarchyService hierarchyService;
 	
 	private static final Logger logger = LoggerFactory.getLogger(DiscobitsTypeHandler.class);
 
@@ -154,4 +158,9 @@
 	protected Set<MetaDataGenerator> getMetaDataGenerators() {
 		return metaDataGenerators;
 	}
+
+	@Override
+	protected HierarchyService getHierarchyService() {
+		return hierarchyService;
+	}
 }

Modified: incubator/clerezza/issues/CLEREZZA-103/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-103/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/SimpleDiscobitsHandler.java?rev=907245&r1=907222&r2=907245&view=diff
==============================================================================
--- incubator/clerezza/issues/CLEREZZA-103/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/SimpleDiscobitsHandler.java (original)
+++ incubator/clerezza/issues/CLEREZZA-103/org.apache.clerezza.platform.content/src/main/java/org/apache/clerezza/platform/content/SimpleDiscobitsHandler.java Sat Feb  6 16:12:17 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;
+	}
+
 }