dev@jsr311.java.net

Re: Platonic URIs

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 25 Sep 2007 13:05:23 +0200

Marc Hadley wrote:
> (iii) We could consider including adding some convention-driven support
> to the UriTemplate annotation. E.g.:
>
> @UriTemplate(value="{id}" extentions=true)
>
> The above could surface a fixed-name URI template variable for any
> supplied extension so that for "foo.xml" you'd get UriParam("id")==foo,
> UriParam("extension")==xml.
>

I am leaning towards this approach.

Say we have these URI templates:

    /collection/
    /collection/{entry}

and we would like to support the following URIs from these templates:

   /collection
   /collection/
   /collection.xml
   /collection/1
   /collection/1/
   /collection/1.xml

I don't think it makes sense to support:

   /collection.xml/1
   /collection.xml/1.xml

The suffices only makes sense on last path segment of the URI.

Off the top of my head this means we have the following regular
expressions (in order of matching precedence):

   /collection/([^/]*).(\w+)(/)?
   /collection/(.*?)(/.*)?
   /collection.(\w+)(/)?
   /collection(/.*)?


It may be useful to also specify such functionality at the level of the
web application such that one does not have to modify code.


We also need to make sure this works correctly when using the
limited=false option. For this template:

   @UriTemplate(value="/collection/{id}", limited=false, extentions=true)

We can have the following regular expressions (in order of precedence):

   /collection/(.*).(\w+)(/)?
   /collection/(.*?)(/)?

which allows us to have the following URIs:

   /collection
   /collection/
   /collection.xml
   /collection.xml/
   /collection/my/path/to/something
   /collection/my/path/to/something/
   /collection/my/path/to/something.xml
   /collection/my/path/to/something.xml/

Is this desirable? Or should we make limited and extentions mutually
exclusive?


In any case i think it should be fairly easy to augment the existing
algorithm with such behaviour be it per-application or per template and
consistently with "limited".

Paul.

> GET /foo.xml
> Accept: */*
>
> is internally treated as if it were:
>
> GET /foo
> Accept: application/xml
>
> If we went this route we'd need to define a set of default mapping rules
> and probably some means to extend or modify the default set.
>
> What do folks think, are (i) and (ii) sufficient or are you interested
> in something along the lines of (iii) ? Perhaps there are other
> approaches we didn't consider ?
>
> Thanks,
> Marc.
>
> [1] http://blogs.sun.com/sandoz/entry/philosphical_content_negotiation
> [2]
> http://blogs.sun.com/sandoz/entry/more_philosophical_content_negotiation
> [3] https://jsr311.dev.java.net/servlets/ReadMsg?list=dev&msgNo=347
>
> ---
> Marc Hadley <marc.hadley at sun.com>
> CTO Office, Sun Microsystems.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: dev-help_at_jsr311.dev.java.net
>

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109