Hello,

what I don't understand is why you want to execute the DELETE request,
can't you just delete the resource data using the data access layer of your
application? Do the resources you want to delete live inside a different
application?

If all resources, the bulkdeleter and the ones to be deleted are inside the
same application, why not just remove them using the lower-level data
access layer?

An example, not production ready, resource handler for the bulkdeleter
would be:

@Post("json")
public JsonRepresentation bulkDelete(JsonRepresentation uris) throws
ResourceException, JSONException, IOException {
  JSONArray auris = new JSONArray(uris.getJsonArray());
  JSONArray deleteResult = new JSONArray();
  for (int i = 0; i < auris.length; i++) {
    T entity = getEntityFromDataLayer(auris[i]);
    boolean deletedOK = entity.delete();
    JSONObject resultJSON = new JSONObject();
    resultJSON.put("uri", auris[i]);
    resultJSON.put("ok", deletedOK);
    deleteResult.add(resultJSON);
  }
  return new JsonRepresentation(deleteResult);
}

There may be some syntax errors on the above (cannot remember all class
names...) but you get the idea. Also, instead of throwing JSONException and
IOException, you may want to surround all the code inside a try catch and
handle exceptions differently.

The key here is getEntityFromDataLayer(uri) as opposed to the DELETE
request you want to perform. This method would then query your data layer,
be it a database, the file system, a JCR repository... and retrieve the
object of type T to be deleted, which is expected to have a method called
delete(), or whatever fits to your data access strategy.

Hope this helps. Good luck.



On Thu, Jul 25, 2013 at 7:30 PM, dbaq <[email protected]> wrote:

> Hi Fabian,
>
> This is almost what I want. Here is what I want :
>
> POST /bulkdeleter
> ["/customer/1", "/customer/22", ...]
>
> From my /bulkdeleter  I want to execute DELETE /customer/1 and get the
> response then I want to execute DELETE /customer/2 and get the response.
> Then I want to return from /bulkdeleter the list of responses formatted in
> JSON (error or not)
>
> How can I do that ?
>



-- 
Fabián Mandelbaum
IS Engineer

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3061380

Reply via email to