Marc Hadley wrote:
> You might also find the StorageService example useful though, IIRC, it
> doesn't support an arbitrarily deep hierarchical structure.
>
Correct. It treats the path as a key to look up the appropriate object,
similar to Amazon S3. Essentially the client has control of those
segments of the URI path.
Paul.
> Also look at the limited property of the @Path annotation, that allows
> you to capture multiple path segments with a single template parameter.
>
> @Path(value="items/{item_path}", limited=false)
> public class ItemResource {
>
> // methods to operate on an item
> @GET
> public Item getItem(@PathParam("item_path") String itemPath) {
> ...
> }
> }
>
> A GET request for items/1/2/3/4 will result in a value of "1/2/3/4" for
> the itemPath parameter of the getItem method. You can then split the
> itemPath value, find the appropriate resource and return it.
>
> If you'd rather avoid splitting the path yourself then you can use a
> recursive sub-resource locator approach instead:
>
> @Path("items")
> public class ItemsResource {
>
> @Path("path_segment")
> public ItemResource getItem(@PathParam("path_segment") String childId) {
> ...
> }
> }
>
> public class ItemResource {
>
> @Path("path_segment")
> public ItemResource getChildItem(@PathParam("path_segment") String
> childId) {
> ...
> }
>
> // methods to operate on an item
> @GET ...
> }
>
> The getItem method is called when the request URI path starts with
> "items" but has additional path segments. It returns an object that is
> then used to recursively find the correct ItemResource. getChildItem
> will be called on each returned ItemResource instance until the URI path
> is exhausted at which point the appropriate @GET, @POST etc method of
> the final ItemResource will be called.
>
> Marc.
>
> On Dec 5, 2007, at 9:13 AM, Farrukh Najmi wrote:
>
>>
>> Dear colleagues,
>>
>> I am new to Jersey and like what I see very much and plan to use it in
>> my project's (ebXML RegRep 4.0 implementation) REST interface.
>>
>> My first REST interface needs to allow browsing of the content in the
>> ebXML RegRep using a familiar file/folder hierarchy where the URL path
>> encodes the composition hierarchy structure of the objects in the
>> registry.
>>
>> I see in archives a long thread about resources and sub-resources:
>>
>> <https://jersey.dev.java.net/servlets/BrowseList?list=users&by=thread&from=976123>
>>
>>
>> Being new to Jersey I do not grok it all yet. However, I have found
>> the Bookmarks example and looking at it
>> for inspiration. Are there any closer examples than the Bookmarks one
>> for my use case? Thanks for sharing any samples
>> pointers or advice.
>>
>> --
>> Regards,
>> Farrukh Najmi
>>
>> Web: http://www.wellfleetsoftware.com
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
> ---
> Marc Hadley <marc.hadley at sun.com>
> CTO Office, Sun Microsystems.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109