Hello Antonio,

just to complete Michael's answer.
You seem to define 4 distincts resources (I mean subclass of 
org.restlet.Resource) as follow:
 - MailListResource attached to "mail_list" uri pattern
 - MailResource attached to ...
 - MailAttachmentListResource attached to ...
 - MailAttachmentResource attached to 
"mail_list/{msg_ID}/attachment/{att_id}" uri pattern

Thus, you define 4 routes:
router.attach("mail_list", MailListResource.class);
router.attach(...);
router.attach(...);
router.attach("mail_list/{msg_ID}/attachment/{att_id}", 
MailAttachmentResource.class);

The router is in charge, as said Michael, to match the current URI with 
the best pattern.

best regards,
Thierry Boileau

> Hi Antonio,
>
> By default a router will route requests to the best matching resource.
>  So if two urls overlap, such as /mail_list and /mail_list/{msg_ID}
> then a request for /mail_list/abc will go to the second url as it
> matches more of the requested url than /main_list.
>
> Regards,
> Michael.
>
> On Thu, Dec 18, 2008 at 2:38 AM, antoniojg <[email protected]> wrote:
>   
>> Hello, I'm designing an application that retrieves some email messages from a
>> DB back end.
>> I'd like to use Rest to put and get messages on the db. A component is later
>> responsible of retrieving them from the DB and storing them on a PEC  inboox
>> and for getting mails from the inboox and storing them on the DB. The DB
>> layer is essential for data maintenance since the inboox is constantly
>> cleared.
>> In my application each mail is identified by a msg_id and each mail can have
>> several attachments
>>
>> So I have the following urls :
>>
>> mail_list  : get all the application related emails and post a new message
>>
>> mail_list/{msg_ID} in order to get, update and delete a specific message
>>
>> mail_list/{msg_ID}/attachment to get all the attachments and post a new one
>>
>> mail_list/{msg_ID}/attachment/{att_id}  to get, put and delete a specific
>> attachment
>>
>> and so on.
>>
>> My doubt is related to how to configure the urls in order to manage requests
>> for email specific attachments : mail_list/{msg_ID}/attachment/{att_id}
>>
>> There are two parameters here {msg_ID} and {att_id} . I can attach the
>> resource mail list to the url /mail_list and the engine will be able to
>> manage the parameter msg_ID through the API.
>>
>> However, how can I configure the mappings in order to reach the attachment
>> resource if the url always starts with mail_list/{msg_ID}/attachment......?
>>
>> I' d be greatful isf someone may help me resolving this doubt.
>> Thanks.
>> Antonio.
>>
>>
>>
>>
>>
>> --
>> View this message in context: 
>> http://n2.nabble.com/a-question-about-resolving-urls-for-resources.-tp1668521p1668521.html
>> Sent from the Restlet Discuss mailing list archive at Nabble.com.
>>
>> ------------------------------------------------------
>> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=985841
>>
>>     
>
> ------------------------------------------------------
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=987160
>
>

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

Reply via email to