Author: rwesten
Date: Wed Nov 12 07:48:55 2014
New Revision: 1638710

URL: http://svn.apache.org/r1638710
Log:
implementation of STANBOL-1404 for 0.12.1

Modified:
    
stanbol/branches/release-0.12/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/reader/ContentItemReader.java

Modified: 
stanbol/branches/release-0.12/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/reader/ContentItemReader.java
URL: 
http://svn.apache.org/viewvc/stanbol/branches/release-0.12/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/reader/ContentItemReader.java?rev=1638710&r1=1638709&r2=1638710&view=diff
==============================================================================
--- 
stanbol/branches/release-0.12/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/reader/ContentItemReader.java
 (original)
+++ 
stanbol/branches/release-0.12/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/reader/ContentItemReader.java
 Wed Nov 12 07:48:55 2014
@@ -26,6 +26,8 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
+import java.net.URI;
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -293,7 +295,25 @@ public class ContentItemReader implement
      */
     private UriRef getContentItemId() {
         //NOTE: check for request NULL is needed because of unit tests
-        String ciUri = request == null ? null : request.getParameter("uri");
+        if(request == null){
+            return null;
+        }
+        String ciUri = request.getParameter("uri");
+        String source = "'uri' parameter";
+        if(ciUri == null){ //try to get the URI from the Content-Location 
header
+            ciUri = request.getHeader(HttpHeaders.CONTENT_LOCATION);
+            source = "'Content-Location' header";
+        }
+        if(ciUri != null){
+            try { //validate the parsed URI
+                new URI(ciUri);
+            } catch (URISyntaxException e) {
+               throw new WebApplicationException(new IllegalArgumentException(
+                   "The parsed ContentItem URI '" + ciUri + 
+                   "' is not a valid URI. Please check the value of the " + 
+                           source, e), Response.Status.BAD_REQUEST);
+            }
+        } 
         return ciUri == null ? null : new UriRef(ciUri);
     }
     /**


Reply via email to