olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chr...@apache.org
Subject svn commit: r1694042 - /olingo/site/trunk/content/doc/odata4/tutorials/readep/tutorial_readep.mdtext
Date Tue, 04 Aug 2015 12:18:26 GMT
Author: chrish
Date: Tue Aug  4 12:18:26 2015
New Revision: 1694042

URL: http://svn.apache.org/r1694042
Log:
CMS commit to olingo by chrish

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=1694042&r1=1694041&r2=1694042&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 Aug 
4 12:18:26 2015
@@ -717,49 +717,49 @@ Again, we have the following 4 steps to
 
                  // 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);
+                 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());
-                  }
-     }
+                      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());
+                   }
+      }
 
 
 ## 4.2. Adapt the DemoServlet class



Mime
View raw message