You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/06/23 16:40:12 UTC

[27/39] olingo-odata4 git commit: [OLINGO-694] Minor code clean up in tutorials

[OLINGO-694] Minor code clean up in tutorials


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/431938c1
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/431938c1
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/431938c1

Branch: refs/heads/IEE754Compatible
Commit: 431938c1e6f513912fe0131ee4a220e20d9a474e
Parents: 93999d5
Author: Michael Bolz <mi...@sap.com>
Authored: Fri Jun 19 06:56:44 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Fri Jun 19 06:56:44 2015 +0200

----------------------------------------------------------------------
 .../java/myservice/mynamespace/util/Util.java   |  63 +--
 .../myservice/mynamespace/data/Storage.java     | 455 +++++++++----------
 .../mynamespace/service/DemoEdmProvider.java    |  10 +-
 .../service/DemoEntityProcessor.java            |  13 +-
 .../service/DemoPrimitiveProcessor.java         |  13 +-
 .../java/myservice/mynamespace/util/Util.java   |   3 +-
 6 files changed, 269 insertions(+), 288 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/431938c1/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/util/Util.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/util/Util.java b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/util/Util.java
index 16c7745..c21d352 100755
--- a/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/util/Util.java
+++ b/samples/tutorials/p2_readep/src/main/java/myservice/mynamespace/util/Util.java
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License. You may obtain a copy of the License at
- *
+ * 
  * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * 
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -37,39 +37,25 @@ import org.apache.olingo.server.api.uri.UriResource;
 import org.apache.olingo.server.api.uri.UriResourceEntitySet;
 
 public class Util {
+  
+  public static Entity findEntity(EdmEntityType edmEntityType, EntityCollection entitySet,
+                                  List<UriParameter> keyParams) throws ODataApplicationException {
 
-	public static EdmEntitySet getEdmEntitySet(UriInfoResource uriInfo) throws ODataApplicationException {
-		List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
-		 // To get the entity set we have to interpret all URI segments
-		if (!(resourcePaths.get(0) instanceof UriResourceEntitySet)) {
-			// Here we should interpret the whole URI but in this example we do not support navigation so we throw an exception
-			throw new ODataApplicationException("Invalid resource type for first segment.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(),Locale.ENGLISH);
-		}
-		
-		UriResourceEntitySet uriResource = (UriResourceEntitySet) resourcePaths.get(0);
-		
-		return uriResource.getEntitySet();
-	}
+    List<Entity> entityList = entitySet.getEntities();
 
-	
-	public static Entity findEntity(EdmEntityType edmEntityType, EntityCollection entitySet, List<UriParameter> keyParams) throws ODataApplicationException {
-		
-		List<Entity> entityList = entitySet.getEntities();
-		
-		// loop over all entities in order to find that one that matches all keys in request e.g. contacts(ContactID=1, CompanyID=1) 
-		for(Entity entity : entityList){
-			boolean foundEntity = entityMatchesAllKeys(edmEntityType, entity, keyParams);
-			if(foundEntity) {
-				return entity;
-			}
-		}
-		
-		return null;
-	}
-	
-	
-  public static boolean
-      entityMatchesAllKeys(EdmEntityType edmEntityType, Entity rt_entity, List<UriParameter> keyParams)
+    // loop over all entities in order to find that one that matches all keys in request
+    // e.g. contacts(ContactID=1, CompanyID=1)
+    for (Entity entity: entityList) {
+      boolean foundEntity = entityMatchesAllKeys(edmEntityType, entity, keyParams);
+      if (foundEntity) {
+        return entity;
+      }
+    }
+
+    return null;
+  }
+
+  public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams)
           throws ODataApplicationException {
 
     // loop over all keys
@@ -87,21 +73,20 @@ public class Util {
       Integer scale = edmKeyProperty.getScale();
       // get the EdmType in order to compare
       EdmType edmType = edmKeyProperty.getType();
-      // if(EdmType instanceof EdmPrimitiveType) // do we need this?
       EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmType;
 
       // Runtime data: the value of the current entity
       // don't need to check for null, this is done in olingo library
-      Object valueObject = rt_entity.getProperty(keyName).getValue();
+      Object valueObject = entity.getProperty(keyName).getValue();
 
       // now need to compare the valueObject with the keyText String
-      // this is done using type.valueToString
-      String valueAsString = null;
+      // this is done using the type.valueToString
+      String valueAsString;
       try {
         valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode);
       } catch (EdmPrimitiveTypeException e) {
-        throw new ODataApplicationException("Failed to retrieve String value",
-						HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ENGLISH, e);
+        throw new ODataApplicationException("Failed to retrieve String value", HttpStatusCode.INTERNAL_SERVER_ERROR
+                .getStatusCode(), Locale.ENGLISH, e);
       }
 
       if (valueAsString == null) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/431938c1/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/data/Storage.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/data/Storage.java b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/data/Storage.java
index 3af3260..ad5dd71 100755
--- a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/data/Storage.java
+++ b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/data/Storage.java
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License. You may obtain a copy of the License at
- *
+ * 
  * http://www.apache.org/licenses/LICENSE-2.0
- *
+ * 
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -38,235 +38,226 @@ import java.util.Locale;
 
 public class Storage {
 
-	
-	private List<Entity> productList;
-	
-	
-	public Storage() {
-		
-		productList = new ArrayList<Entity>();
-		initSampleData();
-	}
-
-	
-	
-	/* PUBLIC FACADE */
-	
-	
-	public EntityCollection readEntitySetData(EdmEntitySet edmEntitySet)throws ODataApplicationException{
-		
-		// actually, this is only required if we have more than one Entity Sets
-		if(edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)){
-			return getProducts();
-		}
-		
-		return null;
-	}
-	
-	
-	public Entity readEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams) throws ODataApplicationException{
-		
-		EdmEntityType edmEntityType = edmEntitySet.getEntityType();
-		
-		// actually, this is only required if we have more than one Entity Type
-		if(edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)){
-			return getProduct(edmEntityType, keyParams);
-		}
-		
-		return null;
-	}
-
-	
-	public Entity createEntityData(EdmEntitySet edmEntitySet, Entity entityToCreate) {
-		
-		EdmEntityType edmEntityType = edmEntitySet.getEntityType();
-		
-		// actually, this is only required if we have more than one Entity Type
-		if(edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)){
-			return createProduct(edmEntityType, entityToCreate);
-		}
-		
-		return null;
-	}
-
-
-	/**
-	 * This method is invoked for PATCH or PUT requests
-	 * */
-	public void updateEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams, Entity updateEntity, HttpMethod httpMethod) throws ODataApplicationException{
-		
-		EdmEntityType edmEntityType = edmEntitySet.getEntityType();
-
-		// actually, this is only required if we have more than one Entity Type
-		if(edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)){
-			updateProduct(edmEntityType, keyParams, updateEntity, httpMethod);
-		}
-	}
-	
-
-	public void deleteEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams) throws ODataApplicationException{
-		
-		EdmEntityType edmEntityType = edmEntitySet.getEntityType();
-		
-		// actually, this is only required if we have more than one Entity Type
-		if(edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)){
-			deleteProduct(edmEntityType, keyParams);
-		}
-	}
-
-	
-	
-	/*  INTERNAL */
-	
-	private EntityCollection getProducts(){
-		EntityCollection retEntitySet = new EntityCollection();
-		
-		for(Entity productEntity : this.productList){
-			   retEntitySet.getEntities().add(productEntity);
-		}
-		
-		return retEntitySet;
-	}
-	
-	
-	private Entity getProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams) throws ODataApplicationException{ 
-		
-		// the list of entities at runtime
-		EntityCollection entitySet = getProducts();
-		
-		/*  generic approach  to find the requested entity */
-		Entity requestedEntity = Util.findEntity(edmEntityType, entitySet, keyParams);
-		
-	
-		if(requestedEntity == null){
-			// this variable is null if our data doesn't contain an entity for the requested key
-			// Throw suitable exception
-			throw new ODataApplicationException("Entity for requested key doesn't exist",
+  private List<Entity> productList;
+
+  public Storage() {
+    productList = new ArrayList<Entity>();
+    initSampleData();
+  }
+
+  /* PUBLIC FACADE */
+
+  public EntityCollection readEntitySetData(EdmEntitySet edmEntitySet) throws ODataApplicationException {
+
+    // actually, this is only required if we have more than one Entity Sets
+    if (edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)) {
+      return getProducts();
+    }
+
+    return null;
+  }
+
+  public Entity readEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams)
+      throws ODataApplicationException {
+
+    EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+
+    // actually, this is only required if we have more than one Entity Type
+    if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
+      return getProduct(edmEntityType, keyParams);
+    }
+
+    return null;
+  }
+
+  public Entity createEntityData(EdmEntitySet edmEntitySet, Entity entityToCreate) {
+
+    EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+
+    // actually, this is only required if we have more than one Entity Type
+    if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
+      return createProduct(edmEntityType, entityToCreate);
+    }
+
+    return null;
+  }
+
+  /**
+   * This method is invoked for PATCH or PUT requests
+   * */
+  public void updateEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams, Entity updateEntity,
+      HttpMethod httpMethod) throws ODataApplicationException {
+
+    EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+
+    // actually, this is only required if we have more than one Entity Type
+    if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
+      updateProduct(edmEntityType, keyParams, updateEntity, httpMethod);
+    }
+  }
+
+  public void deleteEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams)
+      throws ODataApplicationException {
+
+    EdmEntityType edmEntityType = edmEntitySet.getEntityType();
+
+    // actually, this is only required if we have more than one Entity Type
+    if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
+      deleteProduct(edmEntityType, keyParams);
+    }
+  }
+
+  /* INTERNAL */
+
+  private EntityCollection getProducts() {
+    EntityCollection retEntitySet = new EntityCollection();
+
+    for (Entity productEntity : this.productList) {
+      retEntitySet.getEntities().add(productEntity);
+    }
+
+    return retEntitySet;
+  }
+
+  private Entity getProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams)
+					throws ODataApplicationException {
+
+    // the list of entities at runtime
+    EntityCollection entitySet = getProducts();
+
+    /* generic approach to find the requested entity */
+    Entity requestedEntity = Util.findEntity(edmEntityType, entitySet, keyParams);
+
+    if (requestedEntity == null) {
+      // this variable is null if our data doesn't contain an entity for the requested key
+      // Throw suitable exception
+      throw new ODataApplicationException("Entity for requested key doesn't exist",
           HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
-		}
-		
-		return requestedEntity;
-	}
-		
-	
-	private Entity createProduct(EdmEntityType edmEntityType, Entity entity) {
-		
-		// the ID of the newly created product entity is generated automatically
-		int newId = 1;
-		while (productIdExists(newId)){
-			newId++;
-		}
-		
-		Property idProperty = entity.getProperty("ID");
-		if(idProperty != null){
-			idProperty.setValue(ValueType.PRIMITIVE, new Integer(newId));
-		}else{
-			// as of OData v4 spec, the key property can be omitted from the POST request body
-			entity.getProperties().add(new Property(null, "ID", ValueType.PRIMITIVE, newId));
-		}
-		
-		this.productList.add(entity);
-
-		return entity;
-		
-	}
-
-
-	private boolean productIdExists(int id){
-		
-		for(Entity entity : this.productList){
-			Integer existingID = (Integer) entity.getProperty("ID").getValue();
-			if(existingID.intValue() == id){
-				return true;
-			}
-		}
-		
-		return false;
-	}
-	
-	
-	private void updateProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams, Entity entity, HttpMethod httpMethod) throws ODataApplicationException{
-		
-		Entity productEntity = getProduct(edmEntityType, keyParams);
-		if(productEntity == null){
-			throw new ODataApplicationException("Entity not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
-		}
-		
-		// loop over all properties and replace the values with the values of the given payload
-		// Note: ignoring ComplexType, as we don't have it in our odata model
-		List<Property> existingProperties = productEntity.getProperties();
-		for(Property existingProp : existingProperties){
-			String propName = existingProp.getName();
-			
-			// ignore the key properties, they aren't updateable
-			if(isKey(edmEntityType, propName)){
-				continue;
-			}
-			
-			Property updateProperty = entity.getProperty(propName); 
-			// the request payload might not consider ALL properties, so it can be null
-			if(updateProperty == null){
-				// if a property has NOT been added to the request payload
-				// depending on the HttpMethod, our behavior is different
-				if(httpMethod.equals(HttpMethod.PATCH)){
-					// as of the OData spec, in case of PATCH, the existing property is not touched
-					continue; // do nothing
-				}else if(httpMethod.equals(HttpMethod.PUT)){
-					// as of the OData spec, in case of PUT, the existing property is set to null (or to default value)
-					existingProp.setValue(existingProp.getValueType(), null);
-					continue;
-				}
-			}
-			
-			// change the value of the properties 
-			existingProp.setValue(existingProp.getValueType(), updateProperty.getValue());
-		}
-	}
-
-	private void deleteProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams) throws ODataApplicationException{ 
-		
-		Entity productEntity = getProduct(edmEntityType, keyParams);
-		if(productEntity == null){
-			throw new ODataApplicationException("Entity not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
-		}
-		
-		this.productList.remove(productEntity);
-	}
-	
-	
-	
-	/* HELPER */
-	
-	
-	private boolean isKey(EdmEntityType edmEntityType, String propertyName){
-		List<EdmKeyPropertyRef> keyPropertyRefs = edmEntityType.getKeyPropertyRefs();
-		for(EdmKeyPropertyRef propRef : keyPropertyRefs){
-			String keyPropertyName = propRef.getName();
-			if(keyPropertyName.equals(propertyName)){
-				return true;
-			}
-		}
-		return false;
-	}
-
-	
-	private void initSampleData(){
-
-		// add some sample product entities
-		productList.add(new Entity()
-			.addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 1))
-			.addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Notebook Basic 15"))
-			.addProperty(new Property(null, "Description", ValueType.PRIMITIVE, "Notebook Basic, 1.7GHz - 15 XGA - 1024MB DDR2 SDRAM - 40GB")));
-
-		productList.add(new Entity()
-			.addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 2))
-			.addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "1UMTS PDA"))
-			.addProperty(new Property(null, "Description", ValueType.PRIMITIVE, "Ultrafast 3G UMTS/HSDPA Pocket PC, supports GSM network")));
-
-		productList.add(new Entity()
-			.addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 3))
-			.addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Ergo Screen"))
-			.addProperty(new Property(null, "Description", ValueType.PRIMITIVE, "19 Optimum Resolution 1024 x 768 @ 85Hz, resolution 1280 x 960")));
-
-	}
+    }
+
+    return requestedEntity;
+  }
+
+  private Entity createProduct(EdmEntityType edmEntityType, Entity entity) {
+
+    // the ID of the newly created product entity is generated automatically
+    int newId = 1;
+    while (productIdExists(newId)) {
+      newId++;
+    }
+
+    Property idProperty = entity.getProperty("ID");
+    if (idProperty != null) {
+      idProperty.setValue(ValueType.PRIMITIVE, new Integer(newId));
+    } else {
+      // as of OData v4 spec, the key property can be omitted from the POST request body
+      entity.getProperties().add(new Property(null, "ID", ValueType.PRIMITIVE, newId));
+    }
+
+    this.productList.add(entity);
+
+    return entity;
+
+  }
+
+  private boolean productIdExists(int id) {
+
+    for (Entity entity : this.productList) {
+      Integer existingID = (Integer) entity.getProperty("ID").getValue();
+      if (existingID.intValue() == id) {
+        return true;
+      }
+    }
+
+    return false;
+  }
+
+  private void updateProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams, Entity entity,
+      HttpMethod httpMethod) throws ODataApplicationException {
+
+    Entity productEntity = getProduct(edmEntityType, keyParams);
+    if (productEntity == null) {
+      throw new ODataApplicationException("Entity not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
+    }
+
+    // loop over all properties and replace the values with the values of the given payload
+    // Note: ignoring ComplexType, as we don't have it in our odata model
+    List<Property> existingProperties = productEntity.getProperties();
+    for (Property existingProp : existingProperties) {
+      String propName = existingProp.getName();
+
+      // ignore the key properties, they aren't updateable
+      if (isKey(edmEntityType, propName)) {
+        continue;
+      }
+
+      Property updateProperty = entity.getProperty(propName);
+      // the request payload might not consider ALL properties, so it can be null
+      if (updateProperty == null) {
+        // if a property has NOT been added to the request payload
+        // depending on the HttpMethod, our behavior is different
+        if (httpMethod.equals(HttpMethod.PATCH)) {
+          // as of the OData spec, in case of PATCH, the existing property is not touched
+          continue; // do nothing
+        } else if (httpMethod.equals(HttpMethod.PUT)) {
+          // as of the OData spec, in case of PUT, the existing property is set to null (or to default value)
+          existingProp.setValue(existingProp.getValueType(), null);
+          continue;
+        }
+      }
+
+      // change the value of the properties
+      existingProp.setValue(existingProp.getValueType(), updateProperty.getValue());
+    }
+  }
+
+  private void deleteProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams)
+      throws ODataApplicationException {
+
+    Entity productEntity = getProduct(edmEntityType, keyParams);
+    if (productEntity == null) {
+      throw new ODataApplicationException("Entity not found", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
+    }
+
+    this.productList.remove(productEntity);
+  }
+
+  /* HELPER */
+
+  private boolean isKey(EdmEntityType edmEntityType, String propertyName) {
+    List<EdmKeyPropertyRef> keyPropertyRefs = edmEntityType.getKeyPropertyRefs();
+    for (EdmKeyPropertyRef propRef : keyPropertyRefs) {
+      String keyPropertyName = propRef.getName();
+      if (keyPropertyName.equals(propertyName)) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  private void initSampleData() {
+
+    // add some sample product entities
+    productList.add(new Entity()
+        .addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 1))
+        .addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Notebook Basic 15"))
+        .addProperty(
+            new Property(null, "Description", ValueType.PRIMITIVE,
+                "Notebook Basic, 1.7GHz - 15 XGA - 1024MB DDR2 SDRAM - 40GB")));
+
+    productList.add(new Entity()
+        .addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 2))
+        .addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "1UMTS PDA"))
+        .addProperty(
+            new Property(null, "Description", ValueType.PRIMITIVE,
+                "Ultrafast 3G UMTS/HSDPA Pocket PC, supports GSM network")));
+
+    productList.add(new Entity()
+        .addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 3))
+        .addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Ergo Screen"))
+        .addProperty(
+            new Property(null, "Description", ValueType.PRIMITIVE,
+                "19 Optimum Resolution 1024 x 768 @ 85Hz, resolution 1280 x 960")));
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/431938c1/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
index 6a64b31..f842af8 100755
--- a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
+++ b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
@@ -42,7 +42,6 @@ import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
  */
 public class DemoEdmProvider extends CsdlAbstractEdmProvider {
 
-
   // Service Namespace
   public static final String NAMESPACE = "OData.Demo";
 
@@ -87,9 +86,12 @@ public class DemoEdmProvider extends CsdlAbstractEdmProvider {
     if(entityTypeName.equals(ET_PRODUCT_FQN)){
 
       //create EntityType properties
-      CsdlProperty id = new CsdlProperty().setName("ID").setType(EdmPrimitiveTypeKind.Int32.getFullQualifiedName());
-      CsdlProperty name = new CsdlProperty().setName("Name").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
-      CsdlProperty  description = new CsdlProperty().setName("Description").setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
+      CsdlProperty id = new CsdlProperty().setName("ID")
+              .setType(EdmPrimitiveTypeKind.Int32.getFullQualifiedName());
+      CsdlProperty name = new CsdlProperty().setName("Name")
+              .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
+      CsdlProperty  description = new CsdlProperty().setName("Description")
+              .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
 
       // create CsdlPropertyRef for Key element
       CsdlPropertyRef propertyRef = new CsdlPropertyRef();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/431938c1/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
index 10d5023..35d4203 100755
--- a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
+++ b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
@@ -56,13 +56,11 @@ public class DemoEntityProcessor implements EntityProcessor {
 	private OData odata;
 	private Storage storage;
 	private ServiceMetadata serviceMetadata;
-	
-	
+
 	public DemoEntityProcessor(Storage storage) {
 		this.storage = storage;
 	}
 
-	
 	public void init(OData odata, ServiceMetadata serviceMetadata) {
 		this.odata = odata;
 		this.serviceMetadata = serviceMetadata;
@@ -111,7 +109,8 @@ public class DemoEntityProcessor implements EntityProcessor {
 			"Description":"17 Optimum Resolution 1024 x 768 @ 85Hz, resolution 1280 x 960"
 		}
 	 * */
-	public void createEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat, ContentType responseFormat) 
+	public void createEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
+													 ContentType requestFormat, ContentType responseFormat)
 				throws ODataApplicationException, DeserializerException, SerializerException {
 		
 		// 1. Retrieve the entity type from the URI 
@@ -143,7 +142,8 @@ public class DemoEntityProcessor implements EntityProcessor {
 	}
 
 	
-	public void updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat, ContentType responseFormat) 
+	public void updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
+                           ContentType requestFormat, ContentType responseFormat)
 							throws ODataApplicationException, DeserializerException, SerializerException {
 		
 		// 1. Retrieve the entity set which belongs to the requested entity 
@@ -171,7 +171,8 @@ public class DemoEntityProcessor implements EntityProcessor {
 	}
 
 	
-	public void deleteEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo) throws ODataApplicationException {
+	public void deleteEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo)
+          throws ODataApplicationException {
 		
 		// 1. Retrieve the entity set which belongs to the requested entity 
 		List<UriResource> resourcePaths = uriInfo.getUriResourceParts();

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/431938c1/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
index ec4ba3a..ccf6d2b 100755
--- a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
+++ b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
@@ -63,7 +63,6 @@ public class DemoPrimitiveProcessor implements PrimitiveProcessor {
 		this.odata = odata;
 	}
 	
-
 	/*
 	 * In our example, the URL would be: http://localhost:8080/DemoService/DemoService.svc/Products(1)/Name
 	 * and the response:
@@ -97,13 +96,15 @@ public class DemoPrimitiveProcessor implements PrimitiveProcessor {
 		// 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);
+			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);
+			throw new ODataApplicationException("Property not found",
+              HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
 		}		
 		
 		// 3. serialize
@@ -132,12 +133,14 @@ public class DemoPrimitiveProcessor implements PrimitiveProcessor {
 	 * These processor methods are not handled in this tutorial 
 	 *
 	 * */
-	public void updatePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat, ContentType responseFormat)
+	public void updatePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo,
+                              ContentType requestFormat, ContentType responseFormat)
 								throws ODataApplicationException, DeserializerException, SerializerException {
 		throw new ODataApplicationException("Not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
 	}
 
-	public void deletePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo) throws ODataApplicationException {
+	public void deletePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo)
+          throws ODataApplicationException {
 		throw new ODataApplicationException("Not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
 	}
 }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/431938c1/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/util/Util.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/util/Util.java b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/util/Util.java
index 8ad19a0..035cc7b 100755
--- a/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/util/Util.java
+++ b/samples/tutorials/p3_write/src/main/java/myservice/mynamespace/util/Util.java
@@ -71,8 +71,7 @@ public class Util {
     return null;
   }
 
-  public static boolean
-      entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams)
+  public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity entity, List<UriParameter> keyParams)
           throws ODataApplicationException {
 
     // loop over all keys