You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by su...@apache.org on 2012/07/17 10:12:41 UTC

svn commit: r1362397 - in /incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources: SemanticIndexManagerResource.java StoreResource.java

Author: suat
Date: Tue Jul 17 08:12:41 2012
New Revision: 1362397

URL: http://svn.apache.org/viewvc?rev=1362397&view=rev
Log:
Fixes STANBOL-693 and STANBOL-694. Added existence checks for the object(content items, LDPath programs) to be deleted. Adjusted methods while adding the CORS request.

Modified:
    incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java
    incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java

Modified: incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java?rev=1362397&r1=1362396&r2=1362397&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java Tue Jul 17 08:12:41 2012
@@ -19,6 +19,8 @@ package org.apache.stanbol.contenthub.we
 import static javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
 import static org.apache.stanbol.commons.web.base.CorsHelper.addCORSOrigin;
 import static org.apache.stanbol.commons.web.base.CorsHelper.enableCORS;
+import static javax.ws.rs.HttpMethod.DELETE;
+import static javax.ws.rs.HttpMethod.OPTIONS;
 
 import java.util.List;
 
@@ -92,6 +94,14 @@ public class SemanticIndexManagerResourc
     }
 
     @OPTIONS
+    @Path("/program/{name}")
+    public Response handleCorsPreflightDeleteProgram(@Context HttpHeaders headers) {
+        ResponseBuilder res = Response.ok();
+        enableCORS(servletContext, res, headers, DELETE, OPTIONS);
+        return res.build();
+    }
+    
+    @OPTIONS
     @Path("/exists")
     public Response handleCorsPreflightExists(@Context HttpHeaders headers) {
         ResponseBuilder res = Response.ok();
@@ -187,6 +197,9 @@ public class SemanticIndexManagerResourc
     @DELETE
     @Path("/program/{name}")
     public Response deleteProgram(@PathParam(value = "name") String programName, @Context HttpHeaders headers) {
+    	if(!programManager.isManagedProgram(programName)){
+    	    throw new WebApplicationException(404);
+    	}
         programManager.deleteProgram(programName);
         ResponseBuilder rb = Response.ok();
         addCORSOrigin(servletContext, rb, headers);

Modified: incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java?rev=1362397&r1=1362396&r2=1362397&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java Tue Jul 17 08:12:41 2012
@@ -30,6 +30,9 @@ import static org.apache.clerezza.rdf.co
 import static org.apache.clerezza.rdf.core.serializedform.SupportedFormat.X_TURTLE;
 import static org.apache.stanbol.commons.web.base.CorsHelper.addCORSOrigin;
 import static org.apache.stanbol.commons.web.base.CorsHelper.enableCORS;
+import static javax.ws.rs.HttpMethod.DELETE;
+import static javax.ws.rs.HttpMethod.OPTIONS;
+import static javax.ws.rs.HttpMethod.POST;
 
 import java.io.BufferedOutputStream;
 import java.io.ByteArrayOutputStream;
@@ -227,7 +230,7 @@ public class StoreResource extends BaseS
     @Path("/{uri:.+}")
     public Response handleCorsPreflightURI(@Context HttpHeaders headers) {
         ResponseBuilder res = Response.ok();
-        enableCORS(servletContext, res, headers);
+        enableCORS(servletContext, res, headers, POST, DELETE, OPTIONS);
         return res.build();
     }
 
@@ -780,6 +783,10 @@ public class StoreResource extends BaseS
     @Path("/{uri:.+}")
     public Response deleteContentItem(@PathParam(value = "uri") String contentURI,
                                       @Context HttpHeaders headers) throws StoreException {
+        ContentItem ci = solrStore.get(contentURI, indexName);
+        if (ci == null) {
+            throw new WebApplicationException(404);
+        }
         solrStore.deleteById(contentURI, indexName);
         ResponseBuilder rb = Response.ok();
         addCORSOrigin(servletContext, rb, headers);