Author: rwesten
Date: Tue Nov 11 14:05:11 2014
New Revision: 1638109
URL: http://svn.apache.org/r1638109
Log:
implementation for STANBOL-1404: not the Content-Location header can be used to
parse the contentItem ID
Modified:
stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/reader/ContentItemReader.java
Modified:
stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/reader/ContentItemReader.java
URL:
http://svn.apache.org/viewvc/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/reader/ContentItemReader.java?rev=1638109&r1=1638108&r2=1638109&view=diff
==============================================================================
---
stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/reader/ContentItemReader.java
(original)
+++
stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/reader/ContentItemReader.java
Tue Nov 11 14:05:11 2014
@@ -299,6 +299,7 @@ public class ContentItemReader implement
//MultivaluedMap<String,String> params = uriInfo.getPathParameters();
//final String ciUri = params.getFirst("uri");
String ciUri = null; //parse the uri parameter manually from the
request URI
+ String source = null;
if(query != null){
int index = query.indexOf("uri=");
if(index >= 0){
@@ -309,20 +310,25 @@ public class ContentItemReader implement
}
if(index < endIndex){
try {
- ciUri = URLDecoder.decode(query.substring(index,
endIndex), "UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new IllegalStateException(e); //should never happen
- }
+ ciUri = URLDecoder.decode(query.substring(index,
endIndex), "UTF-8");
+ source = "'uri' parameter";
+ } catch (UnsupportedEncodingException e) {
+ throw new IllegalStateException(e); //should never
happen
+ }
}
}
}
+ if(ciUri == null){ //try to get the URI from the Content-Location
header
+ ciUri =
headers.getRequestHeaders().getFirst(HttpHeaders.CONTENT_LOCATION);
+ source = "'Content-Location' header";
+ }
if(ciUri != null){
try { //validate the parsed URI
new URI(ciUri);
} catch (URISyntaxException e) {
throw new WebApplicationException("The parsed ContentItem URI '"
+ ciUri +"' is not a valid URI. Please check the value "
- + "of the 'uri' parameter",Response.Status.BAD_REQUEST);
+ + "of the " + source, Response.Status.BAD_REQUEST);
}
}
return ciUri == null ? null : new UriRef(ciUri);