users@jersey.java.net

[Jersey] Re: DELETE request that deletes a collection of objects

From: Jakub Podlesak <jakub.podlesak_at_oracle.com>
Date: Mon, 07 Nov 2011 10:04:21 +0100

Hi Farrukh,

One approach could be to just add a resource representing the set you
want to delete
(say /sets/{setid}) and then to call the DELETE method on that one. You
have a lot of possibilities
on how to represent the set (XML, JSON, your own format).
A second option would be to pass the set of ids to be removed via query
parameters,
but then you would end up with a dedicated delete resource and an
rpc-like way.
Both approaches give you an opportunity to proceed the deletion in
a transactional way (i.e. delete all or nothing)
Others might have some other ideas.

~Jakub

On 4.11.2011 17:45, Farrukh Najmi wrote:
> Dear Colleagues,
>
> In my REST interface I have a resource method to delete a single
> object like this:
>
> @DELETE
> @Path("/objects/{id}")
> public Response deleteObject(@PathParam("id") String id) {
> ...
> }
>
> I now have a need to delete a set of such objects. Note that there is
> no single resource in my model that represents a collection resource.
>
> What is the best way to handle this? Is there a way to specify
> multiple (1 or more) {id} params in the DELETE request?
>
> Thank you for your help.
>