Hello,

I'm trying to perform operations on a resource in a way that affects 
other resources in the same system (because they depend partly on the 
same domain objects).

For example, in the tutorial 
<http://www.restlet.org/documentation/1.1/tutorial#part12>, UserResource 
and OrderResource both depend on the User domain object.

I'd like, in the messages I sent to the resources to be able to refer to 
other resources, using a URI (usually relative, but perhaps absolute).

For example, if the structure of the URI is flat:
   /user/{USER_ID}    -> UserResource   -> User (table where USER_ID is 
the primary key)
   /order/{ORDER_ID}  -> OrderResource  -> User (table where ORDER_ID is 
the primary key, USER_ID being another column)

and if the default representation for an OrderResource looks like this:
   <order>
     <user>/user/123</user>
     ...
   </order>

I'd like to be able to change the user on that order by giving another 
URI, say:
   <order>
     <user>../user/456</user>
     ...
   </order>

or with the equivalent absolute URI:
   <order>
     <user>http://host.example/user/456</user>
     ...
   </order>

The way the example in the tutorial works around this is by having the 
orders depend on the user in the template 
("/user/{USER_ID}/order/{ORDER_ID}"), so that the OrderResource can know 
both the USER_ID and the ORDER_ID.

Since I'm using a "flat" URI structure, I can't really do this. (What 
I'm trying to do is to have some parent/child relationship between 
resources, without constraints on the depth of the tree, in such a way 
that telling a resource X its parent is Y would also set the domain 
object of Y to be a child of X, and vice-versa. I'm also assuming that 
both within the scope the same system to avoid distributed updates.)


One way to do this would be to make another Request to the enclosing 
Application, via 'handle'. However, going through the external interface 
(GET/PUT/POST/DELETE/...) when it's an internal operation (in 
particular, because I'd like to bypass the Guards/Filters and because I 
want to avoid infinite loops). I'd be looking for a way to get the 
instance of the Resource that would be at the given URI (so that I can 
get its domain object) without the call to be actually made.


Is there a way to do this? Has anyone had similar problems and other 
solutions?


Best wishes,

Bruno.

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

Reply via email to