Farrukh Najmi wrote:
> Paul Sandoz wrote:
>> Hi Farrukh,
>>
>> Could you provide some example URI or URI templates? as that would
>> help me understand better ways to model things.
>
> Here are some samples:
>
> * Get content of root folder of registry: /
> * Get an object in the root folder using its canonical path: /images
> * Get a leaf object in the folder containment using its canonical
> path: /images/summerVacation/2007/wellfleet/NewcombsHollowBeach.png
>
> Above should seem fairly obvious and simple I hope.
>
Yes.
>
>>
>> Below is a general approach to browsing directories or files:
>>
>> For example:
>>
>> public class FileBrowser {
>> private String path;
>>
>> public FileBrowser(String path) { this.path = path }
>>
>> @GET public File getFile() {
>> String absolutePath = getAbsolutePath(path);
>> return new File(absolutePath);
>> }
>> }
>>
>>
>> @Path("/")
>> public class MyResource() {
>> @Path(value="browse/{path}", limited=false)
>> public FileBrowser fileBrowser(@UriParam("path") String path) {
>> return new FileBrowser(path);
>> }
>> }
>>
>> So GET request to /browse/a/b/c/d will create a FileBrowser to serve
>> state for "a/b/c/d". The limited=false means that all the URI path is
>> consumed, if you set it to true then only a path segment is consumed.
>
> In my case I do not really have files and folders. The Registry uses
> that familiar metaphor but what it really has are RegistryObjects
> (files) and RegistryPackages (folders) which are stored in a database.
> But your example is helpful.
>
OK.
> There are some additional complexities. I need to support option to
> return response in specified formats etc.
>
That can be is easy :-) depending on how you want to do it and how
dynamic it is. You can have multiple GET methods that produce different
media types using @ProduceMime. However, i recommend getting the URI
modeling right first before diving into this aspect.
> I am thinking of modelling all this with a RegistryObjectResource and a
> RegistryPackageResource which extends RegistryObjectResource.
>
OK.
> Thanks again for getting me started and for being a very responsive team.
>
No problem.
Paul.
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109