You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2015/07/09 08:34:10 UTC
olingo-odata4 git commit: [OLINGO-713] Code clean up and format
Repository: olingo-odata4
Updated Branches:
refs/heads/master 3a103d534 -> 8960fdb5d
[OLINGO-713] Code clean up and format
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/8960fdb5
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/8960fdb5
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/8960fdb5
Branch: refs/heads/master
Commit: 8960fdb5d16dd53b98a96ea58cd75211eda93441
Parents: 3a103d5
Author: Michael Bolz <mi...@sap.com>
Authored: Thu Jul 9 08:33:58 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Thu Jul 9 08:33:58 2015 +0200
----------------------------------------------------------------------
.../myservice/mynamespace/data/Storage.java | 92 +++++++-------
.../mynamespace/service/DemoEdmProvider.java | 43 +++----
.../service/DemoEntityCollectionProcessor.java | 47 ++++---
.../service/DemoEntityProcessor.java | 64 ++++------
.../service/DemoPrimitiveProcessor.java | 42 +++----
.../java/myservice/mynamespace/util/Util.java | 126 ++++++++++---------
.../myservice/mynamespace/web/DemoServlet.java | 17 ++-
7 files changed, 202 insertions(+), 229 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8960fdb5/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/data/Storage.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/data/Storage.java b/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/data/Storage.java
index 9db188c..2034fe6 100755
--- a/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/data/Storage.java
+++ b/samples/tutorials/p4_navigation/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
@@ -39,7 +39,6 @@ public class Storage {
private List<Entity> productList;
private List<Entity> categoryList;
-
public Storage() {
productList = new ArrayList<Entity>();
@@ -55,142 +54,135 @@ public class Storage {
public EntityCollection readEntitySetData(EdmEntitySet edmEntitySet) {
EntityCollection entitySet = null;
- if(edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)){
+ if (edmEntitySet.getName().equals(DemoEdmProvider.ES_PRODUCTS_NAME)) {
entitySet = getProducts();
- }else if(edmEntitySet.getName().equals(DemoEdmProvider.ES_CATEGORIES_NAME)){
+ } else if (edmEntitySet.getName().equals(DemoEdmProvider.ES_CATEGORIES_NAME)) {
entitySet = getCategories();
}
return entitySet;
}
-
public Entity readEntityData(EdmEntitySet edmEntitySet, List<UriParameter> keyParams) {
Entity entity = null;
EdmEntityType edmEntityType = edmEntitySet.getEntityType();
- if(edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)){
+ if (edmEntityType.getName().equals(DemoEdmProvider.ET_PRODUCT_NAME)) {
entity = getProduct(edmEntityType, keyParams);
- }else if(edmEntityType.getName().equals(DemoEdmProvider.ET_CATEGORY_NAME)){
+ } else if (edmEntityType.getName().equals(DemoEdmProvider.ET_CATEGORY_NAME)) {
entity = getCategory(edmEntityType, keyParams);
}
return entity;
}
-
- // Navigation
+ // Navigation
public Entity getRelatedEntity(Entity entity, EdmEntityType relatedEntityType) {
EntityCollection collection = getRelatedEntityCollection(entity, relatedEntityType);
- if(collection.getEntities().isEmpty()) {
+ if (collection.getEntities().isEmpty()) {
return null;
}
return collection.getEntities().get(0);
}
-
public Entity getRelatedEntity(Entity entity, EdmEntityType relatedEntityType, List<UriParameter> keyPredicates) {
EntityCollection relatedEntities = getRelatedEntityCollection(entity, relatedEntityType);
return Util.findEntity(relatedEntityType, relatedEntities, keyPredicates);
}
-
public EntityCollection getRelatedEntityCollection(Entity sourceEntity, EdmEntityType targetEntityType) {
EntityCollection navigationTargetEntityCollection = new EntityCollection();
FullQualifiedName relatedEntityFqn = targetEntityType.getFullQualifiedName();
String sourceEntityFqn = sourceEntity.getType();
- if(sourceEntityFqn.equals(DemoEdmProvider.ET_PRODUCT_FQN.getFullQualifiedNameAsString())
- && relatedEntityFqn.equals(DemoEdmProvider.ET_CATEGORY_FQN)){
+ if (sourceEntityFqn.equals(DemoEdmProvider.ET_PRODUCT_FQN.getFullQualifiedNameAsString())
+ && relatedEntityFqn.equals(DemoEdmProvider.ET_CATEGORY_FQN)) {
// relation Products->Category (result all categories)
int productID = (Integer) sourceEntity.getProperty("ID").getValue();
- if(productID == 1 || productID == 2) {
+ if (productID == 1 || productID == 2) {
navigationTargetEntityCollection.getEntities().add(categoryList.get(0));
- } else if(productID == 3 || productID == 4) {
+ } else if (productID == 3 || productID == 4) {
navigationTargetEntityCollection.getEntities().add(categoryList.get(1));
- } else if(productID == 5 || productID == 6) {
+ } else if (productID == 5 || productID == 6) {
navigationTargetEntityCollection.getEntities().add(categoryList.get(2));
}
- }else if(sourceEntityFqn.equals(DemoEdmProvider.ET_CATEGORY_FQN.getFullQualifiedNameAsString())
- && relatedEntityFqn.equals(DemoEdmProvider.ET_PRODUCT_FQN)){
+ } else if (sourceEntityFqn.equals(DemoEdmProvider.ET_CATEGORY_FQN.getFullQualifiedNameAsString())
+ && relatedEntityFqn.equals(DemoEdmProvider.ET_PRODUCT_FQN)) {
// relation Category->Products (result all products)
int categoryID = (Integer) sourceEntity.getProperty("ID").getValue();
- if(categoryID == 1){
- navigationTargetEntityCollection.getEntities().addAll(productList.subList(0, 2));// the first 2 products are notebooks
- }else if(categoryID == 2){
- navigationTargetEntityCollection.getEntities().addAll(productList.subList(2, 4));// the next 2 products are organizers
- }else if(categoryID == 3){
- navigationTargetEntityCollection.getEntities().addAll(productList.subList(4, 6));// the first 2 products are monitors
+ if (categoryID == 1) {
+ // the first 2 products are notebooks
+ navigationTargetEntityCollection.getEntities().addAll(productList.subList(0, 2));
+ } else if (categoryID == 2) {
+ // the next 2 products are organizers
+ navigationTargetEntityCollection.getEntities().addAll(productList.subList(2, 4));
+ } else if (categoryID == 3) {
+ // the first 2 products are monitors
+ navigationTargetEntityCollection.getEntities().addAll(productList.subList(4, 6));
}
}
- if(navigationTargetEntityCollection.getEntities().isEmpty()){
+ if (navigationTargetEntityCollection.getEntities().isEmpty()) {
return null;
}
return navigationTargetEntityCollection;
}
+ /* INTERNAL */
- /* INTERNAL */
-
- private EntityCollection getProducts(){
+ private EntityCollection getProducts() {
EntityCollection retEntitySet = new EntityCollection();
- for(Entity productEntity : this.productList){
- retEntitySet.getEntities().add(productEntity);
+ for (Entity productEntity : this.productList) {
+ retEntitySet.getEntities().add(productEntity);
}
return retEntitySet;
}
-
private Entity getProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams) {
// the list of entities at runtime
EntityCollection entityCollection = getProducts();
- /* generic approach to find the requested entity */
+ /* generic approach to find the requested entity */
return Util.findEntity(edmEntityType, entityCollection, keyParams);
}
-
- private EntityCollection getCategories(){
+ private EntityCollection getCategories() {
EntityCollection entitySet = new EntityCollection();
- for(Entity categoryEntity : this.categoryList){
- entitySet.getEntities().add(categoryEntity);
+ for (Entity categoryEntity : this.categoryList) {
+ entitySet.getEntities().add(categoryEntity);
}
return entitySet;
}
-
private Entity getCategory(EdmEntityType edmEntityType, List<UriParameter> keyParams) {
// the list of entities at runtime
EntityCollection entitySet = getCategories();
- /* generic approach to find the requested entity */
+ /* generic approach to find the requested entity */
return Util.findEntity(edmEntityType, entitySet, keyParams);
}
-
-
/* HELPER */
- private void initProductSampleData(){
+ private void initProductSampleData() {
Entity entity = new Entity();
entity.addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 1));
entity.addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Notebook Basic 15"));
entity.addProperty(new Property(null, "Description", ValueType.PRIMITIVE,
- "Notebook Basic, 1.7GHz - 15 XGA - 1024MB DDR2 SDRAM - 40GB"));
+ "Notebook Basic, 1.7GHz - 15 XGA - 1024MB DDR2 SDRAM - 40GB"));
entity.setType(DemoEdmProvider.ET_PRODUCT_FQN.getFullQualifiedNameAsString());
productList.add(entity);
@@ -198,7 +190,7 @@ public class Storage {
entity.addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 2));
entity.addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Notebook Professional 17"));
entity.addProperty(new Property(null, "Description", ValueType.PRIMITIVE,
- "Notebook Professional, 2.8GHz - 15 XGA - 8GB DDR3 RAM - 500GB"));
+ "Notebook Professional, 2.8GHz - 15 XGA - 8GB DDR3 RAM - 500GB"));
entity.setType(DemoEdmProvider.ET_PRODUCT_FQN.getFullQualifiedNameAsString());
productList.add(entity);
@@ -206,7 +198,7 @@ public class Storage {
entity.addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 3));
entity.addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "1UMTS PDA"));
entity.addProperty(new Property(null, "Description", ValueType.PRIMITIVE,
- "Ultrafast 3G UMTS/HSDPA Pocket PC, supports GSM network"));
+ "Ultrafast 3G UMTS/HSDPA Pocket PC, supports GSM network"));
entity.setType(DemoEdmProvider.ET_PRODUCT_FQN.getFullQualifiedNameAsString());
productList.add(entity);
@@ -214,7 +206,7 @@ public class Storage {
entity.addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 4));
entity.addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Comfort Easy"));
entity.addProperty(new Property(null, "Description", ValueType.PRIMITIVE,
- "32 GB Digital Assitant with high-resolution color screen"));
+ "32 GB Digital Assitant with high-resolution color screen"));
entity.setType(DemoEdmProvider.ET_PRODUCT_FQN.getFullQualifiedNameAsString());
productList.add(entity);
@@ -222,7 +214,7 @@ public class Storage {
entity.addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 5));
entity.addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Ergo Screen"));
entity.addProperty(new Property(null, "Description", ValueType.PRIMITIVE,
- "19 Optimum Resolution 1024 x 768 @ 85Hz, resolution 1280 x 960"));
+ "19 Optimum Resolution 1024 x 768 @ 85Hz, resolution 1280 x 960"));
entity.setType(DemoEdmProvider.ET_PRODUCT_FQN.getFullQualifiedNameAsString());
productList.add(entity);
@@ -230,12 +222,12 @@ public class Storage {
entity.addProperty(new Property(null, "ID", ValueType.PRIMITIVE, 6));
entity.addProperty(new Property(null, "Name", ValueType.PRIMITIVE, "Flat Basic"));
entity.addProperty(new Property(null, "Description", ValueType.PRIMITIVE,
- "Optimum Hi-Resolution max. 1600 x 1200 @ 85Hz, Dot Pitch: 0.24mm"));
+ "Optimum Hi-Resolution max. 1600 x 1200 @ 85Hz, Dot Pitch: 0.24mm"));
entity.setType(DemoEdmProvider.ET_PRODUCT_FQN.getFullQualifiedNameAsString());
productList.add(entity);
}
- private void initCategorySampleData(){
+ private void initCategorySampleData() {
Entity entity = new Entity();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8960fdb5/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java b/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
index 86dd9fb..7b1fef8 100755
--- a/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoEdmProvider.java
+++ b/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoEdmProvider.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,12 +38,9 @@ import org.apache.olingo.commons.api.edm.provider.CsdlSchema;
public class DemoEdmProvider extends CsdlAbstractEdmProvider {
-
// Service Namespace
public static final String NAMESPACE = "OData.Demo";
- // OData.Demo
-
// EDM Container
public static final String CONTAINER_NAME = "Container";
public static final FullQualifiedName CONTAINER = new FullQualifiedName(NAMESPACE, CONTAINER_NAME);
@@ -59,22 +56,20 @@ public class DemoEdmProvider extends CsdlAbstractEdmProvider {
public static final String ES_PRODUCTS_NAME = "Products";
public static final String ES_CATEGORIES_NAME = "Categories";
-
-
@Override
public CsdlEntityType getEntityType(FullQualifiedName entityTypeName) throws ODataException {
// this method is called for each EntityType that are configured in the Schema
CsdlEntityType entityType = null;
- if(entityTypeName.equals(ET_PRODUCT_FQN)){
- //create EntityType properties
+ if (entityTypeName.equals(ET_PRODUCT_FQN)) {
+ // create EntityType properties
CsdlProperty id = new CsdlProperty().setName("ID")
- .setType(EdmPrimitiveTypeKind.Int32.getFullQualifiedName());
+ .setType(EdmPrimitiveTypeKind.Int32.getFullQualifiedName());
CsdlProperty name = new CsdlProperty().setName("Name")
- .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
- CsdlProperty description = new CsdlProperty().setName("Description")
- .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
+ .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
+ CsdlProperty description = new CsdlProperty().setName("Description")
+ .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
// create PropertyRef for Key element
CsdlPropertyRef propertyRef = new CsdlPropertyRef();
@@ -82,23 +77,23 @@ public class DemoEdmProvider extends CsdlAbstractEdmProvider {
// navigation property: many-to-one, null not allowed (product must have a category)
CsdlNavigationProperty navProp = new CsdlNavigationProperty().setName("Category")
- .setType(ET_CATEGORY_FQN).setNullable(false).setPartner("Products");
+ .setType(ET_CATEGORY_FQN).setNullable(false).setPartner("Products");
List<CsdlNavigationProperty> navPropList = new ArrayList<CsdlNavigationProperty>();
navPropList.add(navProp);
// configure EntityType
entityType = new CsdlEntityType();
entityType.setName(ET_PRODUCT_NAME);
- entityType.setProperties(Arrays.asList(id, name , description));
+ entityType.setProperties(Arrays.asList(id, name, description));
entityType.setKey(Arrays.asList(propertyRef));
entityType.setNavigationProperties(navPropList);
- }else if (entityTypeName.equals(ET_CATEGORY_FQN)){
- //create EntityType properties
+ } else if (entityTypeName.equals(ET_CATEGORY_FQN)) {
+ // create EntityType properties
CsdlProperty id = new CsdlProperty().setName("ID")
- .setType(EdmPrimitiveTypeKind.Int32.getFullQualifiedName());
+ .setType(EdmPrimitiveTypeKind.Int32.getFullQualifiedName());
CsdlProperty name = new CsdlProperty().setName("Name")
- .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
+ .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
// create PropertyRef for Key element
CsdlPropertyRef propertyRef = new CsdlPropertyRef();
@@ -106,7 +101,7 @@ public class DemoEdmProvider extends CsdlAbstractEdmProvider {
// navigation property: one-to-many
CsdlNavigationProperty navProp = new CsdlNavigationProperty().setName("Products")
- .setType(ET_PRODUCT_FQN).setCollection(true).setPartner("Category");
+ .setType(ET_PRODUCT_FQN).setCollection(true).setPartner("Category");
List<CsdlNavigationProperty> navPropList = new ArrayList<CsdlNavigationProperty>();
navPropList.add(navProp);
@@ -127,9 +122,9 @@ public class DemoEdmProvider extends CsdlAbstractEdmProvider {
CsdlEntitySet entitySet = null;
- if(entityContainer.equals(CONTAINER)){
+ if (entityContainer.equals(CONTAINER)) {
- if(entitySetName.equals(ES_PRODUCTS_NAME)){
+ if (entitySetName.equals(ES_PRODUCTS_NAME)) {
entitySet = new CsdlEntitySet();
entitySet.setName(ES_PRODUCTS_NAME);
@@ -143,7 +138,7 @@ public class DemoEdmProvider extends CsdlAbstractEdmProvider {
navPropBindingList.add(navPropBinding);
entitySet.setNavigationPropertyBindings(navPropBindingList);
- }else if(entitySetName.equals(ES_CATEGORIES_NAME)){
+ } else if (entitySetName.equals(ES_CATEGORIES_NAME)) {
entitySet = new CsdlEntitySet();
entitySet.setName(ES_CATEGORIES_NAME);
@@ -167,7 +162,7 @@ public class DemoEdmProvider extends CsdlAbstractEdmProvider {
// This method is invoked when displaying the service document at
// e.g. http://localhost:8080/DemoService/DemoService.svc
- if(entityContainerName == null || entityContainerName.equals(CONTAINER)){
+ if (entityContainerName == null || entityContainerName.equals(CONTAINER)) {
CsdlEntityContainerInfo entityContainerInfo = new CsdlEntityContainerInfo();
entityContainerInfo.setContainerName(CONTAINER);
return entityContainerInfo;
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8960fdb5/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java b/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java
index 932691e..9f281bb 100755
--- a/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.java
+++ b/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoEntityCollectionProcessor.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
@@ -52,14 +52,11 @@ import org.apache.olingo.server.api.uri.UriResourceNavigation;
public class DemoEntityCollectionProcessor implements EntityCollectionProcessor {
-
private OData odata;
private ServiceMetadata srvMetadata;
// our database-mock
private Storage storage;
-
-
public DemoEntityCollectionProcessor(Storage storage) {
this.storage = storage;
}
@@ -69,21 +66,19 @@ public class DemoEntityCollectionProcessor implements EntityCollectionProcessor
this.srvMetadata = serviceMetadata;
}
-
/*
* This method is invoked when a collection of entities has to be read.
* In our example, this can be either a "normal" read operation, or a navigation:
- *
+ *
* Example for "normal" read entity set operation:
* http://localhost:8080/DemoService/DemoService.svc/Categories
- *
+ *
* Example for navigation
* http://localhost:8080/DemoService/DemoService.svc/Categories(3)/Products
- *
- * */
+ */
public void readEntityCollection(ODataRequest request, ODataResponse response,
- UriInfo uriInfo, ContentType responseFormat)
- throws ODataApplicationException, SerializerException {
+ UriInfo uriInfo, ContentType responseFormat)
+ throws ODataApplicationException, SerializerException {
EdmEntitySet responseEdmEntitySet = null; // we'll need this to build the ContextURL
EntityCollection responseEntityCollection = null; // we'll need this to set the response body
@@ -93,27 +88,27 @@ public class DemoEntityCollectionProcessor implements EntityCollectionProcessor
int segmentCount = resourceParts.size();
UriResource uriResource = resourceParts.get(0); // in our example, the first segment is the EntitySet
- if (! (uriResource instanceof UriResourceEntitySet)) {
+ if (!(uriResource instanceof UriResourceEntitySet)) {
throw new ODataApplicationException("Only EntitySet is supported",
- HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(),Locale.ROOT);
+ HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
}
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) uriResource;
EdmEntitySet startEdmEntitySet = uriResourceEntitySet.getEntitySet();
- if(segmentCount == 1){ // this is the case for: DemoService/DemoService.svc/Categories
- responseEdmEntitySet = startEdmEntitySet; //the response body is built from the first (and only) entitySet
+ if (segmentCount == 1) { // this is the case for: DemoService/DemoService.svc/Categories
+ responseEdmEntitySet = startEdmEntitySet; // the response body is built from the first (and only) entitySet
// 2nd: fetch the data from backend for this requested EntitySetName and deliver as EntitySet
responseEntityCollection = storage.readEntitySetData(startEdmEntitySet);
- }else if (segmentCount == 2){ // in case of navigation: DemoService.svc/Categories(3)/Products
+ } else if (segmentCount == 2) { // in case of navigation: DemoService.svc/Categories(3)/Products
UriResource lastSegment = resourceParts.get(1); // in our example we don't support more complex URIs
- if(lastSegment instanceof UriResourceNavigation){
- UriResourceNavigation uriResourceNavigation = (UriResourceNavigation)lastSegment;
+ if (lastSegment instanceof UriResourceNavigation) {
+ UriResourceNavigation uriResourceNavigation = (UriResourceNavigation) lastSegment;
EdmNavigationProperty edmNavigationProperty = uriResourceNavigation.getProperty();
EdmEntityType targetEntityType = edmNavigationProperty.getType();
- //from Categories(1) to Products
+ // from Categories(1) to Products
responseEdmEntitySet = Util.getNavigationTargetEntitySet(startEdmEntitySet, edmNavigationProperty);
// 2nd: fetch the data from backend
@@ -121,19 +116,19 @@ public class DemoEntityCollectionProcessor implements EntityCollectionProcessor
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
// e.g. for Categories(3)/Products we have to find the single entity: Category with ID 3
Entity sourceEntity = storage.readEntityData(startEdmEntitySet, keyPredicates);
- // error handling for e.g. DemoService.svc/Categories(99)/Products
- if(sourceEntity == null) {
+ // error handling for e.g. DemoService.svc/Categories(99)/Products
+ if (sourceEntity == null) {
throw new ODataApplicationException("Entity not found.",
- HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ROOT);
+ HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ROOT);
}
// then fetch the entity collection where the entity navigates to
// note: we don't need to check uriResourceNavigation.isCollection(),
// because we are the EntityCollectionProcessor
responseEntityCollection = storage.getRelatedEntityCollection(sourceEntity, targetEntityType);
}
- }else{ // this would be the case for e.g. Products(1)/Category/Products
+ } else { // this would be the case for e.g. Products(1)/Category/Products
throw new ODataApplicationException("Not supported",
- HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(),Locale.ROOT);
+ HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
}
// 3rd: create and configure a serializer
@@ -143,7 +138,7 @@ public class DemoEntityCollectionProcessor implements EntityCollectionProcessor
ODataSerializer serializer = odata.createSerializer(ODataFormat.fromContentType(responseFormat));
SerializerResult serializerResult = serializer.entityCollection(this.srvMetadata, edmEntityType,
- responseEntityCollection, opts);
+ responseEntityCollection, opts);
// 4th: configure the response object: set the body, headers and status code
response.setContent(serializerResult.getContent());
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8960fdb5/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java b/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
index 1d05e12..a2cf344 100755
--- a/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.java
+++ b/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoEntityProcessor.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
@@ -53,37 +53,31 @@ import org.apache.olingo.server.api.uri.UriResourceNavigation;
public class DemoEntityProcessor implements EntityProcessor {
-
private OData odata;
private ServiceMetadata srvMetadata;
private Storage storage;
-
-
public DemoEntityProcessor(Storage storage) {
this.storage = storage;
}
-
public void init(OData odata, ServiceMetadata serviceMetadata) {
this.odata = odata;
this.srvMetadata = serviceMetadata;
}
- /*
+ /**
* This method is invoked when a single entity has to be read.
* In our example, this can be either a "normal" read operation, or a navigation:
- *
+ *
* Example for "normal" read operation:
* http://localhost:8080/DemoService/DemoService.svc/Products(1)
- *
+ *
* Example for navigation
* http://localhost:8080/DemoService/DemoService.svc/Products(1)/Category
- *
- * */
+ */
public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat)
- throws ODataApplicationException, SerializerException {
-
+ throws ODataApplicationException, SerializerException {
EdmEntityType responseEdmEntityType = null; // we'll need this to build the ContextURL
Entity responseEntity = null; // required for serialization of the response body
@@ -94,33 +88,33 @@ public class DemoEntityProcessor implements EntityProcessor {
int segmentCount = resourceParts.size();
UriResource uriResource = resourceParts.get(0); // in our example, the first segment is the EntitySet
- if (! (uriResource instanceof UriResourceEntitySet)) {
+ if (!(uriResource instanceof UriResourceEntitySet)) {
throw new ODataApplicationException("Only EntitySet is supported",
- HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(),Locale.ENGLISH);
+ HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
}
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) uriResource;
EdmEntitySet startEdmEntitySet = uriResourceEntitySet.getEntitySet();
// Analyze the URI segments
- if(segmentCount == 1){ // no navigation
+ if (segmentCount == 1) { // no navigation
responseEdmEntityType = startEdmEntitySet.getEntityType();
responseEdmEntitySet = startEdmEntitySet; // since we have only one segment
// 2. step: retrieve the data from backend
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
responseEntity = storage.readEntityData(startEdmEntitySet, keyPredicates);
- } else if (segmentCount == 2){ //navigation
+ } else if (segmentCount == 2) { // navigation
UriResource navSegment = resourceParts.get(1); // in our example we don't support more complex URIs
- if(navSegment instanceof UriResourceNavigation){
- UriResourceNavigation uriResourceNavigation = (UriResourceNavigation)navSegment;
+ if (navSegment instanceof UriResourceNavigation) {
+ UriResourceNavigation uriResourceNavigation = (UriResourceNavigation) navSegment;
EdmNavigationProperty edmNavigationProperty = uriResourceNavigation.getProperty();
responseEdmEntityType = edmNavigationProperty.getType();
// contextURL displays the last segment
responseEdmEntitySet = Util.getNavigationTargetEntitySet(startEdmEntitySet, edmNavigationProperty);
// 2nd: fetch the data from backend.
- // e.g. for the URI: Products(1)/Category we have to find the correct Category entity
+ // e.g. for the URI: Products(1)/Category we have to find the correct Category entity
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
// e.g. for Products(1)/Category we have to find first the Products(1)
Entity sourceEntity = storage.readEntityData(startEdmEntitySet, keyPredicates);
@@ -131,18 +125,18 @@ public class DemoEntityProcessor implements EntityProcessor {
// the key for nav is used in this case: Categories(3)/Products(5)
List<UriParameter> navKeyPredicates = uriResourceNavigation.getKeyPredicates();
- if(navKeyPredicates.isEmpty()){ // e.g. DemoService.svc/Products(1)/Category
+ if (navKeyPredicates.isEmpty()) { // e.g. DemoService.svc/Products(1)/Category
responseEntity = storage.getRelatedEntity(sourceEntity, responseEdmEntityType);
- }else{ // e.g. DemoService.svc/Categories(3)/Products(5)
+ } else { // e.g. DemoService.svc/Categories(3)/Products(5)
responseEntity = storage.getRelatedEntity(sourceEntity, responseEdmEntityType, navKeyPredicates);
}
}
- }else{
+ } else {
// this would be the case for e.g. Products(1)/Category/Products(1)/Category
- throw new ODataApplicationException("Not supported", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(),Locale.ROOT);
+ throw new ODataApplicationException("Not supported", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
}
- if(responseEntity == null) {
+ if (responseEntity == null) {
// this is the case for e.g. DemoService.svc/Categories(4) or DemoService.svc/Categories(3)/Products(999)
throw new ODataApplicationException("Nothing found.", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ROOT);
}
@@ -154,36 +148,32 @@ public class DemoEntityProcessor implements EntityProcessor {
ODataFormat oDataFormat = ODataFormat.fromContentType(responseFormat);
ODataSerializer serializer = this.odata.createSerializer(oDataFormat);
SerializerResult serializerResult = serializer.entity(this.srvMetadata,
- responseEdmEntityType, responseEntity, opts);
+ responseEdmEntityType, responseEntity, opts);
- //4. configure the response object
+ // 4. configure the response object
response.setContent(serializerResult.getContent());
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
}
-
-
/*
* These processor methods are not handled in this tutorial
- * */
+ */
public void createEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
- ContentType requestFormat, ContentType responseFormat)
- throws ODataApplicationException, DeserializerException, SerializerException {
+ ContentType requestFormat, ContentType responseFormat)
+ throws ODataApplicationException, DeserializerException, SerializerException {
throw new ODataApplicationException("Not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
}
-
public void updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
- ContentType requestFormat, ContentType responseFormat)
- throws ODataApplicationException, DeserializerException, SerializerException {
+ ContentType requestFormat, ContentType responseFormat)
+ throws ODataApplicationException, DeserializerException, SerializerException {
throw new ODataApplicationException("Not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
}
-
public void deleteEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo)
- throws ODataApplicationException {
+ throws ODataApplicationException {
throw new ODataApplicationException("Not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8960fdb5/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java b/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
index 6436ae5..c32c5c2 100755
--- a/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.java
+++ b/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/service/DemoPrimitiveProcessor.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
@@ -56,30 +56,27 @@ public class DemoPrimitiveProcessor implements PrimitiveProcessor {
private OData odata;
private Storage storage;
-
-
public DemoPrimitiveProcessor(Storage storage) {
this.storage = storage;
}
-
public void init(OData odata, ServiceMetadata serviceMetadata) {
this.odata = odata;
}
-
/*
* In our example, the URL would be: http://localhost:8080/DemoService/DemoService.svc/Products(1)/Name
* and the response:
* {
- * @odata.context: "$metadata#Products/Name",
- * value: "Notebook Basic 15"
+ *
+ * @odata.context: "$metadata#Products/Name",
+ * value: "Notebook Basic 15"
* }
- * */
+ */
public void readPrimitive(ODataRequest request, ODataResponse response,
- UriInfo uriInfo, ContentType responseFormat)
- throws ODataApplicationException, SerializerException {
+ UriInfo uriInfo, ContentType responseFormat)
+ throws ODataApplicationException, SerializerException {
// 1. Retrieve info from URI
// 1.1. retrieve the info about the requested entity set
@@ -92,26 +89,25 @@ public class DemoPrimitiveProcessor implements PrimitiveProcessor {
// 1.2. retrieve the requested (Edm) property
// the last segment is the Property
- UriResourceProperty uriProperty = (UriResourceProperty)resourceParts.get(resourceParts.size() -1);
+ 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);
+ 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);
+ HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
}
// 3. serialize
@@ -127,28 +123,28 @@ public class DemoPrimitiveProcessor implements PrimitiveProcessor {
SerializerResult serializerResult = serializer.primitive(edmPropertyType, property, options);
InputStream propertyStream = serializerResult.getContent();
- //4. configure the response object
+ // 4. configure the response object
response.setContent(propertyStream);
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
- }else{
+ } else {
// in case there's no value for the property, we can skip the serialization
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
}
-
-
/*
* These processor methods are not handled in this tutorial
- * */
+ */
- public void updatePrimitive(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType requestFormat, ContentType responseFormat)
- throws ODataApplicationException, DeserializerException, SerializerException {
+ 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/8960fdb5/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/util/Util.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/util/Util.java b/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/util/Util.java
index 6a9ecb2..3320760 100755
--- a/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/util/Util.java
+++ b/samples/tutorials/p4_navigation/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,15 +37,16 @@ import org.apache.olingo.server.api.uri.UriParameter;
public class Util {
-
- public static Entity findEntity(EdmEntityType edmEntityType, EntityCollection entitySet, List<UriParameter> keyParams) {
+ public static Entity findEntity(EdmEntityType edmEntityType, EntityCollection entitySet,
+ List<UriParameter> keyParams) {
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){
+ // 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){
+ if (foundEntity) {
return entity;
}
}
@@ -53,93 +54,98 @@ public class Util {
return null;
}
-
- public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity rt_entity, List<UriParameter> keyParams) {
-
- // loop over all keys
- for (final UriParameter key : keyParams) {
- // key
- String keyName = key.getName();
- String keyText = key.getText();
-
- // note: below line doesn't consider: keyProp can be part of a complexType in V4
- // in such case, it would be required to access it via getKeyPropertyRef()
- // but since this isn't the case in our model, we ignore it in our implementation
- EdmProperty edmKeyProperty = (EdmProperty )edmEntityType.getProperty(keyName);
- // Edm: we need this info for the comparison below
- Boolean isNullable = edmKeyProperty.isNullable();
- Integer maxLength = edmKeyProperty.getMaxLength();
- Integer precision = edmKeyProperty.getPrecision();
- Boolean isUnicode = edmKeyProperty.isUnicode();
- 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
- Object valueObject = rt_entity.getProperty(keyName).getValue(); // don't need to check for null, this is done in FWK
- // TODO if the property is a complex type
+ public static boolean entityMatchesAllKeys(EdmEntityType edmEntityType, Entity rt_entity,
+ List<UriParameter> keyParams) {
+
+ // loop over all keys
+ for (final UriParameter key : keyParams) {
+ // key
+ String keyName = key.getName();
+ String keyText = key.getText();
+
+ // note: below line doesn't consider: keyProp can be part of a complexType in V4
+ // in such case, it would be required to access it via getKeyPropertyRef()
+ // but since this isn't the case in our model, we ignore it in our implementation
+ EdmProperty edmKeyProperty = (EdmProperty) edmEntityType.getProperty(keyName);
+ // Edm: we need this info for the comparison below
+ Boolean isNullable = edmKeyProperty.isNullable();
+ Integer maxLength = edmKeyProperty.getMaxLength();
+ Integer precision = edmKeyProperty.getPrecision();
+ Boolean isUnicode = edmKeyProperty.isUnicode();
+ 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 FWK
+ Object valueObject = rt_entity.getProperty(keyName).getValue();
+ // TODO if the property is a complex type
// now need to compare the valueObject with the keyText String
// this is done using the type.valueToString
String valueAsString = null;
try {
- valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable, maxLength, precision, scale, isUnicode);
+ valueAsString = edmPrimitiveType.valueToString(valueObject, isNullable,
+ maxLength, precision, scale, isUnicode);
} catch (EdmPrimitiveTypeException e) {
return false; // TODO proper Exception handling
}
- if (valueAsString == null){
+ if (valueAsString == null) {
return false;
}
boolean matches = valueAsString.equals(keyText);
- if(matches){
+ if (matches) {
// if the given key value is found in the current entity, continue with the next key
continue;
- }else{
+ } else {
// if any of the key properties is not found in the entity, we don't need to search further
return false;
}
- }
-
- return true;
- }
-
+ }
+ return true;
+ }
- /*
+ /**
* Example:
* For the following navigation: DemoService.svc/Categories(1)/Products
* we need the EdmEntitySet for the navigation property "Products"
*
* This is defined as follows in the metadata:
- *
+ * <code>
+ *
* <EntitySet Name="Categories" EntityType="OData.Demo.Category">
- <NavigationPropertyBinding Path="Products" Target="Products"/>
- </EntitySet>
- * The "Target" attribute specifies the target EntitySet
- * Therefore we need the startEntitySet "Categories" in order to retrieve the target EntitySet "Products"
- */
- public static EdmEntitySet getNavigationTargetEntitySet(EdmEntitySet startEntitySet, EdmNavigationProperty edmNavigationProperty) throws ODataApplicationException {
+ * <NavigationPropertyBinding Path="Products" Target="Products"/>
+ * </EntitySet>
+ * </code>
+ * The "Target" attribute specifies the target EntitySet
+ * Therefore we need the startEntitySet "Categories" in order to retrieve the target EntitySet "Products"
+ */
+ public static EdmEntitySet getNavigationTargetEntitySet(EdmEntitySet startEntitySet,
+ EdmNavigationProperty edmNavigationProperty)
+ throws ODataApplicationException {
+
EdmEntitySet navigationTargetEntitySet = null;
String navPropName = edmNavigationProperty.getName();
EdmBindingTarget edmBindingTarget = startEntitySet.getRelatedBindingTarget(navPropName);
- if(edmBindingTarget == null){
- throw new ODataApplicationException("Not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
+ if (edmBindingTarget == null) {
+ throw new ODataApplicationException("Not supported.",
+ HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
}
- if(edmBindingTarget instanceof EdmEntitySet){
- navigationTargetEntitySet = (EdmEntitySet)edmBindingTarget;
- }else{
- throw new ODataApplicationException("Not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
+ if (edmBindingTarget instanceof EdmEntitySet) {
+ navigationTargetEntitySet = (EdmEntitySet) edmBindingTarget;
+ } else {
+ throw new ODataApplicationException("Not supported.",
+ HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
}
return navigationTargetEntitySet;
}
-
-}
-
+}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/8960fdb5/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/web/DemoServlet.java
----------------------------------------------------------------------
diff --git a/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/web/DemoServlet.java b/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/web/DemoServlet.java
index dd83c6e..5c828e5 100755
--- a/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/web/DemoServlet.java
+++ b/samples/tutorials/p4_navigation/src/main/java/myservice/mynamespace/web/DemoServlet.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
@@ -45,16 +45,15 @@ public class DemoServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(DemoServlet.class);
-
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
- HttpSession session = req.getSession(true);
- Storage storage = (Storage) session.getAttribute(Storage.class.getName());
- if (storage == null) {
- storage = new Storage();
- session.setAttribute(Storage.class.getName(), storage);
- }
+ HttpSession session = req.getSession(true);
+ Storage storage = (Storage) session.getAttribute(Storage.class.getName());
+ if (storage == null) {
+ storage = new Storage();
+ session.setAttribute(Storage.class.getName(), storage);
+ }
// create odata handler and configure it with EdmProvider and Processor
OData odata = OData.newInstance();