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 2015/10/13 12:50:15 UTC

svn commit: r968746 - in /websites/staging/olingo/trunk/content: ./ doc/odata4/tutorials/media/tutorial_media.html

Author: buildbot
Date: Tue Oct 13 10:50:15 2015
New Revision: 968746

Log:
Staging update by buildbot for olingo

Modified:
    websites/staging/olingo/trunk/content/   (props changed)
    websites/staging/olingo/trunk/content/doc/odata4/tutorials/media/tutorial_media.html

Propchange: websites/staging/olingo/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Tue Oct 13 10:50:15 2015
@@ -1 +1 @@
-1708321
+1708322

Modified: websites/staging/olingo/trunk/content/doc/odata4/tutorials/media/tutorial_media.html
==============================================================================
--- websites/staging/olingo/trunk/content/doc/odata4/tutorials/media/tutorial_media.html (original)
+++ websites/staging/olingo/trunk/content/doc/odata4/tutorials/media/tutorial_media.html Tue Oct 13 10:50:15 2015
@@ -142,7 +142,7 @@ This tutorial can be found in subdirecto
 <li>Implement the interface <code>MediaEntityProcessor</code></li>
 </ul>
 <h3 id="extend-the-metadata-document">Extend the metadata document<a class="headerlink" href="#extend-the-metadata-document" title="Permanent link">&para;</a></h3>
