users@jersey.java.net

Re: [Jersey] RESTful API with optional XML elements/JSON properties

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 09 Mar 2009 17:52:23 +0100

On Mar 7, 2009, at 3:30 AM, Jaka JanĨar wrote:

> On 6. Mar 2009, at 20:52, Marc Hadley wrote:
>> Consider using PATCH or POST instead. PUT is intended to replace
>> the representation at the request URI with the one you supply
>> rather than patching it as a diff. The latest spec for PATCH is here:
>>
>> http://www.ietf.org/internet-drafts/draft-dusseault-http-patch-13.txt
>
> PATCH is a good idea. POST would be wrong, I think, because it's
> meant to create a new resource under the one that's being POSTed to.

The semantics of POST are undefined by HTTP. As a common convention it
is used for creation as you describe, but you can specify your own
semantics for POST.


>
>
> But the problem remains even with PATCH:
>
> How to differentiate between no element and a null element on the
> Java-side of the mapping and how to get JAXB (or anything else) to
> map this correctly.
>

Like Tatu, i am not sure this is possible without being explicit about
what "no element" is i.e. i do not think you can mix nillable and no
element with JAXB. However, you might want to experiment with the
XmlJavaTypeAdapter and see if you can code something up that does what
you require.

Paul.

> Regards,
> Jaka
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>