<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>brettdargan.com &#187; RESTful</title>
	<atom:link href="http://brettdargan.com/blog/category/restful/feed/" rel="self" type="application/rss+xml" />
	<link>http://brettdargan.com/blog</link>
	<description>Thoughts and rants</description>
	<lastBuildDate>Fri, 28 May 2010 01:35:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>RIMVR and HATEOAS: MVC+URITemplateAspects, LinkAwareModels and LinkTemplateProcessors</title>
		<link>http://brettdargan.com/blog/2009/04/29/rimvr/</link>
		<comments>http://brettdargan.com/blog/2009/04/29/rimvr/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 12:24:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Patterns]]></category>
		<category><![CDATA[RESTful]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[rest]]></category>

		<guid isPermaLink="false">http://brettdargan.com/blog/?p=337</guid>
		<description><![CDATA[There has been a discussion titled [Jersey] Putting the RESTful "connectedness" around my existing Domain objects on the jersey mailing list that is starting up again.
I don't think I have confused HATEOAS with "connectedness", I have a reasonable understanding of resource state, application state and HATEOAS.
See http://www.stucharlton.com/blog/archives/000141.html and this discussion, http://tech.dir.groups.yahoo.com/group/rest-discuss/message/12497, which I see you [...]]]></description>
			<content:encoded><![CDATA[<p>There has been a discussion titled <a href="https://jersey.dev.java.net/servlets/ReadMsg?list=users&#038;msgNo=5657">[Jersey] Putting the RESTful "connectedness" around my existing Domain objects</a> on the jersey mailing list that is starting up again.</p>
<p>I don't think I have confused HATEOAS with "connectedness", I have a reasonable understanding of resource state, application state and HATEOAS.</p>
<p>See <a href="http://www.stucharlton.com/blog/archives/000141.html">http://www.stucharlton.com/blog/archives/000141.html</a> and this discussion, <a href="http://tech.dir.groups.yahoo.com/group/rest-discuss/message/12497">http://tech.dir.groups.yahoo.com/group/rest-discuss/message/12497</a>, which I see you have contributed to.</p>
<p>I think this final point made by <a href="http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven">Roy</a> is pretty applicable here:</p>
<blockquote><p>
A REST API should be entered with no prior knowledge beyond the initial URI (bookmark) and set of standardized media types that are appropriate for the intended audience (i.e., expected to be understood by any client that might use the API). From that point on, <b>all application state transitions must be driven by client selection of server-provided choices that are present in the received representations or implied by the user’s manipulation of those representations</b>. The transitions may be determined (or limited by) the client’s knowledge of media types and resource communication mechanisms, both of which may be improved on-the-fly (e.g., code-on-demand). [Failure here implies that out-of-band information is driving interaction instead of hypertext.]
</p></blockquote>
<p><b>My point is you can't adhere to the HATEOAS constraint, without providing links between resources</b> so the server can guide the client to other application states.</p>
<p>I agree that forms are a better example for explaining state transitions, especially since resource state is likely to be changed by providing forms (as will the User Agent, as Roy mentions); or equivalent form templates/prototypes for other media types.<br />
But to me providing forms or equivalents for other media types is a different and easier problem to solve.</p>
<p>I'm very interested in <b>how to evolve existing systems</b>; I want to leverage the <b>vast islands of information</b> that already exist. </p>
<p>I just want to do it in an elegant way from a <b>code</b> and a <b>web perspective</b>, including the fact that uri's shouldn't change.<br />
<div id="attachment_338" class="wp-caption alignleft" style="width: 310px"><a href="http://brettdargan.com/blog/wp-content/uploads/2009/04/hateoas_4_legacy.jpg"><img src="http://brettdargan.com/blog/wp-content/uploads/2009/04/hateoas_4_legacy-300x225.jpg" alt="RIMVR: MVC + URITemplateAspects; LinkAwareModels and LinkTemplateProcessor" title="hateoas_4_legacy" width="300" height="225" class="size-medium wp-image-338" /></a><p class="wp-caption-text">URITemplateAspects; LinkAwareModels and LinkTemplateProcessor</p></div></p>
<p>In a standard, layered design, you would have these components (see <a href="http://brettdargan.com/blog/wp-content/uploads/2009/04/hateoas_4_legacy-300x225.jpg">Image</a>):</p>
<p>1. Code-On-Demand<br />
2. View<br />
3. Controller<br />
4-6. Contains the Proposed Abstractions<br />
7. Model<br />
8. Persistent Store - Db; file; jcr; webdav<br />
9. Proxies</p>
<p>Here are some options I have for adding links around some existing system (there are likely more)</p>
<p>Due to the time constraints, the Pros, will be sparse.</p>
<h3>Option 1: Add Links via Code-On-Demand.</h3>
<p>Add links to my html page via javascript.<br />
I could take my existing html representation and use dhtml to add links.</p>
<p>Cons:<br />
* code-on-demand not available for all user agents or may be disabled<br />
* Proxies can't cache the entire representation<br />
* leak of possible application states to clients that don't need to know<br />
* Detailed knowledge of resource and subresources required to provide "link rich" representations<br />
* Alternative media types may require alternative languages or structure to perform add the links. ie. use of xsl for xml; javascript with svg.</p>
<h3>Option 2: Add Links via Views</h3>
<p>Cons:<br />
* We all know this is bad<br />
* Detailed knowledge of resource and subresources required to provide "link rich" representations<br />
* different views/media types require the same logic and detailed knowledge of the model<br />
* different views/media types may require some application state knowledge. an admin user may have other links than anon.</p>
<h3>Option 3: Add Links via Controllers</h3>
<p>Pros:<br />
* Can handle the inclusion/exclusion of links depending on the current application state, regardless of the media type to respond with </p>
<p>Cons:<br />
* Detailed knowledge of resource and subresources required to provide "link rich" representations</p>
<h3>Option 4: Add Links via Models</h3>
<p>Pros:<br />
* Detailed knowledge of the model and related models belong in the Model</p>
<p>Cons:<br />
* Detailed knowledge of resource links aren't the domain of the models<br />
* Not all possible related models are likely to be represented; to balance performance with types of usage, often some relationships are not modelled, so as to not eager load, very large graphs etc.<br />
* Links are very static, The "next available" application state, still needs to be determined in another layer, like Controller</p>
<h3>Option 5: Add Links via Persistent Store</h3>
<p>Store partial links in the db </p>
<p>Pros:<br />
* Db driven, easy to update<br />
* Tables have relationships<br />
* easy adoption path<br />
* easy to link to external resources, or resources outside your db schema<br />
* easy to share links at db level, if several systems integrate at that level<br />
* Good for sparse relationships. </p>
<p>Cons:<br />
* Update to change a link, will not play nice with intermediaries nor "cool uris, that don't change"<br />
* Not great for <b>consistent dense relationships</b>, you probably want to model that differently. So with a Parent Child relationship, you wouldn't want something in addition to existing foreign key relations, to redundantly specify that to get to the children of a parent you have a list of /child/xyz links. but by having that specified in the URITemplateAspect then you are managing that once, close to the data.<br />
* Relationships are not always defined in Foreign Keys<br />
* Links are very static, The "next available" application state, still needs to be determined in another layer, like Controller<br />
* Only a partial solution for more dynamic aspect of determining what application states make sense, still needs to be done in another layer.<br />
* May be invasive, links stored in columns or other tables, no good if you've got a locked down schema.</p>
<h3>Thoughts</h3>
<p>Models shouldn't have relationships to hardcoded resources, like "/resource/50", but they could have a semantic relationship to "/resource/{id}" or "/resource/{id};role={role}" under certain conditions.</p>
<p>There is a place for such LinkAwareModels (Component no. 5), as long as the links are isolated and only contain semantic relationships, they are not urls.</p>
<p>The Links from Models to Resources are isolated and encapsulated within its own abstraction; which gives us component no. 6 URITemplateAspects (maybe just simplify this to LinkTemplateAspect).</p>
<p>Possible "Application States" are dependent on the request, even though a request must be STATELESS, possible "Application States" may still be determined by the security access; restrictions of media-types or client, which should all be part of the request. If you do stuff with user roles, then make sure you encode within your url.</p>
<p>Component no. 4 is our LinkTemplateProcessor(s) and its responsibility is to evaluate URITemplates within the LinkAwareModels/entities and to determine appropriate state transitions based on the request.</p>
<p>This leads us to the final Option ( well, for this post <img src='http://brettdargan.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  )</p>
<h3>Option 6: Semantic relationships of a "Model to resources" definied via URITemplateAspect and a LinkTemplateProcessor to evaluate the relationships (URITemplates) and sub-entities to determine other "application states"</h3>
<p>Pros:<br />
* Detailed knowledge of the model and related models belong in the Model<br />
* Detailed knowledge of the model to resource of interest is a concern isolated in the URITemplateAspects<br />
* Any possible relationships to other resources can be defined<br />
* Links are very dynamic. The possible state transitions can be determined by the LinkTemplateProcessor, but it can do so decoupled from the detailed relationships of the model to other resources. </p>
<p>The semantic relationships that are defined in the LinkAwareModels, can include uri and other attributes, like rel. The LinkTemplateProcessor can evaluate a lot of the current application state (but not all as the User Agent may have representations from other servers or representations that have been modified by Code-On-Demand) in combination with the semantic relationship to determine the ultimate value of the link to use (relative preferred, of course) and it can determine if that link is a valid state transition. Only if you are an admin do you see this link; or the link retains the current media-type used for this request; so a request for /country/AU.html includes links to cities.html, not just cities. The default negotiation might be something if that is not specified.</p>
<p>* The Processor can operate on objects, prior to rendering to a particular media-type, so if you have a single object model that can render to multiple media-types, you could have less code</p>
<h3>Conclusion</h3>
<p>What do you call, this, maybe Rich Interconnected Model View Resource RIMVR.<br />
Rich in relation to having deep links within a resource representation and from the applicability of those links. That actual uri templates are evaluated late and with some context of the request and application state.</p>
<p>The use of these abstractions, <b>in no way make an application RESTful, that is up to the developers</b>, but hopefully by following some abstractions, like these we will get some clean code and some better understanding of RESTful APIs.</p>
<p><a href="http://brettdargan.com/blog/2009/01/14/hateoas-for-legacy-object-models/">I have some old code, to show this working.</a><br />
One day I'll get a chance to clarify terms and simplify the code <img src='http://brettdargan.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=RIMVR+and+HATEOAS%3A+MVC%2BURITemplateAspects%2C+LinkAwareModels+and+LinkTemplateProcessors+http://3z75n.th8.us" title="Post to Twitter"><img class="nothumb" src="http://brettdargan.com/blog/wp-content/plugins/tweet-this/icons/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=RIMVR+and+HATEOAS%3A+MVC%2BURITemplateAspects%2C+LinkAwareModels+and+LinkTemplateProcessors+http://3z75n.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettdargan.com/blog/2009/04/29/rimvr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>link and self; rel=&#8221;canonical&#8221; and rev=&#8221;canonical&#8221;</title>
		<link>http://brettdargan.com/blog/2009/01/22/link-and-self/</link>
		<comments>http://brettdargan.com/blog/2009/01/22/link-and-self/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 23:26:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[RESTful]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[uri]]></category>

		<guid isPermaLink="false">http://brettdargan.com/blog/?p=285</guid>
		<description><![CDATA[




This is based on a cross post from http://www.innoq.com/blog/st/2009/01/link_and_self.html.
Subbu and &#60;Stefan Tilkov have been discussing URI  Equivalence, linking to self and Resource Identities, so here is my view.
Subbu's last remark asks the question

&#62;&#62;&#62;
On January 18, 2009 4:32 AM, Subbu Allamaraju said:
Here is a longer response that is longer than a comment &#60;img src='http://brettdargan.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' [...]]]></description>
			<content:encoded><![CDATA[
<div class="document">


<!-- -*- mode: rst -*- -->
<p>This is based on a cross post from <a class="reference external" href="http://www.innoq.com/blog/st/2009/01/link_and_self.html">http://www.innoq.com/blog/st/2009/01/link_and_self.html</a>.</p>
<p><a class="reference external" href="http://www.subbu.org/blog/2008/12/resource-identity-and-cool-uris">Subbu</a> and <a class="reference external" href="http://www.innoq.com/blog/st/2009/01/link_and_self.html">&lt;Stefan Tilkov</a> have been discussing URI  Equivalence, linking to self and Resource Identities, so here is my view.</p>
<p><a class="reference external" href="http://www.innoq.com/blog/st/2009/01/link_and_self.html#comment-1926">Subbu's last remark asks the question</a></p>
<pre class="doctest-block">
&gt;&gt;&gt;
On January 18, 2009 4:32 AM, Subbu Allamaraju said:
Here is a longer response that is longer than a comment &lt;img src='http://brettdargan.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /&gt;
</pre>
<p><a class="reference external" href="http://www.subbu.org/blog/2009/01/uris-vs-identifiers-take-two">http://www.subbu.org/blog/2009/01/uris-vs-identifiers-take-two</a></p>
<p>IMHO URI non-equivalence does not imply resource non-equivalence.
And if that is really important to your application there SHOULD be ways to handle it.</p>
<p>I agree with Stefan on providing a canonical resource.</p>
<p>You can argue both ways that person and person with address book are either two representations of a person resource, or two different resources, that is the great thing about the Web.</p>
<p>For this case in the atom self link what about using the &lt;b&gt;rev tag&lt;/b&gt; to identify the canonical resource that makes sense for your application.</p>
<p>Since rev also accepts space separated list of link-types you could mark it with both the type and the uri of the canonical resource.</p>
<!-- code-block: html -->
<p>&lt;link href=&quot;<a class="reference external" href="http://www.example.org/person/abc?include=addressBook">http://www.example.org/person/abc?include=addressBook</a>&quot; rel=&quot;self&quot; rev=&quot;canonical <a class="reference external" href="http://www.example.org/person/abc">http://www.example.org/person/abc</a>&quot;/&gt;</p>
<p>As to whether or not <strong>two different entities that returned from different URI</strong> are based on the <strong>same version of the canonical resource or not</strong>:</p>
<p>I would use an EntityTag that encoded some value of resource state and some value of the representation.
Eg. template for xhtml representation may change without resource state and the ETag must change in order to reflect that.</p>
<p>To KISS.</p>
<p>If you had an ETag consisted of something like <strong>&quot;resourceVersion=20,reprVersion={date}&quot;</strong>
Then your application could extract out the self links with <strong>identical rev tags</strong> and extract from the ETag the resourceVersion.</p>
</div>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=link+and+self%3B+rel%3D%E2%80%9Dcanonical%E2%80%9D+and+rev%3D%E2%80%9Dcanonical%E2%80%9D+http://zresm.th8.us" title="Post to Twitter"><img class="nothumb" src="http://brettdargan.com/blog/wp-content/plugins/tweet-this/icons/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=link+and+self%3B+rel%3D%E2%80%9Dcanonical%E2%80%9D+and+rev%3D%E2%80%9Dcanonical%E2%80%9D+http://zresm.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettdargan.com/blog/2009/01/22/link-and-self/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>URI Design &#8211; Matrix Params for cross-cutting concerns</title>
		<link>http://brettdargan.com/blog/2009/01/16/uri-design-matrix-params-for-cross-cutting-concerns/</link>
		<comments>http://brettdargan.com/blog/2009/01/16/uri-design-matrix-params-for-cross-cutting-concerns/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 14:54:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[RESTful]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[uri]]></category>

		<guid isPermaLink="false">http://brettdargan.com/blog/?p=217</guid>
		<description><![CDATA[




Looking at URI design, there are a lot of cross-cutting concerns across many a resource.
It would be great to come up with some conventions for the most common.
These are some of the ones I've been percolating on.

You can see there are a broad range, including:

different views or representations of a resource, around breadth/depth of it's [...]]]></description>
			<content:encoded><![CDATA[
<div class="document">


<!-- -*- mode: rst -*- -->
<p>Looking at URI design, there are a lot of cross-cutting concerns across many a resource.
It would be great to come up with some conventions for the most common.</p>
<p>These are some of the ones I've been percolating on.</p>
<dl class="docutils">
<dt>You can see there are a broad range, including:</dt>
<dd><ul class="first last simple">
<li>different views or representations of a resource, around breadth/depth of it's data and relations</li>
<li>user request based affects on a representation</li>
<li>resource version</li>
<li>application supporting mechanisms, returning fragments and forms or form fragments</li>
<li>temporality</li>
</ul>
</dd>
</dl>
<p>There are a few more, but the trick is having less, right.</p>
<table border="1" class="docutils">
<colgroup>
<col width="6%" />
<col width="94%" />
</colgroup>
<tbody valign="top">
<tr><td>;version</td>
<td>entity version that is</td>
</tr>
<tr><td>;_for_edit ;_for_inline_edit</td>
<td>return html fragment</td>
</tr>
<tr><td>;_at_instant={utc_milliseconds}</td>
<td>get this resource as it would be represented at this point in time</td>
</tr>
<tr><td>;_for_period=iso8601 format</td>
<td>holidays during these periods/durations. die to start and end date ranges. or ;_for_interval</td>
</tr>
<tr><td>;_role=admin</td>
<td>&nbsp;</td>
</tr>
<tr><td>;_repr=code_value</td>
<td>representation of code_value. May also need numcode_value and maybe a triple for code,short name and description</td>
</tr>
<tr><td>;_repr=summary|detail|depth</td>
<td>you get the idea</td>
</tr>
<tr><td>;_repr=no_ambiguity</td>
<td>return a 300 Multiple Choices, if there must be no ambiguity in the request. If the request can not fully determine the intended resource. Often in practice a convention will be followed, like the latest version of the resource. If you support multiple versions do you do what wikipedia does and offers a disambiguity page (as a standard OK response). Although disambiguity pages could cause issues in situations where you expect all particular requests of a resource to return same formatted representation ie. no ambiguity.</td>
</tr>
<tr><td>;additional_param=xyz</td>
<td>#ambiguity resolution</td>
</tr>
<tr><td>;fragment</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>See also <a class="reference external" href="http://wikipedia.com/ISO_8601">ISO8601</a></p>
</div>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=URI+Design+%E2%80%93+Matrix+Params+for+cross-cutting+concerns+http://sisb5.th8.us" title="Post to Twitter"><img class="nothumb" src="http://brettdargan.com/blog/wp-content/plugins/tweet-this/icons/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=URI+Design+%E2%80%93+Matrix+Params+for+cross-cutting+concerns+http://sisb5.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettdargan.com/blog/2009/01/16/uri-design-matrix-params-for-cross-cutting-concerns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Query vs. Matrix Params or Path Params</title>
		<link>http://brettdargan.com/blog/2009/01/16/query-vs-matrix-params/</link>
		<comments>http://brettdargan.com/blog/2009/01/16/query-vs-matrix-params/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 14:09:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[RESTful]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[uri]]></category>

		<guid isPermaLink="false">http://brettdargan.com/blog/?p=211</guid>
		<description><![CDATA[




I've come across a few posts about Matrix Parameters recently and there is a lot of misunderstanding.
There are several old posts that discuss and describe these things:

Query Strings Considered Harmful
w3c MatrixURIs


I've summarised what I think is important:

urls with query params won't have their response cached by intermediaries/proxies (at present)
matrix parameters may appear anywhere in path
calculating [...]]]></description>
			<content:encoded><![CDATA[
<div class="document">


<!-- -*- mode: rst -*- -->
<p>I've come across a few posts about Matrix Parameters recently and there is a lot of misunderstanding.</p>
<p>There are several old posts that discuss and describe these things:</p>
<ul class="simple">
<li><a class="reference external" href="http://rest.blueoxen.net/cgi-bin/wiki.pl?QueryStringsConsideredHarmful">Query Strings Considered Harmful</a></li>
<li><a class="reference external" href="http://www.w3.org/DesignIssues/MatrixURIs.html">w3c MatrixURIs</a></li>
</ul>
<dl class="docutils">
<dt>I've summarised what I think is important:</dt>
<dd><ul class="first last simple">
<li>urls with query params <a class="reference internal" href="#won-t-have-their-response-cached-by-intermediaries-proxies-at-present">won't have their response cached by intermediaries/proxies (at present)</a></li>
<li>matrix parameters may appear anywhere in path</li>
<li><a class="reference internal" href="#calculating-the-relative-uri">calculating the relative uri</a> is different</li>
<li>much more than uri convention</li>
<li>query params are generally abused to add new verbs instead of using existing methods on resources</li>
<li>matrix parameters are not resources, they are aspects that help reference a resource in an information space that is difficult to represent within a hierarchy</li>
</ul>
</dd>
</dl>
<p><strong>Tip: If you're not sure if you should use them then don't.</strong></p>
<dl class="docutils">
<dt>Matrix parameters are used with</dt>
<dd><ul class="first last simple">
<li><a class="reference external" href="http://developer.yahoo.com/yui">YUI paging widgets</a></li>
<li><a class="reference external" href="http://rails.org">RoR</a> /some/resource/id;edit</li>
<li>J2ee fallsback to ;jsessionid=xxx when no cookies can be set.</li>
<li><a class="reference external" href="http://jersey.dev.java.net">Jersey (JAX-RS RefImpl) has good support</a></li>
</ul>
</dd>
</dl>
<div class="section" id="caching-issues">
<span id="won-t-have-their-response-cached-by-intermediaries-proxies-at-present"></span><h3>Caching Issues</h3>
<dl class="docutils">
<dt>Intermediaries (proxies) won't cache any url with a query parameter in the url</dt>
<dd><ul class="first last simple">
<li>this is because in the early days of the web, they didn't trust the Cache control information from dynamically generated pages.</li>
<li>Freshness and Validation information are very important pieces of information and the proxy admins took a cautious stance and didn't cache any of it.</li>
</ul>
</dd>
</dl>
<p>As the web has matured the views of devs/admins are changing, the new versions of Squid will default to cache any urls with query parameters</p>
<p>Obviously this could have a very large impact, I've heard google maps image tiles had this issue with some proxies at one time.</p>
</div>
<div class="section" id="relative-uri-calculations">
<span id="calculating-the-relative-uri"></span><h3>Relative URI calculations</h3>
<p>Relative URIs have different affects, as relatives URLs are determined by appending to the Base URI. For Query Parameter requests they are stripped from the Base.</p>
<p>For those still interested I would recommend checking out the following in addition to the <a class="reference external" href="http://tools.ietf.org/html/rfc2616">RFC-2616</a> of course.</p>
<blockquote>
<ul class="simple">
<li><a class="reference external" href="http://www.oreillynet.com/xml/blog/2006/12/the_matrix_revisited.html">the matrix revisited</a></li>
<li><a class="reference external" href="http://rest.blueoxen.net/cgi-bin/wiki.pl?PathsAndQueryStrings">PathsAndQueryStrings</a></li>
<li><a class="reference external" href="http://doriantaylor.com/policy/http-url-path-parameter-syntax">http url path parameter syntax</a></li>
<li><a class="reference external" href="http://blogs.sun.com/sandoz/entry/building_uris">Building URIs</a></li>
</ul>
</blockquote>
</div>
</div>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Query+vs.+Matrix+Params+or+Path+Params+http://xba34.th8.us" title="Post to Twitter"><img class="nothumb" src="http://brettdargan.com/blog/wp-content/plugins/tweet-this/icons/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Query+vs.+Matrix+Params+or+Path+Params+http://xba34.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettdargan.com/blog/2009/01/16/query-vs-matrix-params/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>HATEOAS for legacy object models</title>
		<link>http://brettdargan.com/blog/2009/01/14/hateoas-for-legacy-object-models/</link>
		<comments>http://brettdargan.com/blog/2009/01/14/hateoas-for-legacy-object-models/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 15:44:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Patterns]]></category>
		<category><![CDATA[RESTful]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[aop]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[hateoas]]></category>
		<category><![CDATA[rest]]></category>

		<guid isPermaLink="false">http://brettdargan.com/blog/?p=196</guid>
		<description><![CDATA[




One of the best aspects of RESTful orientated services is getting your resources connected, possibly even achieving HATEOAS. Making that jump with with legacy object models or data can be tricky, depending on how intrusive you want to be.
There is such a large amount of legacy data in various forms, usually with minimal links/relations that [...]]]></description>
			<content:encoded><![CDATA[
<div class="document">


<!-- -*- mode: rst -*- -->
<p>One of the best aspects of RESTful orientated services is getting your resources connected, possibly even achieving HATEOAS. Making that jump with with legacy object models or data can be tricky, depending on how intrusive you want to be.</p>
<p>There is such a large amount of legacy data in various forms, usually with minimal links/relations that could be leveraged.</p>
<p>So it is a worthy challenge to try and do it in the least intrusive manner possible.</p>
<p>This is one approach that is reasonably decoupled from an existing legacy model.</p>
<p>There are three main parts to this technique:</p>
<ol class="arabic simple">
<li>Enhance your model objects so they have a placeholder/collection so you can accumulate links</li>
<li>Annotate your model at interesting points with <strong>link templates</strong>, around attributes or methods or classes</li>
<li>Use a custom <a class="reference external" href="http://jersey.dev.java.net&quot;">ContainerResponseFilter</a> class of jersey to scan for annotations of interest, then evaluate your link templates (at run time), using the data of your models and any request based information you may require.</li>
</ol>
<p>I chose to enhance my model classes using <a class="reference external" href="http://eclipse.org/aspectj">AspectJ</a> at compile time.</p>
<p><a class="reference external" href="http://brettdargan.com/blog/wp-content/uploads/2009/01/hateoas4legacytar.bz2">Download the source</a></p>
<div class="codeblock"><div class="highlight"><pre>mvn glassfish:run
./curl_test #will hit two urls
</pre></div>
</div><p>and you should see some results, with links like this:</p>
<div class="codeblock"><div class="highlight"><pre><span style="color: #BC7A00">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;</span>
<span style="color: #008000; font-weight: bold">&lt;country</span> <span style="color: #7D9029">xmlns:ns2=</span><span style="color: #BA2121">&quot;http://www.w3.org/1999/xlink&quot;</span><span style="color: #008000; font-weight: bold">&gt;</span>
  <span style="color: #008000; font-weight: bold">&lt;links&gt;</span>
    <span style="color: #008000; font-weight: bold">&lt;link</span> <span style="color: #7D9029">rel=</span><span style="color: #BA2121">&quot;&quot;</span> <span style="color: #7D9029">ns2:type=</span><span style="color: #BA2121">&quot;locator&quot;</span>
        <span style="color: #7D9029">ns2:href=</span><span style="color: #BA2121">&quot;http://localhost:8080/hateoas4legacy/rs/cities/Brisbane&quot;</span><span style="color: #008000; font-weight: bold">/&gt;</span>
    <span style="color: #008000; font-weight: bold">&lt;link</span> <span style="color: #7D9029">rel=</span><span style="color: #BA2121">&quot;&quot;</span>
        <span style="color: #7D9029">ns2:type=</span><span style="color: #BA2121">&quot;locator&quot;</span> <span style="color: #7D9029">ns2:href=</span><span style="color: #BA2121">&quot;http://localhost:8080/hateoas4legacy/rs/cities/Sydney&quot;</span><span style="color: #008000; font-weight: bold">/&gt;</span>
    <span style="color: #008000; font-weight: bold">&lt;link</span> <span style="color: #7D9029">rel=</span><span style="color: #BA2121">&quot;&quot;</span>
        <span style="color: #7D9029">ns2:type=</span><span style="color: #BA2121">&quot;locator&quot;</span> <span style="color: #7D9029">ns2:href=</span><span style="color: #BA2121">&quot;http://localhost:8080/hateoas4legacy/rs/cities/Melbourne&quot;</span><span style="color: #008000; font-weight: bold">/&gt;</span>
    <span style="color: #008000; font-weight: bold">&lt;link</span> <span style="color: #7D9029">rel=</span><span style="color: #BA2121">&quot;&quot;</span>
        <span style="color: #7D9029">ns2:type=</span><span style="color: #BA2121">&quot;locator&quot;</span> <span style="color: #7D9029">ns2:href=</span><span style="color: #BA2121">&quot;http://localhost:8080/hateoas4legacy/rs/countries/AU&quot;</span><span style="color: #008000; font-weight: bold">/&gt;</span>
  <span style="color: #008000; font-weight: bold">&lt;/links&gt;</span>
  <span style="color: #008000; font-weight: bold">&lt;cities&gt;</span>
    <span style="color: #008000; font-weight: bold">&lt;city&gt;</span>
      <span style="color: #008000; font-weight: bold">&lt;links/&gt;</span>
      <span style="color: #008000; font-weight: bold">&lt;name&gt;</span>Brisbane<span style="color: #008000; font-weight: bold">&lt;/name&gt;</span>
    <span style="color: #008000; font-weight: bold">&lt;/city&gt;</span>
    <span style="color: #008000; font-weight: bold">&lt;city&gt;</span>
        <span style="color: #008000; font-weight: bold">&lt;links/&gt;</span>
        <span style="color: #008000; font-weight: bold">&lt;name&gt;</span>Sydney<span style="color: #008000; font-weight: bold">&lt;/name&gt;</span>
    <span style="color: #008000; font-weight: bold">&lt;/city&gt;</span>
    <span style="color: #008000; font-weight: bold">&lt;city&gt;</span>
      <span style="color: #008000; font-weight: bold">&lt;links/&gt;</span>
      <span style="color: #008000; font-weight: bold">&lt;name&gt;</span>Melbourne<span style="color: #008000; font-weight: bold">&lt;/name&gt;</span>
    <span style="color: #008000; font-weight: bold">&lt;/city&gt;</span>
  <span style="color: #008000; font-weight: bold">&lt;/cities&gt;</span>
  <span style="color: #008000; font-weight: bold">&lt;isoCode&gt;</span>AU<span style="color: #008000; font-weight: bold">&lt;/isoCode&gt;</span>
  <span style="color: #008000; font-weight: bold">&lt;name&gt;</span>Australia<span style="color: #008000; font-weight: bold">&lt;/name&gt;</span>
<span style="color: #008000; font-weight: bold">&lt;/country&gt;</span>
</pre></div>
</div><p>All countries Results</p>
<div class="codeblock"><div class="highlight"><pre><span style="color: #BC7A00">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;</span>
<span style="color: #008000; font-weight: bold">&lt;countries&gt;</span>
<span style="color: #008000; font-weight: bold">&lt;country</span> <span style="color: #7D9029">xmlns:ns2=</span><span style="color: #BA2121">&quot;http://www.w3.org/1999/xlink&quot;</span><span style="color: #008000; font-weight: bold">&gt;</span>
  <span style="color: #008000; font-weight: bold">&lt;links&gt;</span>
    <span style="color: #008000; font-weight: bold">&lt;link</span> <span style="color: #7D9029">rel=</span><span style="color: #BA2121">&quot;&quot;</span>
        <span style="color: #7D9029">ns2:type=</span><span style="color: #BA2121">&quot;locator&quot;</span> <span style="color: #7D9029">ns2:href=</span><span style="color: #BA2121">&quot;http://localhost:8080/hateoas4legacy/rs/countries/AU&quot;</span><span style="color: #008000; font-weight: bold">/&gt;</span>
  <span style="color: #008000; font-weight: bold">&lt;/links&gt;</span>
  <span style="color: #008000; font-weight: bold">&lt;cities/&gt;</span>
  <span style="color: #008000; font-weight: bold">&lt;isoCode&gt;</span>AU<span style="color: #008000; font-weight: bold">&lt;/isoCode&gt;</span>
  <span style="color: #008000; font-weight: bold">&lt;name&gt;</span>Australia<span style="color: #008000; font-weight: bold">&lt;/name&gt;</span>
<span style="color: #008000; font-weight: bold">&lt;/country&gt;</span>
<span style="color: #008000; font-weight: bold">&lt;country</span> <span style="color: #7D9029">xmlns:ns2=</span><span style="color: #BA2121">&quot;http://www.w3.org/1999/xlink&quot;</span><span style="color: #008000; font-weight: bold">&gt;</span>
  <span style="color: #008000; font-weight: bold">&lt;links&gt;</span>
    <span style="color: #008000; font-weight: bold">&lt;link</span> <span style="color: #7D9029">rel=</span><span style="color: #BA2121">&quot;&quot;</span>
        <span style="color: #7D9029">ns2:type=</span><span style="color: #BA2121">&quot;locator&quot;</span> <span style="color: #7D9029">ns2:href=</span><span style="color: #BA2121">&quot;http://localhost:8080/hateoas4legacy/rs/countries/USA&quot;</span><span style="color: #008000; font-weight: bold">/&gt;</span>
  <span style="color: #008000; font-weight: bold">&lt;/links&gt;</span>
  <span style="color: #008000; font-weight: bold">&lt;cities/&gt;</span>
  <span style="color: #008000; font-weight: bold">&lt;isoCode&gt;</span>USA<span style="color: #008000; font-weight: bold">&lt;/isoCode&gt;</span>
  <span style="color: #008000; font-weight: bold">&lt;name&gt;</span>United States of America<span style="color: #008000; font-weight: bold">&lt;/name&gt;</span>
<span style="color: #008000; font-weight: bold">&lt;/country&gt;</span>
<span style="color: #008000; font-weight: bold">&lt;/countries&gt;</span>
</pre></div>
</div><p>It is very crufty, but does work in the simple cases.
I haven't had a chance to demonstrate all of the features yet.</p>
<p>I'm likely to further flesh out this example as it is interesting in other RESTful related ways.</p>
</div>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=HATEOAS+for+legacy+object+models+http://ysfqw.th8.us" title="Post to Twitter"><img class="nothumb" src="http://brettdargan.com/blog/wp-content/plugins/tweet-this/icons/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=HATEOAS+for+legacy+object+models+http://ysfqw.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://brettdargan.com/blog/2009/01/14/hateoas-for-legacy-object-models/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