-<p>If you have read the prevois tutorials, you should be familiar with the definition entity types. The only difference to regular (Non media enties) is, that they have a <code>hasStream</code> Property. If this property is not provided it defaults to false. So add the following code to class <code>DemoEdmProvider</code>:</p>
+<p>If you have read the prevois tutorials, you should be familiar with the definition entity types. The only difference to regular (Non media enties) is, that they have a <code>hasStream</code> property. If this property is not provided it defaults to false. So add the following code to class <code>DemoEdmProvider</code>:</p>
 <p>We start with method <code>DemoEdmProvider.getEntityType</code></p>
 <div class="codehilite"><pre><span class="kd">public</span> <span class="n">CsdlEntityType</span> <span class="nf">getEntityType</span><span class="o">(</span><span class="n">FullQualifiedName</span> <span class="n">entityTypeName</span><span class="o">)</span> <span class="o">{</span>
     <span class="n">CsdlEntityType</span> <span class="n">entityType</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
@@ -176,7 +176,7 @@ This tutorial can be found in subdirecto
 </pre></div>
 
 
-<p>Further a have to create a new entity set. Add the following snipped to <code>DemoEdmProvider.getEntitySet</code></p>
+<p>Further we  have to create a new entity set. Add the following snipped to <code>DemoEdmProvider.getEntitySet</code></p>
 <div class="codehilite"><pre><span class="p">@</span><span class="n">Override</span>
 <span class="n">public</span> <span class="n">CsdlEntitySet</span> <span class="n">getEntitySet</span><span class="p">(</span><span class="n">FullQualifiedName</span> <span class="n">entityContainer</span><span class="p">,</span> <span class="n">String</span> <span class="n">entitySetName</span><span class="p">)</span> <span class="p">{</span>
     <span class="n">CsdlEntitySet</span> <span class="n">entitySet</span> <span class="p">=</span> <span class="n">null</span><span class="p">;</span>
@@ -218,17 +218,19 @@ This tutorial can be found in subdirecto
 
 <h3 id="enable-the-data-store-to-handle-media-entities">Enable the data store to handle media entities<a class="headerlink" href="#enable-the-data-store-to-handle-media-entities" title="Permanent link">&para;</a></h3>
 <p>In this tutorial, we will keep things simple. To store the value of media entities, we create a special property <em>$value</em>. Note this is not a valid OData Identifier.</p>
-<p>To read the content to a media entity, we simple return the value of the property <em>$value</em>.
-    ::::java
-     private static final String MEDIA_PROPERTY_NAME = "$value";</p>
-<div class="codehilite"><pre><span class="n">public</span> <span class="n">byte</span><span class="p">[]</span> <span class="n">readMedia</span><span class="p">(</span><span class="n">final</span> <span class="n">Entity</span> <span class="n">entity</span><span class="p">)</span> <span class="p">{</span>
-    <span class="k">return</span> <span class="p">(</span><span class="n">byte</span><span class="p">[])</span> <span class="n">entity</span><span class="p">.</span><span class="n">getProperty</span><span class="p">(</span><span class="n">MEDIA_PROPERTY_NAME</span><span class="p">).</span><span class="n">asPrimitive</span><span class="p">();</span>
-<span class="p">}</span>
+<p>To read the content to a media entity, we simple return the value of the property <em>$value</em>.</p>
+<div class="codehilite"><pre> <span class="kd">private</span> <span class="kd">static</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">MEDIA_PROPERTY_NAME</span> <span class="o">=</span> <span class="s">&quot;$value&quot;</span><span class="o">;</span>
+
+<span class="kd">public</span> <span class="kt">byte</span><span class="o">[]</span> <span class="nf">readMedia</span><span class="o">(</span><span class="kd">final</span> <span class="n">Entity</span> <span class="n">entity</span><span class="o">)</span> <span class="o">{</span>
+    <span class="k">return</span> <span class="o">(</span><span class="kt">byte</span><span class="o">[])</span> <span class="n">entity</span><span class="o">.</span><span class="na">getProperty</span><span class="o">(</span><span class="n">MEDIA_PROPERTY_NAME</span><span class="o">).</span><span class="na">asPrimitive</span><span class="o">();</span>
+<span class="o">}</span>
 </pre></div>
 
 
-<p>If we update the content of a media entity, we must also the the Content Type of the content.  </p>
-<div class="codehilite"><pre><span class="kd">public</span> <span class="kt">void</span> <span class="nf">updateMedia</span><span class="o">(</span><span class="kd">final</span> <span class="n">Entity</span> <span class="n">entity</span><span class="o">,</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">mediaContentType</span><span class="o">,</span> <span class="kd">final</span> <span class="kt">byte</span><span class="o">[]</span> <span class="n">data</span><span class="o">)</span> <span class="o">{</span>
+<p>If we update the content of a media entity, we must also set the the Content Type of the content.</p>
+<div class="codehilite"><pre><span class="kd">private</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">Entity</span><span class="o">&gt;</span> <span class="n">advertisments</span><span class="o">;</span>
+
+<span class="kd">public</span> <span class="kt">void</span> <span class="nf">updateMedia</span><span class="o">(</span><span class="kd">final</span> <span class="n">Entity</span> <span class="n">entity</span><span class="o">,</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">mediaContentType</span><span class="o">,</span> <span class="kd">final</span> <span class="kt">byte</span><span class="o">[]</span> <span class="n">data</span><span class="o">)</span> <span class="o">{</span>
     <span class="n">entity</span><span class="o">.</span><span class="na">getProperties</span><span class="o">().</span><span class="na">remove</span><span class="o">(</span><span class="n">entity</span><span class="o">.</span><span class="na">getProperty</span><span class="o">(</span><span class="n">MEDIA_PROPERTY_NAME</span><span class="o">));</span>
     <span class="n">entity</span><span class="o">.</span><span class="na">addProperty</span><span class="o">(</span><span class="k">new</span> <span class="n">Property</span><span class="o">(</span><span class="kc">null</span><span class="o">,</span> <span class="n">MEDIA_PROPERTY_NAME</span><span class="o">,</span> <span class="n">ValueType</span><span class="o">.</span><span class="na">PRIMITIVE</span><span class="o">,</span> <span class="n">data</span><span class="o">));</span>
     <span class="n">entity</span><span class="o">.</span><span class="na">setMediaContentType</span><span class="o">(</span><span class="n">mediaContentType</span><span class="o">);</span>
@@ -236,7 +238,7 @@ This tutorial can be found in subdirecto
 </pre></div>
 
 
-<p>If a client creates a new media entity, the body of the requet contains the content of the media entity instead the regualr properties! So the other regular properties defaults to <code>null</code>. The Content Type of the  media content must also be set up.</p>
+<p>If a client creates a new media entity, the body of the requet contains the content of the media entity instead the regualr properties! So the other regular properties defaults to <code>null</code>. The Content Type of the  media content must also be set.</p>
 <div class="codehilite"><pre><span class="kd">public</span> <span class="n">Entity</span> <span class="nf">createMediaEntity</span><span class="o">(</span><span class="kd">final</span> <span class="n">EdmEntityType</span> <span class="n">edmEntityType</span><span class="o">,</span> <span class="kd">final</span> <span class="n">String</span> <span class="n">mediaContentType</span><span class="o">,</span> <span class="kd">final</span> <span class="kt">byte</span><span class="o">[]</span> <span class="n">data</span><span class="o">)</span> <span class="o">{</span>
     <span class="n">Entity</span> <span class="n">entity</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
 
@@ -258,7 +260,7 @@ This tutorial can be found in subdirecto
 
 
 <h3 id="implement-the-interface-mediaentityprocessor">Implement the interface <code>MediaEntityProcessor</code><a class="headerlink" href="#implement-the-interface-mediaentityprocessor" title="Permanent link">&para;</a></h3>
-<p>As you can see the <a href="http://olingo.apache.org/javadoc/odata4/org/apache/olingo/server/api/processor/MediaEntityProcessor.html"><code>MediaEntityProcessor</code></a> extends <a href="http://olingo.apache.org/javadoc/odata4/org/apache/olingo/server/api/processor/EntityProcessor.html"><code>EntityProcessor</code></a>, therefore we will implement <code>MediaEntityProcessor</code> in class <code>DemoEntityProcessor</code>.</p>
+<p>As you can see the <a href="http://olingo.apache.org/javadoc/odata4/org/apache/olingo/server/api/processor/MediaEntityProcessor.html"><code>MediaEntityProcessor</code>(Javadoc)</a> extends <a href="http://olingo.apache.org/javadoc/odata4/org/apache/olingo/server/api/processor/EntityProcessor.html"><code>EntityProcessor</code></a>, therefore we will implement <code>MediaEntityProcessor</code> in class <code>DemoEntityProcessor</code>.</p>
 <p>The easiest part is to delete an media entity. The method <code>deleteMediaEntity</code> is delegated to the method <code>deleteEntity(...)</code>.</p>
 <div class="codehilite"><pre><span class="nd">@Override</span>
 <span class="kd">public</span> <span class="kt">void</span> <span class="nf">deleteMediaEntity</span><span class="o">(</span><span class="n">ODataRequest</span> <span class="n">request</span><span class="o">,</span> <span class="n">ODataResponse</span> <span class="n">response</span><span class="o">,</span> <span class="n">UriInfo</span> <span class="n">uriInfo</span><span class="o">)</span>
@@ -269,7 +271,7 @@ This tutorial can be found in subdirecto
 </pre></div>
 
 
-<p>Next implement the creation of media entites. First we fetch the addressed entity set and convert the body of the request to a byte array. Remember the whole body of the request contains the content of the media entity.</p>
+<p>Next the creation of media entites is implemented. First we fetch the addressed entity set and convert the body of the request to a byte array. Remember the whole body of the request contains the content of the media entity.</p>
 <div class="codehilite"><pre><span class="nd">@Override</span>
 <span class="kd">public</span> <span class="kt">void</span> <span class="nf">createMediaEntity</span><span class="o">(</span><span class="n">ODataRequest</span> <span class="n">request</span><span class="o">,</span> <span class="n">ODataResponse</span> <span class="n">response</span><span class="o">,</span> <span class="n">UriInfo</span> <span class="n">uriInfo</span><span class="o">,</span>
         <span class="n">ContentType</span> <span class="n">requestFormat</span><span class="o">,</span> <span class="n">ContentType</span> <span class="n">responseFormat</span><span class="o">)</span>
@@ -365,14 +367,14 @@ This tutorial can be found in subdirecto
 
 <h2 id="run-the-implemented-service">Run the implemented service<a class="headerlink" href="#run-the-implemented-service" title="Permanent link">&para;</a></h2>
 <p>After building and deploying the project, we can invoke our OData service.</p>
-<p>Read media entity set
+<p>Read media entity set  <br />
 <strong>GET</strong> <a href="http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments">http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments</a></p>
-<p>Read media entity
+<p>Read media entity  <br />
 <strong>GET</strong> <a href="http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7)">http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7)</a></p>
-<p>Read media entity content
+<p>Read media entity content  <br />
 <strong>GET</strong> <a href="http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/$value">http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/$value</a></p>
-<p>Create a new Media Entity
-<strong>POST</strong> <a href="">http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments
+<p>Create a new Media Entity  <br />
+<strong>POST</strong> <a href="">http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments  <br />
 Content-Type: image/svg+xml</a></p>
 <div class="codehilite"><pre><span class="cp">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
 <span class="nt">&lt;svg</span> <span class="na">xmlns=</span><span class="s">&quot;http://www.w3.org/2000/svg&quot;</span> <span class="na">version=</span><span class="s">&quot;1.1&quot;</span> <span class="na">viewBox=</span><span class="s">&quot;0 0 100 100&quot;</span><span class="nt">&gt;</span>
@@ -383,15 +385,15 @@ Content-Type: image/svg+xml</a></p>
 </pre></div>
 
 
-<p>Update the content of a media entity
-<strong>PUT</strong>  <a href="http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/$value">http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/$value</a>
+<p>Update the content of a media entity  <br />
+<strong>PUT</strong>  <a href="http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/$value">http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7)/$value</a>  <br />
 Content-Type: text/plain</p>
 <div class="codehilite"><pre>Super super nice content
 </pre></div>
 
 
-<p>Update the properties of a media entity
-<strong>PUT</strong> <a href="http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7)">http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7)</a>
+<p>Update the properties of a media entity  <br />
+<strong>PUT</strong> <a href="http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7)">http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7)</a>  <br />
 Content-Type: application/json</p>
 <div class="codehilite"><pre><span class="p">{</span>
     <span class="nt">&quot;Name&quot;</span><span class="p">:</span> <span class="s2">&quot;New Name&quot;</span><span class="p">,</span>
@@ -400,9 +402,9 @@ Content-Type: application/json</p>
 </pre></div>
 
 
-<p>Delete a media entity
+<p>Delete a media entity  <br />
 <strong>DELETE</strong> <a href="http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7)">http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(f89dee73-af9f-4cd4-b330-db93c25ff3c7)</a></p>
-<p>Delete a media entity
+<p>Delete a media entity  <br />
 <strong>DELETE</strong> <a href="http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(db2d2186-1c29-4d1e-88ef-127f521b9c67)/$value">http://localhost:8080/DemoService-Media/DemoService.svc/Advertisments(db2d2186-1c29-4d1e-88ef-127f521b9c67)/$value</a></p>
 <h1 id="5-links">5. Links<a class="headerlink" href="#5-links" title="Permanent link">&para;</a></h1>
 <h3 id="tutorials">Tutorials<a class="headerlink" href="#tutorials" title="Permanent link">&para;</a></h3>