[OTDev] Creation of a new feature - Tomcat

Nina Jeliazkova nina at acad.bg
Fri Dec 25 13:51:57 CET 2009


Hi Pantelis,

Your RDF is fine, and in fact the feature is created successfully (and
was also accessible under 
http://ambit.uni-plovdiv.bg:8080/ambit2/feature/13149 ).

The problem turns out to be a Tomcat 6 peculiarity when handling URLs ,
containing encoded slashes, like the one below

    http://ambit.uni-plovdiv.bg:8080/ambit2/feature/http%3A%2F%2Fother.com%2Ffeature%2F200Default



Restlet handles these kind of URLs fine, junit tests for this also run
fine , but once the code is deployed under tomcat, it fails to retrieve
the feature under URL above and instead returns "HTTP/1.x 400 Invalid
URI: noSlash". The Tomcat 6 behaviour for handling URLs with encoded
slashes is controlled via a Java system property , as described in [1]
and [2].

    * |org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH|:
      |true|false|

Setting the property to "true" fixes the issue you've encountered, but
is considered a security threat (under specific settings).   (The
security threat could also be valid for other servers as well, not only
for Tomcat).

To summarize, now we have set the above setting to true and the problem
should be resolved. But in general we should avoid including encoded
slashes in URLs (I will be changing the code sending feature URLs upon
creation). 

On another note, avoiding slashes in URIs makes impossible using InChIs 
as compound ID as in e.g. /compound/InChI%3D1%2FCH2O%2Fc1-2%2Fh1H2 , so
it would be better if specified as query parameters, e.g. 
http://ambit.uni-plovdiv.bg:8080/ambit2/compound/?search=InChI%3D1%2FCH2O%2Fc1-2%2Fh1H2

[1] http://old.nabble.com/HTTP-1.x-400-Invalid-URI:-noSlash-td15005787.html
[2] http://tomcat.apache.org/security-6.html

Best regards,
Nina

chung wrote:
> Hi Nina,
>  According to the API, one can post an rdf representation of a feature
> to a feature service to have a new Feature created. So I made an
> experiment using the following curl command:
>
> curl -X POST -H 'Content-type:application/rdf+xml' --data-binary
> @/path/to/feature.rdf http://ambit.uni-plovdiv.bg:8080/ambit2/feature
>
> The content of feature RDF is:
>
> <rdf:RDF
>     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
>     xmlns:ot="http://www.opentox.org/api/1.1#"
>     xmlns:owl="http://www.w3.org/2002/07/owl#"
>     xmlns:dc="http://purl.org/dc/elements/1.1/"
>     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
>     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" > 
>   <rdf:Description rdf:about="http://purl.org/dc/elements/1.1/creator">
>     <rdf:type
> rdf:resource="http://www.w3.org/2002/07/owl#AnnotationProperty"/>
>   </rdf:Description>
>   <rdf:Description rdf:nodeID="A0">
>     <owl:sameAs rdf:resource="http://other.com/feature/200"/>
>     <dc:creator
> rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://opentox.ntua.gr</dc:creator>
>     <rdf:type rdf:resource="http://www.opentox.org/api/1.1#Feature"/>
>   </rdf:Description>
>   <rdf:Description rdf:about="http://other.com/feature/200">
>     <rdf:type rdf:resource="http://www.opentox.org/api/1.1#Feature"/>
>   </rdf:Description>
>   <rdf:Description rdf:about="http://www.opentox.org/api/1.1#Feature">
>     <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
>   </rdf:Description>
> </rdf:RDF>
>
> This RDF was generated using the following code:
>
>
>
> OntModel featureModel = OT.createModel();
>         Individual feature =
> featureModel.createIndividual(featureModel.getOntClass(OT.Class.Dataset.getURI()));
>
> feature.addRDFType(OT.Class.Feature.createProperty(featureModel));
>
> feature.addProperty(featureModel.createAnnotationProperty(DC.creator.getURI()), featureModel.createTypedLiteral("http://opentox.ntua.gr"));
>
> feature.setSameAs(featureModel.createResource("http://other.com/feature/200", OT.Class.Feature.getResource()));
>         OT.Class.Feature.createOntClass(featureModel);
>
> *** The operation is successful (the server responds with a status code
> 200-OK), a URI is returned for the generated feature which is
> http://ambit.uni-plovdiv.bg:8080/ambit2/feature/http%3A%2F%2Fother.com%
> 2Ffeature%2F200Default , but the result of the following request: 
>
> curl -v -H 'Accept:application/rdf+xml'
> http://ambit.uni-plovdiv.bg:8080/ambit2/feature/http%3A%2F%2Fother.com%
> 2Ffeature%2F200Default 
>
> returns an empty representation and a status code 400 - Bad Request. 
>
>
>
> Is there a problem with the RDF I posted? Could you provide an example
> of how can one create a new Feature?
>   

> Best Regards,
> Pantelis
>   




More information about the Development mailing list