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">"@odata.context"</span><span class="p">:</span>
<span class="s2">"$metadata#Products"</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"><</span><span
class="n">serviceroot</span><span class="o">>/</span>$<span
class="n">metadata</span>
+<div class="codehilite"><pre><span
class="nt"><serviceroot></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"><?xml version='1.0'
encoding='UTF-8'?></span>
<span class="nt"><edmx:Edmx</span> <span class="na">Version=</span><span
class="s">"4.0"</span> <span class="na">xmlns:edmx=</span><span
class="s">"http://docs.oasis-open.org/odata/ns/edmx"</span><span
class="nt">></span>
@@ -524,6 +529,7 @@ We have declared the main elements of an
<div class="codehilite"><pre>http://localhost:8080/DemoService/DemoService.svc/
+
:::json
{
"@odata.context" :
"http://localhost:8080/DemoService/DemoService.svc/$metadata",
@@ -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 > 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"><</span><span
class="n">UriResource</span><span class="o">></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>