users@jsr311.java.net

Re: base-uri for MessageBodyReader

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 08 Sep 2008 09:04:51 +0200

Hi Reto,

You can inject a UriInfo instance onto a field of a reader/writer, for
example:

   @Context UriInfo ui;

Paul.

On Sep 8, 2008, at 8:31 AM, Reto Bachmann-Gmür wrote:

> Hello
>
> I was writing a MessageBodyReader accepting RDF/XML and returning an
> RDF-Graph instance when I noticed that my client uses relative URI
> references:
>
>
> PUT /editor/dynamic/page1 HTTP/1.1
> Host: localhost:8282
> Keep-Alive: 300
> Connection: keep-alive
> Content-Type: application/rdf+xml
> Referer: http://localhost:8282/editor/static/disco.xhtml
> Content-Length: 311
>
> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
> <rdf:Description rdf:about="page1">
> <infoBit xmlns="http://discobits.org/ontology#"
> rdf:parseType="Literal">bla bla bla bla </infoBit>
> <rdf:type rdf:resource="http://discobits.org/ontology#XHTMLInfoDiscoBit
> "/>
> </rdf:Description>
> </rdf:RDF>
>
> In the MessageBodyReader I cannot reconstruct the full URI of the
> subject of the two triples in the graph as I cannot access the fist
> line of the http-request.
>
> I think the problem may occur with any formats supporting relative
> URIs, for RDF things are particularly difficult as relative-uris are
> permitted only in the serialization format, a valid RDF-Graph never
> contains relative URI references.
>
> For MessageBodyWriter the situation is similar if the applications
> wants to deliver relative URIs in the serilaized form. The issues
> with writers is however less urgent, as it's usually acceptable to
> deliver absolute URIs.
>
> Should MessageBodyReader have access to a context-URI? Or to the
> full Request instead of just the entity headers?
>
> Reto
>