December 2, 2009
Linked Data and Cool URI Patterns
MVC scaffolding frameworks like Grails and Ruby on Rails prove that the identity and behavior of Web resources can easily be generalized when they are based on a domain model. What Grails and presumably most other frameworks fail to account for is the fact that things named in a domain model identify real world objects. It is time to correct this oversight.
Recall that the primary things named in a domain model fall into a handful of categories: class, instance, attribute, relationship, operation, and the model itself. The Grails scaffold automatically provides HTTP URIs for Web document representations for some of these things. Here are examples using the default Grails URI mapping:
- Model Web Document
- http://example.org/
- Class Web Document
- http://example.org/{className}/{operationName}
- Instance Web Document
- http://example.org/{className}/{operationName}/{instanceName}
[Beware that Grails names these path segment tokens based on analogous MVC concepts:
{className}={controller}
{instanceName}={id}
{operationName}={action}
Also beware that the default Grails URI patterns are deficient in other ways, but it is difficult to change them. As a result, the URI patterns below are reluctantly forced into the default mold.]
The first enhancement for Linked Data compliance is real world object identifiers support for everything in the model. For some domain model categories 303 (See Other) redirect behavior is appropriate:
- Real World Model
- http://example.org/{modelName}/rwo
- Real World Class
- http://example.org/{className}/rwo
- Real World Instance
- http://example.org/{className}/rwo/{instanceName}
These can be implemented by creating a special controller for the {modelName} and adding a new content-negotiable "rwo" action to it and the default scaffold controller. Real world object URIs for attributes and relationships can then piggy-back on Real World Class as hash URIs:
- Real World Attribute
- http://example.org/{className}/rwo#{attributeName}
- Real World Relationship
- http://example.org/{className}/rwo#{relationshipName}
Now that real world object identifiers are defined for everything in the domain model, the only thing lacking is an RDF representation alongside the scaffold's HTML representation. This will be examined in a subsequent post.
0 comments so far