You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by bu...@apache.org on 2013/10/09 16:42:02 UTC

svn commit: r881873 - in /websites/staging/olingo/trunk/content: ./ doc/tutorials/read_media-resource.html

Author: buildbot
Date: Wed Oct  9 14:42:02 2013
New Revision: 881873

Log:
Staging update by buildbot for olingo

Modified:
    websites/staging/olingo/trunk/content/   (props changed)
    websites/staging/olingo/trunk/content/doc/tutorials/read_media-resource.html

Propchange: websites/staging/olingo/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Wed Oct  9 14:42:02 2013
@@ -1 +1 @@
-1530635
+1530640

Modified: websites/staging/olingo/trunk/content/doc/tutorials/read_media-resource.html
==============================================================================
--- websites/staging/olingo/trunk/content/doc/tutorials/read_media-resource.html (original)
+++ websites/staging/olingo/trunk/content/doc/tutorials/read_media-resource.html Wed Oct  9 14:42:02 2013
@@ -115,7 +115,7 @@ As conclusion following methods are adde
 <p>Additional and in conclusion with the <code>DataStore</code> three images (png) are added to the sample project. These images are located in <em>/sample-service/src/main/resources/</em> and are named Driver_'x'.png were 'x' is replaced by a number.
 To really get an image for a media resource request it is necessary to copy these images (or create own PNG files which follows the naming schema).
 If nothing is copied/created the sample will still work but does not show an image for a media resource request (instead a HTTP Response 404 - Entity not found is shown). </p>
