users@jersey.java.net

Re: [Jersey] Creating multiple resources

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 19 Apr 2010 12:09:02 +0200

On Apr 16, 2010, at 6:50 PM, Chris Carrier wrote:

> Hey guys I have what should be a simple question but I haven't been
> able to confirm it anywhere. I have a POST end point that will bulk
> create records based on a JSON list getting passed in. So in my
> normal POST responses I put the URI in the location header. If I
> create multiple resources is the convention to just pass the URI's
> back as multiple location headers? That seems right but I can't find
> any mention of it anywhere. And if that is correct what's the best
> way to do the in Jersey? Something like:
>
> Response.status(Status.created).location(URI1).location(URI2) ?
>

What do you send as a response entity for the creation of multiple
resources?

http://greenbytes.de/tech/webdav/rfc2616.html#status.201

A 201 created response is associated with one created resource whose
URI is declared in the Location header, that does not mean other
resources cannot be created too, but to reference those i think would
require that the URIs be in the entity body.

The Location header could refer to the first created resource. The
media type of the response could describe the entity that contains
links to all the created resources.

IIRC WebDav has the concept of a multi-response and may better fit
your needs.

Paul.