users@jersey.java.net

RE: [Jersey] best practice for generating unique id in the resources

From: Robertson, Jeff <jeff.robertson_at_digitalinsight.com>
Date: Fri, 31 Oct 2008 16:32:52 -0400

Wouldn't you normally want the client to create a customer by POSTing to
the parent /customers resource?

Request:

         POST /customers HTTP/1.1
         Content-type: xxx
         Content-length: nnn

         ... etc ...


Response:

         HTTP 201 Created
         Location: /customers/1234



-----Original Message-----
From: Arul Dhesiaseelan [mailto:arul_at_fluxcorp.com]
Sent: Friday, October 31, 2008 4:26 PM
To: users_at_jersey.dev.java.net
Subject: [Jersey] best practice for generating unique id in the
resources

Hello,

I have a CustomersResource with sub-resource CustomerResource :

/customers/{id} =>

/customers/1909
/customers/2234
/customers/3454

The client can add customers to the customers resource using POST. But,
it needs to populate the unique id which forms part of the URI as well
as customer ID.

What would be the best method to generate such unique id?

I can think of an ID generator service on the server-side and the client

can first do a GET to get an ID and use this ID in the POST to create a
new customer.

Would this approach cause any issue? Is there a better approach to
implement this behavior?

Appreciate your suggestions.

Thanks!
Arul




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