-<p><strong> Extend MyEdmProvider with Driver data model </strong></p>
+<p><strong> Extend MyEdmProvider with Driver data model </strong><br></p>
 <p>First the new Driver is added in the EDM. 
 The Driver gets a Key (Id) and some properties (Name, Surname, Nickname, Updates. For simplification currently we do not add any associations to another entities.</p>
 <p>To mark the Driver as a media link entry with an associated media resource extension it is mandatory to set the stream property to true via the <code>setHasStream(true)</code> method when creating the <code>EntityType</code>.</p>
@@ -166,7 +166,7 @@ The Driver gets a Key (Id) and some prop
 </pre></div>
 
 
-<p><strong>Extend <code>MyODataSingleProcessor</code> with <code>readEntityMedia(uriInfo:GetMediaResourceUriInfo, contentType:String):ODataResponse</code> method</strong>
+<p><strong>Extend <code>MyODataSingleProcessor</code> with <code>readEntityMedia(uriInfo:GetMediaResourceUriInfo, contentType:String):ODataResponse</code> method</strong><br>
 All requests for media resources are done via the specified $value property in the URL (e.g. <em>.../MyODataSample.svc/Drivers(1)/$value</em>). Such a request will be dispatched to an <code>EntityMediaProcessor</code> which is in our case the <code>MyODataSingleProcessor</code> (inherited from <code>ODataSingleProcessor</code>).
 To handle now such read requests for our media resources we override and implement the <code>readEntityMedia(uriInfo:GetMediaResourceUriInfo, contentType:String):ODataResponse</code> method.
 For our scenario we simply have to validate the correct requested target <code>EntitySet</code>, get the key for requesting the data from our <code>DataStore</code> (which contains the binary data of our media resource), use the <code>EntityProvider</code> to write the data and at last build the <code>ODataResponse</code>.
@@ -192,7 +192,7 @@ Seems a lot but in code this are only th
 
 
 <p>With these extension it is possible to read the media resource, but for access to the Driver <code>EntitySet</code> and <code>Entity</code> the according read methods have to be extended.</p>
-<p><strong> Extend existing <code>readEntitySet(...)</code> and <code>readEntity(...)</code> methods in <code>MyODataSingleProcessor</code> methods </strong>
+<p><strong> Extend existing <code>readEntitySet(...)</code> and <code>readEntity(...)</code> methods in <code>MyODataSingleProcessor</code> methods </strong><br>
 For access to the Driver as <code>Entity</code> and as <code>EntitySet</code> the according <code>readreadEntitySet(...)</code> and <code>readEntity(...)</code> methods have to be extended.</p>
 <p>But its quite the same procedure as in the basic read. Validate the requested Entity, get the key for requesting the <code>DataStore</code> and write the result data via the <code>EntityProvider</code>.</p>
 <p>The resulting extension for <code>readEntity(…)</code>:</p>
@@ -215,12 +215,12 @@ For access to the Driver as <code>Entity
 </pre></div>
 
 
-<p><strong>Conclusion for media resource extension</strong>
+<p><strong>Conclusion for media resource extension</strong><br>
 After finishing all steps above the project can be built and deployed containing a Driver type which is a media link entry with associated media resource. <em>Congratulations.</em></p>
 <p>For a more interesting sample and to update before learned knowledge about associations and <code>$expand</code> it is recommended to finish this HowTo with the creation of an association between a Driver and his Car with supported <code>$expand</code>.</p>
-<p><strong>Extend Driver with association to Car</strong>
+<p><strong>Extend Driver with association to Car</strong><br>
 For a more interesting sample we now create an association between a Driver and his Car.</p>
-<p><strong>Extend Driver and Car in MyEdmProvider with a navigation property</strong>
+<p><strong>Extend Driver and Car in MyEdmProvider with a navigation property</strong><br>
 At first we introduce the necessary constants:</p>
 <div class="codehilite"><pre>  <span class="kd">private</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">FullQualifiedName</span> <span class="n">ASSOCIATION_DRIVER_CAR</span> <span class="o">=</span> <span class="k">new</span> <span class="n">FullQualifiedName</span><span class="o">(</span><span class="n">NAMESPACE</span><span class="o">,</span> <span class="s">&quot;Driver_Car-Car_Driver&quot;</span><span class="o">);</span>
 
@@ -300,7 +300,7 @@ At first we introduce the necessary cons
 </pre></div>
 
 
-<p><strong>Extend existing <code>readreadEntitySet(...)</code> and <code>readEntity(...)</code> methods in <code>MyODataSingleProcessor</code></strong>
+<p><strong>Extend existing <code>readreadEntitySet(...)</code> and <code>readEntity(...)</code> methods in <code>MyODataSingleProcessor</code></strong><br>
 For cleaner code we introduce at first following method in the <code>MyODataSingleProcessor</code> which validate if the uri contains the expected association.</p>
 <div class="codehilite"><pre><span class="kd">private</span> <span class="kt">boolean</span> <span class="nf">isAssociation</span><span class="o">(</span><span class="n">GetEntityUriInfo</span> <span class="n">uriInfo</span><span class="o">,</span> <span class="n">String</span> <span class="n">startName</span><span class="o">,</span> <span class="n">String</span> <span class="n">targetName</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">EdmException</span> <span class="o">{</span>
   <span class="k">if</span><span class="o">(</span><span class="n">startName</span> <span class="o">==</span> <span class="kc">null</span> <span class="o">||</span> <span class="n">targetName</span> <span class="o">==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span>
@@ -342,9 +342,9 @@ For cleaner code we introduce at first f
 </pre></div>
 
 
-<p><strong>Add $expand support for Driver to/from Car association</strong>
+<p><strong>Add $expand support for Driver to/from Car association</strong><br>
 The last missing step is to add the <code>$expand</code> support for the new Driver to/from Car association.</p>
-<p><strong>Extend MyCallback for Driver and Car association</strong>
+<p><strong>Extend MyCallback for Driver and Car association</strong><br>
 Add first the extension in the MyCallback for each entity is done in the <code>retrieveEntryResult()</code> method.
 The procedure is similar to the Cars - Manufacturers association. At first it is checked for the correct association of the requested Entity, then the key for requesting the DataStore is get as well as the data and then result data is attached to the <code>WriteEntryCallbackResult</code>.</p>
 <p>The resulting method extension is:</p>
@@ -373,7 +373,7 @@ The procedure is similar to the Cars - M
 </pre></div>
 
 
-<p><strong>Add registration of MyCallback for Driver and Car association</strong>
+<p><strong>Add registration of MyCallback for Driver and Car association</strong><br>
 After extension of <code>MyCallback</code> it is necessary to register a callback within the <code>readEntity()</code> in the <code>MyODataSingleProcessor</code>.</p>
 <p>For the Driver we add the complete callback registration (code between the comments) which results in final code for the complete Driver Entity handling:</p>
 <div class="codehilite"><pre><span class="o">...</span>