Author: mibo
Date: Tue May 19 07:07:23 2015
New Revision: 1680191

URL: http://svn.apache.org/r1680191
Log:
Minor formating issues

Modified:
    olingo/site/trunk/content/doc/odata4/tutorials/readep/tutorial_readep.mdtext

Modified: 
olingo/site/trunk/content/doc/odata4/tutorials/readep/tutorial_readep.mdtext
URL: 
http://svn.apache.org/viewvc/olingo/site/trunk/content/doc/odata4/tutorials/readep/tutorial_readep.mdtext?rev=1680191&r1=1680190&r2=1680191&view=diff
==============================================================================
--- 
olingo/site/trunk/content/doc/odata4/tutorials/readep/tutorial_readep.mdtext 
(original)
+++ 
olingo/site/trunk/content/doc/odata4/tutorials/readep/tutorial_readep.mdtext 
Tue May 19 07:07:23 2015
@@ -204,6 +204,8 @@ Change the code such that it looks as fo
                ServiceMetadata edm = odata.createServiceMetadata(new 
DemoEdmProvider(), new ArrayList<EdmxReference>());
                ODataHttpHandler handler = odata.createHandler(edm);
                handler.register(new DemoEntityCollectionProcessor(storage));
+      } /* more code */
+    }
 
 
 
@@ -469,8 +471,6 @@ and he receives the following response i
     }
 
 
-
-
 **Steps**  
 The steps to be followed in the implementation of the `readEntity(...)` method 
are the same that we followed in the previous tutorial, when we implemented the 
`readEntityCollection(...)` method:
 
@@ -478,8 +478,8 @@ The steps to be followed in the implemen
     Check the UriInfo instance for information about which *EntityCollection* 
has been requested.  
     Note that in the code, we directly access the first segment of the URI and 
cast it to `UriResourceEntitySet`
 
-      :::java
-      UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) 
resourcePaths.get(0);
+        :::java
+        UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) 
resourcePaths.get(0);
 
     This is only possible, because in our current sample scenario we only 
support simple URIs. In a real productive OData service, which supports 
navigation and other OData V4 features, the code would be more complex.
 
@@ -661,65 +661,65 @@ Again, we have the following 4 steps to
     If this is the case, when configuring the response object, we don’t 
