users@jersey.java.net

[Jersey] URI extension mapping - how to get the extension?

From: Piotr Hołubowicz <piotrhol_at_man.poznan.pl>
Date: Mon, 26 Mar 2012 14:57:09 +0200

Hi!

I'm using Jersey 1.11 and I have a configured URI extension mapping. So,
in my case I get:
- foo/bar instead of foo/bar.rdf
- foo/bar instead of foo/bar.ttl

My problem is that the extension is important to me because in some
cases I need to save the file exactly as it arrived. And I have not
found any easy method to get the request URI or part of it, with the
extension.

For GET or PUT requests it's less of a problem because I'm using
multiple methods with @Produces and @Consumes anyway, so I can usually
use the default extension for a given file format. However, I feel it's
a bad smell to use either of these for DELETE. Is there a better
solution?

An example:
PUT foo/bar.rdf, Content-Type: application/rdf+xml - I have a method with @Consumes("application/rdf+xml")
and I manually append .rdf to request URI foo/bar.

GET foo/bar.rdf, no Accept header - I have a method with @Produces("application/rdf+xml")
and I manually append .rdf to request URI foo/bar.

DELETE foo/bar.rdf - I get a request URI foo/bar - but how do I get the
extension? Send a Content-Type header and use @Consumes?

thanks for any advice,

cheers,
Piotr

-- 
Piotr Hołubowicz <piotrhol_at_man.poznan.pl>