users@jersey.java.net

Handling URIs in the body of a message from the server-side

From: Andrew Ochsner <aochsner_at_cs.stanford.edu>
Date: Tue, 29 Sep 2009 17:02:28 -0500

Hi:

This probably more of a conceptual question, and if it's already been
covered, just let me know. I couldn't find anything doing some quick
searches...

I'll just start with an example.. Let's say I'm POSTing an Order (which is
a list of items and quantity). I think the most "RESTful" way of doing this
would be...sure there are other ways but this is just what we're thinking
of...
POST /orders
{ "items" : [{ "item" : "http://server/path/to/item/12", "quantity":2 }, {
"item" : "http://server/path/to/item/21", "quantity":3 }]}

What's the best approach to resolving those URIs? In my case, I own (and
don't forsee not owning) the URI space/Resources for Items as well. And
ultimately I just care about the last part of the path (12 & 21) so I can
look it up in a database....

Ideally I'd like to utilize (in some way...no idea) the Path matching that
already happens when a client does a GET /items/21

The simplest but maybe the most brittle would be to just chop off all of the
path but the last part

Most generic approach would be to just use the Jersey client (or some other
http client) to GET that URI...but not sure it's worth whatever performance
issues that may cause (heck it might not cause any...that'd be cool)...

Is there anything in between?

Thanks in advance
Andy Ochsner