Hi all,

I have just started playing with Restlet, in hopes of cleaning up the RESTy
interfaces to some of our code here at work, and I have run into a problem
that I wanted some input on.

Queries for specific resources (i.e. /users/admin) currently return an RDF
XML document.  In the RDF document, the URI identifying the resource is
referenced.  Inside the resource are references to child resources, and they
are also identified by URI.  The problem is: at RDF construction, how do I
know the URIs?

When producing the "top" node, this is trivial, because the URI is obviously
that passed in the Request.  It gets more complicated for each of the child
nodes, however.  There, the RDF writer has to have knowledge of what the URI
should be, and has to manually construct the URI.  What is disapointing to
me about this is that this means now that the list of URI -> resource
mappings it maintained in two places: once in whatever sets up routes to the
Router, and once in the bit that produces the RDF representation of my data
model.

Ideally, however, I  would like one registry which:
* sets up the router to attach patterns to their Restlets
* has the list of all the patterns
* can be a reference point for the RDF (or whatever other representation)
builder to go to and say "for something of resource type X, the URI is Y"

I tried to build something up based on Template, but what I really need to
make this happen is for Template to have a method which would produce a
string with variables substituted.

Here's an example of what I mean:

Inside my "RDFTransformationVisitor":

   public Resource accept(Module module) {
       Resource moduleR = rdfModel.createResource(baseURI + "/modules/" +
module.getCode());

       moduleR.addProperty(rdfModel.createProperty(URI, "name"),
module.getName()).
               addProperty(rdfModel.createProperty(URI, "code"),
module.getCode()).
               addProperty(rdfModel.createProperty(URI, "visible"),
module.getVisible().equalsIgnoreCase("Y")).
               addProperty(rdfModel.createProperty(URI, "url"),
module.getAppDeployUrl());

       return moduleR;
   }

Instead of that 'baseURI + ...' bit, I would prefer to have something like:

baseURI + URIRegistry.get(Module.class).getTemplate().substitute("module",
module.getCode())

Additionally, when declaring the routings for my application, I could do:

router.attach( URIRegistry.get(Module.class).getTemplate().getPattern(),
URIRegistry.get(Module.class).getHandler() )

Am I way out in left field, or is this something someone else could use?  It
seems like a pattern other people would be interested in.  However, it
requires modifications to Template, lest I have to write my own parser for
the same format that Template uses.

Ryan

Reply via email to