provide response body and header.
 
 
-    :::java
-    public void readPrimitive(ODataRequest request, ODataResponse response,
-                                               UriInfo uriInfo, ContentType 
responseFormat)
-                                               throws 
ODataApplicationException, SerializerException {
-
-       // 1. Retrieve info from URI
-       // 1.1. retrieve the info about the requested entity set
-       List<UriResource> resourceParts = uriInfo.getUriResourceParts();
-       // Note: only in our example we can rely that the first segment is the 
EntitySet
-       UriResourceEntitySet uriEntityset = (UriResourceEntitySet) 
resourceParts.get(0);
-       EdmEntitySet edmEntitySet = uriEntityset.getEntitySet();
-       // the key for the entity
-       List<UriParameter> keyPredicates = uriEntityset.getKeyPredicates();
-
-       // 1.2. retrieve the requested (Edm) property
-       // the last segment is the Property
-       UriResourceProperty uriProperty = (UriResourceProperty) 
resourceParts.get(resourceParts.size() -1);
-       EdmProperty edmProperty = uriProperty.getProperty();
-       String edmPropertyName = edmProperty.getName();
-       // in our example, we know we have only primitive types in our model
-       EdmPrimitiveType edmPropertyType = (EdmPrimitiveType) 
edmProperty.getType();
-
-       // 2. retrieve data from backend
-       // 2.1. retrieve the entity data, for which the property has to be read
-       Entity entity = storage.readEntityData(edmEntitySet, keyPredicates);
-       if (entity == null) { // Bad request
-            throw new ODataApplicationException("Entity not found",
-                    HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
-       }
-
-       // 2.2. retrieve the property data from the entity
-       Property property = entity.getProperty(edmPropertyName);
-       if (property == null) {
-               throw new ODataApplicationException("Property not found",
-                    HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
-       }
-
-       // 3. serialize
-       Object value = property.getValue();
-       if (value != null) {
-               // 3.1. configure the serializer
-               ODataFormat format = 
ODataFormat.fromContentType(responseFormat);
-               ODataSerializer serializer = odata.createSerializer(format);
-
-               ContextURL contextUrl = 
ContextURL.with().entitySet(edmEntitySet).navOrPropertyPath(edmPropertyName).build();
-               PrimitiveSerializerOptions options = 
PrimitiveSerializerOptions.with().contextURL(contextUrl).build();
-               // 3.2. serialize
-               SerializerResult serializerResult = 
serializer.primitive(edmPropertyType, property, options);
-               InputStream propertyStream = serializerResult.getContent();
-
-               //4. configure the response object
-               response.setContent(propertyStream);
-               response.setStatusCode(HttpStatusCode.OK.getStatusCode());
-               response.setHeader(HttpHeader.CONTENT_TYPE, 
responseFormat.toContentTypeString());
-       }else{
-               // in case there's no value for the property, we can skip the 
serialization
-                       
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
-       }
-    }
+        :::java
+        public void readPrimitive(ODataRequest request, ODataResponse response,
+                                                       UriInfo uriInfo, 
ContentType responseFormat)
+                                                       throws 
ODataApplicationException, SerializerException {
+
+               // 1. Retrieve info from URI
+               // 1.1. retrieve the info about the requested entity set
+               List<UriResource> resourceParts = uriInfo.getUriResourceParts();
+               // Note: only in our example we can rely that the first segment 
is the EntitySet
+               UriResourceEntitySet uriEntityset = (UriResourceEntitySet) 
resourceParts.get(0);
+               EdmEntitySet edmEntitySet = uriEntityset.getEntitySet();
+               // the key for the entity
+               List<UriParameter> keyPredicates = 
uriEntityset.getKeyPredicates();
+
+               // 1.2. retrieve the requested (Edm) property
+               // the last segment is the Property
+               UriResourceProperty uriProperty = (UriResourceProperty) 
resourceParts.get(resourceParts.size() -1);
+               EdmProperty edmProperty = uriProperty.getProperty();
+               String edmPropertyName = edmProperty.getName();
+               // in our example, we know we have only primitive types in our 
model
+               EdmPrimitiveType edmPropertyType = (EdmPrimitiveType) 
edmProperty.getType();
+
+               // 2. retrieve data from backend
+               // 2.1. retrieve the entity data, for which the property has to 
be read
+               Entity entity = storage.readEntityData(edmEntitySet, 
keyPredicates);
+               if (entity == null) { // Bad request
+                throw new ODataApplicationException("Entity not found",
+                        HttpStatusCode.NOT_FOUND.getStatusCode(), 
Locale.ENGLISH);
+               }
+
+               // 2.2. retrieve the property data from the entity
+               Property property = entity.getProperty(edmPropertyName);
+               if (property == null) {
+                       throw new ODataApplicationException("Property not 
found",
+                        HttpStatusCode.NOT_FOUND.getStatusCode(), 
Locale.ENGLISH);
+               }
+
+               // 3. serialize
+               Object value = property.getValue();
+               if (value != null) {
+                       // 3.1. configure the serializer
+                       ODataFormat format = 
ODataFormat.fromContentType(responseFormat);
+                       ODataSerializer serializer = 
odata.createSerializer(format);
+
+                       ContextURL contextUrl = 
ContextURL.with().entitySet(edmEntitySet).navOrPropertyPath(edmPropertyName).build();
+                       PrimitiveSerializerOptions options = 
PrimitiveSerializerOptions.with().contextURL(contextUrl).build();
+                       // 3.2. serialize
+                       SerializerResult serializerResult = 
serializer.primitive(edmPropertyType, property, options);
+                       InputStream propertyStream = 
serializerResult.getContent();
+
+                       //4. configure the response object
+                       response.setContent(propertyStream);
+                       
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+                       response.setHeader(HttpHeader.CONTENT_TYPE, 
responseFormat.toContentTypeString());
+               }else{
+                       // in case there's no value for the property, we can 
skip the serialization
+                               
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
+               }
+        }
 
 
 
@@ -773,8 +773,8 @@ In the next tutorial ([Part 3: Write](/d
 # 6. Links
 
 Tutorial OData V4 service part 1: [Read Entity 
Collection](/doc/odata4/tutorials/read/tutorial_read.html) | [sample project 
zip](/doc/odata4/tutorials/read/sample/DemoService_Tutorial_Read.zip)  
-Tutorial OData V4 service part 2: [Read Entity, Read Property (this 
page)](/doc/odata4/tutorials/readep/tutorial_readep.html) | [sample project 
zip](/doc/odata4/tutorials/readep/sample/DemoService_Tutorial_Readep.zip)
-Tutorial OData V4 service part 3: [Write (Create, Update, Delete 
Entity)](/doc/odata4/tutorials/write/tutorial_write.html) | [sample project 
zip](/doc/odata4/tutorials/write/sample/DemoService_Tutorial_Write.zip)
+Tutorial OData V4 service part 2: [Read Entity, Read Property (this 
page)](/doc/odata4/tutorials/readep/tutorial_readep.html) | [sample project 
zip](/doc/odata4/tutorials/readep/sample/DemoService_Tutorial_Readep.zip)  
+Tutorial OData V4 service part 3: [Write (Create, Update, Delete 
Entity)](/doc/odata4/tutorials/write/tutorial_write.html) | [sample project 
zip](/doc/odata4/tutorials/write/sample/DemoService_Tutorial_Write.zip)  
 
 
 OData specification: <http://odata.org/>


Reply via email to