users@jersey.java.net

[Jersey] Re: Migrating RPC to REST

From: Imran M Yousuf <imyousuf_at_smartitengineering.com>
Date: Thu, 14 Apr 2011 13:41:53 +0600

Hi Markus,

>
> Also the question is: How will one know about the URI of the created
> invoice, as it is not sent back (sending it back as a Location header in the
> POST would be invalid http, see RFC).
>

I am not sure to which RFC you were referring to but if a POST returns
201, IOW creates a resource its perfectly RFC compliant and RESTful.
Please have a look at -
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30

If the invoice in your example is created when order is confirmed,
then POST to /order/123/confirmation could point to the /invoices/123
resource. The only step I would add one GET in the above sequence of
request to discover the confirmation resource.

1 > POST /orders
1 < 201
1 < Location: /orders/123

2 > GET /orders/123
2 < 200
2 < Some media exposes /orders/123/confirmation

3 > POST /orders/123/confirmation
3 > application/www-url-encoded confirm=yes&confirmationTime=DATETIME
3 < 201
3 < Location: /invoices/123

Please do excuse me if I have mistaken in understanding any point of yours :).

Now coming to your original post - INSERT INTO TABLE SELECT * FROM....
I could map it to the above example as INSERT INTO invoice SELECT FROM
order where order id = 123
In HATEOAS, AFAIK, it would not be a violation if server parses any
URI. I would map it as

0 > GET /
0 < /orders, /invoices

1 > POST /orders
1 < 201 /orders/123

2 > POST /invoices
2 > order=/orders/123
2 < 201 /invoices/111

Thank you,

-- 
Imran M Yousuf
Entrepreneur & CEO
Smart IT Engineering Ltd.
25/5B, Block F, Haji Chinu Miah Road Bylane
Joint Quarter, Mohammadpur
Dhaka - 1207, Bangladesh
Email: imran_at_smartitengineering.com
Twitter: @imyousuf - http://twitter.com/imyousuf
Blog: http://imyousuf-tech.blogs.smartitengineering.com/
Mobile: +880-1711402557