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/04/28 14:47:36 UTC

svn commit: r949487 - in /websites/staging/olingo/trunk/content: ./ doc/odata4/tutorials/read/tutorial_read.html

Author: buildbot
Date: Tue Apr 28 12:47:36 2015
New Revision: 949487

Log:
Staging update by buildbot for olingo

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

Propchange: websites/staging/olingo/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Tue Apr 28 12:47:36 2015
@@ -1 +1 @@
-1676515
+1676519

Modified: websites/staging/olingo/trunk/content/doc/odata4/tutorials/read/tutorial_read.html
==============================================================================
--- websites/staging/olingo/trunk/content/doc/odata4/tutorials/read/tutorial_read.html (original)
+++ websites/staging/olingo/trunk/content/doc/odata4/tutorials/read/tutorial_read.html Tue Apr 28 12:47:36 2015
@@ -103,7 +103,10 @@ Furthermore, for building with maven, we
 <p>This is how our working directory in Eclipse will look like:</p>
 <p><img alt="projectLayout" src="EclipseProjectTree.png" title="The project layout" /></p>
 <p>At the end of this tutorial, you’ll have written an OData service and you’ll be able to invoke the following URL in a browser:</p>
-<p>http://localhost:8080/DemoService/DemoService.svc/Products</p>
+<div class="codehilite"><pre>http://localhost:8080/DemoService/DemoService.svc/Products
+</pre></div>
+
+
 <p>And the browser will display the following little collection of data:</p>
 <div class="codehilite"><pre><span class="p">{</span>
   <span class="nt">&quot;@odata.context&quot;</span><span class="p">:</span> <span class="s2">&quot;$metadata#Products&quot;</span><span class="p">,</span>
@@ -294,7 +297,7 @@ From context menu on project node, choos
 <p>According to the OData specification, an OData service has to declare its structure in the so-called <em>metadata document</em>.
 This document defines the contract, such that the user of the service knows which requests can be executed, the structure of the result and how the service can be navigated.</p>
 <p>The metadata document can be invoked via the following URI:</p>
-<div class="codehilite"><pre><span class="o">&lt;</span><span class="n">serviceroot</span><span class="o">&gt;/</span>$<span class="n">metadata</span>
+<div class="codehilite"><pre><span class="nt">&lt;serviceroot&gt;</span>/$metadata
 </pre></div>
 
 
@@ -498,6 +501,8 @@ We have declared the main elements of an
 <p>In our example:</p>
 <div class="codehilite"><pre>http://localhost:8080/DemoService/DemoService.svc/$metadata
 
+
+
 :::xml
 <span class="cp">&lt;?xml version=&#39;1.0&#39; encoding=&#39;UTF-8&#39;?&gt;</span>
 <span class="nt">&lt;edmx:Edmx</span> <span class="na">Version=</span><span class="s">&quot;4.0&quot;</span> <span class="na">xmlns:edmx=</span><span class="s">&quot;http://docs.oasis-open.org/odata/ns/edmx&quot;</span><span class="nt">&gt;</span>
@@ -524,6 +529,7 @@ We have declared the main elements of an
 <div class="codehilite"><pre>http://localhost:8080/DemoService/DemoService.svc/
 
 
+
 :::json
 {
   &quot;@odata.context&quot; : &quot;http://localhost:8080/DemoService/DemoService.svc/$metadata&quot;,
@@ -606,30 +612,28 @@ Here we have to understand that this <em
 <p>The method signature:</p>
 <p>The “request” parameter contains raw HTTP information. It is typically used for creation scenario, where a request body is sent along with the request.</p>
 <p>With the second parameter, the “response” object is passed to our method in order to carry the response data. So here we have to set the response body, along with status code and content-type header.</p>
-<p>The third parameter, the “uriInfo”, contains information about the relevant part of the URL. This means, the segments starting after the service name.<br />
-Example:
-If the user calls the following URL:<br />
-http://localhost:8080/DemoService/DemoService.svc/Products<br />
-The <em>readEntityCollection</em> method is invoked and the <em>uriInfo</em> object contains one segment: “Products”<br />
+<p>The third parameter, the “uriInfo”, contains information about the relevant part of the URL. This means, the segments starting after the service name.  </p>
+<p>Example:<br />
 If the user calls the following URL:<br />
-http://localhost:8080/DemoService/DemoService.svc/Products?$filter=ID eq 1<br />
+<code>http://localhost:8080/DemoService/DemoService.svc/Products</code><br />
+The <em>readEntityCollection</em> method is invoked and the <em>uriInfo</em> object contains one segment: “Products”  </p>
+<p>If the user calls the following URL:<br />
+<code>http://localhost:8080/DemoService/DemoService.svc/Products?$filter=ID eq 1</code><br />
 Then the <em>readEntityCollection</em> method is invoked and the <em>uriInfo</em> contains the information about the entity set and furthermore the system query option $filter and its value.</p>
 <p>The last parameter, the “responseFormat”, contains information about the content type that is requested by the user.<br />
-This means that the user has the choice to receive the data either in XML or in JSON.<br />
-Example:<br />
+This means that the user has the choice to receive the data either in XML or in JSON.  </p>
+<p>Example:<br />
 If the user calls the following URL:<br />
-http://localhost:8080/DemoService/DemoService.svc/Products?$format=application/json;odata.metadata=minimal<br />
-then the content type is:<br />
-application/json;odata.metadata=minimal<br />
+<code>http://localhost:8080/DemoService/DemoService.svc/Products?$format=application/json;odata.metadata=minimal</code></p>
+<p>then the content type is:<br />
+<code>application/json;odata.metadata=minimal</code><br />
 which means that the payload is formatted in JSON (like it is shown in the introduction section of this tutorial)</p>
-<blockquote>
-<p>Note:
+<p><strong>Note:</strong>
 The content type can as well be specified via the following request header<br />
 Accept: application/json;odata.metadata=minimal<br />
 In this case as well, our readEntityCollection() method will be called with the parameter responseFormat containing the content type &gt; information.</p>
-<p>Note:
+<p><strong>Note:</strong>
 If the user doesn’t specify any content type, then the default is JSON.</p>
-</blockquote>
 <p>Why is this parameter needed?<br />
 Because the <em>readEntityCollection</em> method is supposed to deliver the data in the format that is requested by the user. We’ll use this parameter when creating a serializer based on it.</p>
 <p>The steps for implementating the method <em>readEntityCollection</em> are:</p>
@@ -652,9 +656,9 @@ Because the <em>readEntityCollection</em
 <p>Configure the response<br />
   The response object has been passed to us in the method signature. We use it to set the serialized data (the <em>InputStream</em> object).<br />
   Furthermore, we have to set the HTTP status code, which means that we have the opportunity to do proper error handling.<br />
-  And finally we have to set the content type.</p>
+  And finally we have to set the content type.  </p>
 <p>:::java
-public void readEntityCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat)
+  public void readEntityCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat)
                      throws ODataApplicationException, SerializerException {</p>
 <div class="codehilite"><pre><span class="c1">// 1st retrieve the requested EntitySet from the uriInfo (representation of the parsed URI)</span>
 <span class="n">List</span><span class="o">&lt;</span><span class="n">UriResource</span><span class="o">&gt;</span> <span class="n">resourcePaths</span> <span class="o">=</span> <span class="n">uriInfo</span><span class="p">.</span><span class="n">getUriResourceParts</span><span class="p">();</span>