users@jersey.java.net

Questions about 'templated' content responses and return type (url param)

From: Matthew Camuto <mattcamuto_at_gmail.com>
Date: Thu, 22 Jan 2009 08:51:13 -0800

Hi There -

I am fairly new to jersey and have been loving what I see so far. However I
have a few questions about about current needs at work.

We are developing api's at work and have a few requirements that are
desired. One that is that ever response would essentially be a 'template' if
you will with some common information (think term of service, error codes).
I realize that jersey is very 'pojo' and was not sure if this would be
trivial to implment.

For example we would want all of our api responses to look like something
like this:

<company>
  <tos> TERM OF SERVICE FOR ALL RESPONSES </tos>
  <error codes>
      Here would be error codes like 'param not found'
  <error codes>
 <response>
   ....// concrete data here based on java object type....
 </response>
</company>

So in essence I am looking to capture the response from an endpoint and wrap
the data in my generic xml format. And I would like to centralize the
generic stuff like error handling and have the ability to give the user a
verbose message about the error they can easily consume (i.e. 'start date
should be before end date'...) I am not sure if this would be trivial in
jersey without having a lot of repetition in each of my methods. I am also
supposed to support json,rss,atom so I am trying to keep all the 'plumbing'
to a minimum.. I am not sure if this flies in the face of jax-rs or not?!?!

Also. I did not see this in the docs? Is it possible to specify return type
in thu uri params. i.e. default to xml always but if you had...

//myurl/service?format=atom

have it auto detect the return type.

Thanks in advance.

matt