You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by bu...@apache.org on 2015/07/08 14:15:07 UTC

svn commit: r957513 - in /websites/staging/olingo/trunk/content: ./ doc/odata4/tutorials/navigation/ doc/odata4/tutorials/read/

Author: buildbot
Date: Wed Jul  8 12:15:07 2015
New Revision: 957513

Log:
Staging update by buildbot for olingo

Added:
    websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/
    websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/TutorialPart4.md   (with props)
    websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/browser_categories.JPG   (with props)
    websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/browser_categories1.jpg   (with props)
    websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/browser_categories1_products.jpg   (with props)
    websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/browser_metadataCategory.JPG   (with props)
    websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/model.JPG   (with props)
Modified:
    websites/staging/olingo/trunk/content/   (props changed)
    websites/staging/olingo/trunk/content/doc/odata4/tutorials/read/tutorial_read.html

Propchange: websites/staging/olingo/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Wed Jul  8 12:15:07 2015
@@ -1 +1 @@
-1687122
+1689854

Added: websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/TutorialPart4.md
==============================================================================
--- websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/TutorialPart4.md (added)
+++ websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/TutorialPart4.md Wed Jul  8 12:15:07 2015
@@ -0,0 +1,911 @@
+# How to build an OData Service with Olingo V4
+
+# Part 4: Navigation
+
+## Introduction
+
+In the present tutorial, we’ll learn how to implement navigation between 2 Entity Types in an OData V4 service.
+
+**Background**  
+Say, we have an electronics shop and we have a lot of products which we’re selling and these products can be notebooks or monitors or organizers, which are the categories.  
+We would have 3 requirements:
+
+  1. We want to show a list of all our categories, then select one and display a list of all products that belong to this category, e.g. all monitors
+  In terms of OData, this is called navigation
+  2. From the list of our products, we want to choose one and display its category
+  3. We want to navigate from a category to its products and perform a READ operation on one of them.
+
+**Example for navigating in a service**  
+We open the Categories collection: <http://localhost:8080/DemoService/DemoService.svc/Categories>
+
+![CategoryCollection](browser_categories.JPG "The Category collection")
+
+We open the details of the first Category, the “Notebooks”-category:
+http://localhost:8080/DemoService/DemoService.svc/Categories(1)
+
+![CategoryEntity](browser_categories1.jpg "Read single Category entity")
+
+In order to display all products that are notebooks, we can navigate from the selected category to its products:  
+http://localhost:8080/DemoService/DemoService.svc/Categories(1)/Products
+
+![ProductsOfCategory](browser_categories1_products.jpg "After navigating from a  Category to the related Products")
+
+In the above example we’ve executed a one-to-many navigation.  
+
+As mentioned in the Background section, it is also required to navigate from a selected product to its category, which is a to-one relation, like:
+http://localhost:8080/DemoService/DemoService.svc/Products(1)/Category
+
+And finally, it is possible to navigate to a list of products and directly access one of them, e.g.  
+http://localhost:8080/DemoService/DemoService.svc/Categories(1)/Products(1)
+
+All three cases are covered by the present tutorial.
+
+
+**Note**
+The full implementation of the OData service as described in the present tutorial can be found in the attached zip file that contains an Eclipse project that can be imported into your Eclipse workspace.
+
+**Disclaimer**
+Again, in the present tutorial, we’ll focus only on the relevant implementation, in order to keep the code small and simple.
+The sample code shouldn’t be reused for advanced scenarios.
+
+
+**Table of Contents**
+
+  1. Prerequisites
+  2. Preparation
+  3. Implementating the navigation
+    1. Declare the Metadata
+    2. Implement the to-many navigation
+    3. Implement the to-one navigation
+    4. Implement the to-many navigation with key access
+  4. Run the implemented service
+  5. Summary
+  6. Links
+  7. Appendix: code snippets
+
+
+___
+
+# 1. Prerequisites
+
+Same prerequisites as in [Tutorial Part 1: Read Entity Collection](http://olingo.apache.org/doc/odata4/tutorials/read/tutorial_read.html)
+ and [Tutorial Part 2: Read Entity](http://olingo.apache.org/doc/odata4/tutorials/readep/tutorial_readep.html) as well as basic knowledge about the concepts presented in both tutorials.
+
+___
+
+# 2. Preparation
+
+Follow Tutorial Part 1: Read Entity Collection and Tutorial Part 2: Read Entity or as shortcut import the project attached to Tutorial Part 2 into your Eclipse workspace.
+
+Afterwards do a Deploy and run: it should be working.
+
+
+___
+
+
+# 3. Implementing the navigation
+
+
+In our sample scenario, we want to navigate from a product to its category and from a category to a list of products.  
+In order to achieve this, we need to create a second Entity Type, "Category", and we need to specify _Navigation Properties_ in both Entity Types.  
+Our model looks as follows:
+
+![ODataModelNavigation](model.JPG "Our OData Model with link between 2 Entity Types")
+
+
+**Note**
+When designing the OData model, we could think of specifying a property “ProductCategory” in the entity type “Product”.
+E.g. a product with name “Brilliant flat and wide” would have the category “Monitors”.  
+But this is not necessary, because that information can be obtained by navigating to the respective “Category”-entity using the navigation property.  
+That way, we can keep the entity types lightweight, which is one of the intentions of OData.
+
+
+## 3.1. Declare the metadata
+
+In order to declare the metadata of our OData service, we open the class _myservice.mynamespace.service.DemoEdmProvider_
+
+### 3.1.1. Extend the Entity Type “Product”
+
+In the previous tutorial we’ve already created the metadata for the “Product” entity type:
+
+    :::xml
+    <EntityType Name="Product">
+        <Key>
+          <PropertyRef Name="ID" />
+        </Key>
+        <Property Name="ID" Type="Edm.Int32" Nullable="false" />
+        <Property Name="Name" Type="Edm.String" Nullable="false" />
+        <Property Name="Description" Type="Edm.String" Nullable="false" />
+    </EntityType>
+
+Now we have to add a navigation property.  
+That navigation property element has the following attributes:  
+
+
+**Name**
+Tthe name of the navigation property is used as segment in the URI  
+e.g. for the following URL: <http://localhost:8080/DemoService/DemoService.svc/Products(1)/Category>  
+The segment “Category” is the name of the navigation property  
+
+**Type**
+Here we specify the Entity Type to which we’re navigating.  
+e.g. for the following URL: <http://localhost:8080/DemoService/DemoService.svc/Products(1)/Category>  
+we’re navigating to an entity which has the entity type “OData.Demo.Category”  
+(we still have to create this entity type in this tutorial)  
+Note that the fully qualified name has to be specified.  
+Note that here we don’t specify a collection, so we have a to-one relationship.
+
+**Nullable**  
+Specifies if the navigation target is required.  
+If we don’t specify it, then the default is assumed to be “true”.  
+In our example we want to declare that every product must have a category, so we have to set it to “false”
+
+**Partner**  
+An optional attribute, used to define a bi-directional relationship.  
+Specifies a path from the entity type (specified here) to the navigation property (defined there).
+In our example, we can navigate from product to category and from category to product  
+
+
+In our example, the metadata of our “Product” entity type looks as follows:
+
+
+    :::xml
+     <EntityType Name="Product">
+       <Key>
+         <PropertyRef Name="ID"/>
+       </Key>
+       <Property Name="ID" Type="Edm.Int32"/>
+       <Property Name="Name" Type="Edm.String"/>
+       <Property Name="Description" Type="Edm.String"/>
+       <NavigationProperty Name="Category" Type="OData.Demo.Category" Nullable="false" Partner="Products"/>
+     </EntityType>
+
+
+Implementation-wise we have to create and configure an object of type _CsdlNavigationProperty_:
+
+    :::java
+    CsdlNavigationProperty navProp = new CsdlNavigationProperty()
+                                        .setName("Category")
+                                        .setType(ET_CATEGORY_FQN)
+                                        .setNullable(false)
+                                        .setPartner("Products");
+
+Since an entity type can have multiple navigation properties, we have to put it into a list:
+
+    :::java
+    List<CsdlNavigationProperty> navPropList = new ArrayList<CsdlNavigationProperty>();
+    navPropList.add(navProp);
+
+That list becomes relevant for the entity type that has been created earlier:
+
+    :::java
+    entityType.setNavigationProperties(navPropList);
+
+
+There’s one more step to consider with respect to the navigation: the entity set.  
+At runtime, we need to know how to implement the navigation, when an entity set is invoked.  
+For this purpose, the OData specifies the _NavigationPropertyBinding_ element, which is a child element of the entity set and should be defined for each navigation property.  
+That _NavigationPropertyBinding_ has the following attributes:  
+
+**Path**  
+Here we specify the name of the corresponding navigation property.
+In our example, the navigation property that we’ve defined above is named “Category”
+
+**Target**  
+Here we specify the entity set where we’re navigating to.  
+In our example it is the entity set “Categories” (which we’ll create below)
+
+In our example, the definition of our “Products” entity set looks as follows:
+
+    :::xml
+    <EntitySet Name="Products" EntityType="OData.Demo.Product">
+      <NavigationPropertyBinding Path="Category" Target="Categories"/>
+    </EntitySet>
+
+
+Code-wise, the getEntitySet method is extended as follows:
+
+    :::java
+    CsdlNavigationPropertyBinding navPropBinding = new CsdlNavigationPropertyBinding();
+    navPropBinding.setPath("Category"); // the path from entity type to navigation property
+    navPropBinding.setTarget("Categories"); //target entitySet, where the nav prop points to
+    List<CsdlNavigationPropertyBinding> navPropBindingList = new ArrayList<CsdlNavigationPropertyBinding>();
+    navPropBindingList.add(navPropBinding);
+    entitySet.setNavigationPropertyBindings(navPropBindingList);
+
+
+
+### 3.1.2. Create the Entity Type “Category”  
+
+Now we have to create the second entity type, the “Category”.  
+In order to keep our sample as simple as possible, we define only 2 properties, the “ID” and a “Name”.  
+Since we want to be able to navigate from one given category (e.g. “Monitors”) to a list of products (e.g. all products that are monitors), we have to specify a navigation property in this entity type as well.  
+Here, the navigation property has the following attributes:  
+
+**Name**  
+In our example, we specify “Products”, in plural because we want to get multiple entities.  
+
+**Type**  
+The “Type” attribute can be either an “entity type” or a “collection of entity types”  
+In our example this time, we specify a “collection” of “OData.Demo.Product”  
+
+**Nullable**  
+According to the OData specification (see odata.org), this attribute is not allowed for a collection
+A collection can be empty, but never null.
+
+**Partner**  
+In our example, we’re defining a bi-directional navigation, so here we specify “Category”, the name of the navigation property defined above.
+
+In our example, the metadata of our “Category” entity type looks as follows:
+
+    :::xml
+    <EntityType Name="Category">
+      <Key>
+        <PropertyRef Name="ID"/>
+      </Key>
+      <Property Name="ID" Type="Edm.Int32"/>
+      <Property Name="Name" Type="Edm.String"/>
+      <NavigationProperty Name="Products" Type="Collection(OData.Demo.Product)" Partner="Category"/>
+    </EntityType>
+
+
+The code for the “Category” entity type:
+
+    :::java
+    if (entityTypeName.equals(ET_CATEGORY_FQN)){
+	    //create EntityType properties
+	    CsdlProperty id = new CsdlProperty()
+                                .setName("ID")
+                                .setType(EdmPrimitiveTypeKind.Int32.getFullQualifiedName());
+	    CsdlProperty name = new CsdlProperty()
+                                .setName("Name")
+                                .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
+
+	    // create PropertyRef for Key element
+	    CsdlPropertyRef propertyRef = new CsdlPropertyRef();
+	    propertyRef.setName("ID");
+
+	    // navigation property: one-to-many
+	    CsdlNavigationProperty navProp = new CsdlNavigationProperty()
+                                .setName("Products")
+                                .setType(ET_PRODUCT_FQN)
+                                .setCollection(true)
+                                .setPartner("Category");
+	    List<CsdlNavigationProperty> navPropList = new ArrayList<CsdlNavigationProperty>();
+	    navPropList.add(navProp);
+
+    	// configure EntityType
+    	entityType = new CsdlEntityType();
+    	entityType.setName(ET_CATEGORY_NAME);
+    	entityType.setProperties(Arrays.asList(id, name));
+    	entityType.setKey(Arrays.asList(propertyRef));
+    	entityType.setNavigationProperties(navPropList);
+    }
+
+
+The _NavigationPropertyBinding_ element and its attributes for the entity set “Categories”:  
+
+**Path**  
+In our example, the navigation property that we’ve defined above is named “Products”
+
+**Target**  
+In our example it is the entity set “Products”
+
+
+In our example, the definition of our “Categories” entity set looks as follows:
+
+    :::xml
+    <EntitySet Name="Categories" EntityType="OData.Demo.Category">
+      <NavigationPropertyBinding Path="Products" Target="Products"/>
+    </EntitySet>
+
+And the implementation in the _getEntitySet_ method:
+
+    :::java
+    CsdlNavigationPropertyBinding navPropBinding = new CsdlNavigationPropertyBinding();
+    navPropBinding.setTarget("Products");//target entitySet, where the nav prop points to
+    navPropBinding.setPath("Products"); // the path from entity type to navigation property
+    List<CsdlNavigationPropertyBinding> navPropBindingList = new ArrayList<CsdlNavigationPropertyBinding>();
+    navPropBindingList.add(navPropBinding);
+    entitySet.setNavigationPropertyBindings(navPropBindingList);
+
+
+
+---
+
+
+## 3.2. Implement the to-many navigation
+
+Let’s again have a look at our example, as described in the introduction section above.
+The user of our service invokes the “Categories” collection and chooses one “Category”.  
+This is done with e.g. the following URL: <http://localhost:8080/DemoService/DemoService.svc/Categories(1)>
+
+The returned response payload doesn’t contain any information about possible navigation.  
+So the user has to check the metadata document, where he can see that the entity type “Category” defines one navigation property:  
+
+![CategoryMetadata](browser_metadataCategory.JPG "The definition of a Navigation Property in the $metadata document")
+
+This means, that he can append the navigation property name to his URL, which takes him to the set of “Products” that belong to the chosen “Category”: <http://localhost:8080/DemoService/DemoService.svc/Categories(1)/Products>
+
+From the metadata we can see that the “Type” attribute defines a collection.  
+This means that the implementation has to be done in the _EntityCollectionProcessor_, since we have to provide a collection of entities.
+
+Open the class `myservice.mynamespace.service.DemoEntityCollectionProcessor.java`
+
+There, the implementation for a “normal” read operation is already in place and we have to add the case when an entity collection is expected after navigation.  
+Note that we want to keep our tutorial and our code simple, so we decide that only one step navigation is to be supported by our service.  
+This means that we can navigate only once from one entity to another one.  
+For example:  
+Categories(1)/Products  
+We don’t support navigation from one entity to an entity and then to another entity and so on  
+For example:
+Categories(1)/Products(1)/Category  
+
+Based on this assumption, in our _EntityCollectionProcessor_, we can rely on the fact that the URI can have either one or two segments.  
+This means: we can be called for the following kind of URLs:  
+
+Example URL for one sement: <http://localhost:8080/DemoService/DemoService.svc/Categories>  
+
+Example URL for two segments: <http://localhost:8080/DemoService/DemoService.svc/Categories(1)/Products>
+
+As such, in our code we distinguish these 2 cases:
+
+    :::java
+    if(segmentCount == 1){
+        // here the “normal” entity set is requested
+    }else if (segmentCount == 2){
+        // this is reached in case of navigation: DemoService.svc/Categories(1)/Products
+    }else{
+        // in our example, we don’t support URIs like Products(1)/Category/Products
+        throw new ODataApplicationException("Not supported", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(),Locale.ENGLISH);
+    }
+
+
+The segments of the URI are retrieved from the uriInfo parameter:
+
+    :::java
+    List<UriResource> resourceParts = uriInfo.getUriResourceParts();
+    int segmentCount = resourceParts.size();
+
+In both cases, we have to retrieve the list of entities to be returned.  
+For the first case, we have only one entitySet, so the implementation is straight forward:
+
+    :::java
+    EdmEntitySet startEdmEntitySet = uriResourceEntitySet.getEntitySet();
+    if(segmentCount == 1) {
+        // 2nd: fetch the data from backend for this requested EntitySetName
+        responseEntityCollection = storage.readEntitySetData(responseEdmEntitySet);
+        responseEdmEntitySet = startEdmEntitySet; //there’s only one entity set
+    }
+
+
+Now let’s focus on the second case, the navigation.
+
+Our tasks are:
+  1. depending on the chosen key of the first segment, we have to compute which and how many entities exactly have to be returned. With other words, find the right data in the backend  
+  e.g. for the category “monitors”, we have to find the right products that are monitors
+  2. find out, which entity set has to be returned (can be products, categories, etc)  
+  This _EdmEntitySet_ is required in order to properly build the context URL
+
+The following sections explain how to do that.
+
+### 3.2.1. Get the data for the response
+
+Getting the data for the response is reylized in 2 steps:  
+
+
+**A)** get the data for the first URI segment  
+in our example, we have to perform a read operation for retrieving the Category with ID 3, which is "Monitors"  
+
+**B)** get the data for the navigation  
+in our example, we have to find the products that are monitors.  
+
+With respect to data, remember that we're using sample data that we create in our Storage class which represents our kind of database-mock.  
+On startup of our service, we initialize some sample products and categories.  
+During initialization, there’s no assignment of products to its categories.  
+In our sample code, we’re doing this when requested in a hard-coded method in our _Storage_ class.  
+
+
+**A) get the data for the first URI segment**
+
+In our example, the URL would be: <http://localhost:8080/DemoService/DemoService.svc/Categories(3)/Products>  
+For this example, we would have to retrieve the Category with ID=3  
+The code looks like a normal READ operation:  
+
+    :::java
+    List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
+    Entity sourceEntity = storage.readEntityData(startEdmEntitySet, keyPredicates);
+
+In our example, the result is an entity that represents the “Monitors” – category.
+
+
+**B) get the data for the navigation**
+
+Now we have to follow the navigation, based on the retrieved entity.  
+In our example, we have to retrieve all products that are monitors.  
+
+This is backend logic, so we can directly call a helper method in our Storage class:  
+
+    :::java  
+    responseEntityCollection = storage.getRelatedEntityCollection(sourceEntity, targetEntityType);
+
+This helper method requires the source entity and returns the target collection.  
+Additionally, the method needs the _EdmEntityType_ that corresponds to the requested target.  
+In our example, we pass the “Category” (i.e. "Monitors") as source entity and the navigation target entity type, which is “Product”.  
+As a result, we get the desired “Products” collection, all products that are monitors.  
+
+After this step, we’re almost done, because we have the entity collection that our OData service returns in the response body.  
+We only need to do some more hand work: the response entity collection has to be serialized and the serializer which is in charge of doing that has to be configured properly.  
+For that we need the _EdmEntitySet_ that corresponds to the response.  
+Since it is different in case of navigation and non-navigation, we still need to retrieve it for the case of navigation.  
+
+
+### 3.2.2. Retrieve the EdmEntitySet for the response
+
+First, we have to analyze the URI, and find out if the URI segment is used for navigation.  
+As mentioned, in our simple example we assume that the second segment is used for navigation (in advanced services, a segment could as well be an action or function import, etc).  
+The navigation URI segment can then be asked for the corresponding _EdmNavigationProperty_  
+
+    :::java
+    UriResource lastSegment = resourceParts.get(1);
+    if(lastSegment instanceof UriResourceNavigation){
+	    UriResourceNavigation uriResourceNavigation = (UriResourceNavigation)lastSegment;
+	    EdmNavigationProperty edmNavigationProperty = uriResourceNavigation.getProperty();
+
+
+The bad news is that the _EdmNavigationProperty_ doesn’t know about the target _EdmEntitySet_.  
+This is as per design, just check the metadata:
+
+    :::xml
+    <EntityType Name="Category">
+	    ...
+	    <NavigationProperty Name="Products" Type="Collection(OData.Demo.Product)" Partner="Category"/>
+    </EntityType>
+
+
+The navigation property is defined on entity-type-level and as such, it does know the target entity type.  
+The target entity set is defined in the navigation property binding element on entity-set-level:  
+
+    :::xml
+    <EntitySet Name="Categories" EntityType="OData.Demo.Category">
+	    <NavigationPropertyBinding Path="Products" Target="Products"/>
+    </EntitySet>
+
+This is where we get the information that we need.  
+
+For our implementation, this means:
+  1. we need the _EdmEntiySet_ that corresponds to the first segment of the URI
+  	in our example: Categories
+  2. we need the navigation property that corresponds to the second segment of the URI
+  	in our example: Products
+
+As shown below, from the source _EdmEntitySet_ we get the binding target, based on the navigation property.  
+
+    :::java
+    EdmBindingTarget edmBindingTarget = startEntitySet.getRelatedBindingTarget(navPropName);
+    if(edmBindingTarget instanceof EdmEntitySet){
+	    navigationTargetEntitySet = (EdmEntitySet)edmBindingTarget;
+
+This target is the entity set that we need.  
+
+We move the code into the utility method _Util.getNavigationTargetEntitySet(startEdmEntitySet, edmNavigationProperty)_
+Reason is that we'll need it again, later in this tutorial.  
+
+### 3.2.3 Remaining tasks
+
+In the previous tutorials we’ve already learned what else has to be done: transform the retrieve data into an _InputStream_ i.e. serialize the content.
+Furthermore, configure the response object, i.e. set the response body, the content type and the header.  
+
+
+The following snippet shows the implementation of the _readEntityCollection(…)_ method.
+
+    :::java
+public void readEntityCollection(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat)
+                                    throws ODataApplicationException, SerializerException {
+
+	EdmEntitySet responseEdmEntitySet = null; // for building ContextURL
+	EntityCollection responseEntityCollection = null; // for the response body
+
+	// 1st retrieve the requested EntitySet from the uriInfo
+	List<UriResource> resourceParts = uriInfo.getUriResourceParts();
+	int segmentCount = resourceParts.size();
+
+	UriResource uriResource = resourceParts.get(0); // the first segment is the EntitySet
+	if (! (uriResource instanceof UriResourceEntitySet)) {
+		throw new ODataApplicationException("Only EntitySet is supported", 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; // first (and only) entitySet
+
+		// 2nd: fetch the data from backend for this requested EntitySetName
+		responseEntityCollection = storage.readEntitySetData(startEdmEntitySet);
+	}else if (segmentCount == 2){ //navigation: e.g. DemoService.svc/Categories(3)/Products
+		UriResource lastSegment = resourceParts.get(1); // don't support more complex URIs
+		if(lastSegment instanceof UriResourceNavigation){
+			UriResourceNavigation uriResourceNavigation = (UriResourceNavigation)lastSegment;
+			EdmNavigationProperty edmNavigationProperty = uriResourceNavigation.getProperty();
+			EdmEntityType targetEntityType = edmNavigationProperty.getType();
+			responseEdmEntitySet = Util.getNavigationTargetEntitySet(startEdmEntitySet, edmNavigationProperty);
+
+			// 2nd: fetch the data from backend
+			// first fetch the entity where the first segment of the URI points to
+            // e.g. Categories(3)/Products first find the single entity: Category(3)
+			List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
+			Entity sourceEntity = storage.readEntityData(startEdmEntitySet, keyPredicates);
+			// 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);
+			}
+			// then fetch the entity collection where the entity navigates to
+			responseEntityCollection = storage.getRelatedEntityCollection(sourceEntity, targetEntityType);
+		}
+	}else{ // this would be the case for e.g. Products(1)/Category/Products
+		throw new ODataApplicationException("Not supported", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(),Locale.ROOT);
+	}
+
+	// 3rd: create and configure a serializer  
+	ContextURL contextUrl = ContextURL.with().entitySet(responseEdmEntitySet).build();
+	EntityCollectionSerializerOptions opts = EntityCollectionSerializerOptions.with().contextURL(contextUrl).build();
+	EdmEntityType edmEntityType = responseEdmEntitySet.getEntityType();
+
+	ODataSerializer serializer = odata.createSerializer(ODataFormat.fromContentType(responseFormat));
+	SerializerResult serializerResult = serializer.entityCollection(this.srvMetadata, edmEntityType, responseEntityCollection, opts);
+
+	// 4th: configure the response object: set the body, headers and status code
+	response.setContent(serializerResult.getContent());
+	response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+	response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+}
+
+## 3.3. Implement the to-one navigation
+
+As for the to-one navigation, it is the case if the navigation target is a single entity, not a collection.  
+In our example, the following URL represents a to-one navigation: <http://localhost:8080/DemoService/DemoService.svc/Products(1)/Category>  
+
+The user of our service has chosen a product and wants to know to which category it belongs. He can find it out by following the navigation property.
+As per design, a product can only belong to **one** category (obviously, a product can only be a Notebook or a Monitor, not both). Therefore in our service, we’ve defined a navigation property that is not of type collection:  
+
+    :::xml
+    <NavigationProperty
+        Name="Category"
+        Type="OData.Demo.Category"
+        Nullable="false"
+        Partner="Products"/>
+
+So when the user follows the navigation property in order to display the product category, he expects a response that contains only one entry.  
+This means that we have to do the implementation in the _EntityProcessor_.
+
+Open the class _myservice.mynamespace.service.DemoEntityProcessor.java_
+
+As usual, we first have to analyze the URI.  
+Just like we did in the _EntityCollectionProcessor_, we have to distinguish between navigation and “normal” read of an entity:  
+
+    :::java
+    if(segmentCount == 1){
+        // in case of directly adressing of an entity
+    }else if (segmentCount == 2){
+        // this is reached in case of navigation
+    }
+
+In the following section, we’ll focus on the navigation case only.  
+In our example, our task is to find the category of a chosen product.  
+Again, we have to first fetch the chosen product (first URI segment) from our database-mock and in a second step, we have to ask our database-mock for the corresponding category.  
+This final entity is then serialized and set as response body for the _readEntity_ method, which we’re implementing.  
+
+**A) get the data for the first URI segment**
+
+In our example, we have to perform a read operation for retrieving the product with ID 1: <http://localhost:8080/DemoService/DemoService.svc/Products(1)/Category>  
+
+The code is the same like in the previous chapter (to-many navigation):  
+
+    :::java
+    List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
+    Entity sourceEntity = storage.readEntityData(startEdmEntitySet, keyPredicates);
+
+
+**B) get the data for the navigation**
+
+Now we have to follow the navigation, based on the retrieved entity.  
+In our example, we have to find the category corresponding to the chosen product.  
+Therefore, we invoke our helper method and pass the source Entity (Product) and the required target entity type (Category). The method will find the category which is related to the chosen product.  
+
+    :::java
+    responseEntity = storage.getRelatedEntity(sourceEntity, responseEdmEntityType);
+
+Before we can serialize the _responseEntity_, we have to retrieve the _EdmEntitySet_ that corresponds to the response entity, because we need it for building the ContextURL.
+
+The procedure is the same like in the chapter above, where we treated the to-many navigation:
+
+    :::java
+    EdmNavigationProperty edmNavigationProperty = uriResourceNavigation.getProperty();
+    responseEdmEntityType = edmNavigationProperty.getType();
+    responseEdmEntitySet = Util.getNavigationTargetEntitySet(startEdmEntitySet, edmNavigationProperty);
+
+In our example, the value of the variable _responseEdmEntitySet_ will be “Categories” and it will be used for building the contextURL, which will look as follows:
+
+    :::xml  
+    "$metadata#Categories/$entity"
+
+
+## 3.4. Implement the to-many navigation with key access
+
+"Navigation with key access" means that we have a to-many navigation, like navigating from a chosen category to the list of corresponding products: <http://localhost:8080/DemoService/DemoService.svc/Categories(3)/Products>
+
+but in addition, we want to read only one of the collected products, which is directly addressed by its key:   <http://localhost:8080/DemoService/DemoService.svc/Categories(3)/Products(5)>
+
+From this URL, we can assume that the _EntityProcessor.java_ is the relevant place to handle this request in our code.  
+
+The steps to find the requested entity are:  
+
+  1. Do a read operation for the first segment (same as in the previous chapter)  
+  In our example, this would be read entity for: */Categories(3)*
+  2. Follow the navigation to get the collection of the second segment  
+  In our example, this would be get the entity collection for: */Categories(3)/Products*
+  3. Pick the requested entity from the collection  
+  In our example, retrieve the product with ID=5, which is contained in the collection */Categories(3)/Products(5)*
+
+
+
+We can assume, that our database-mock is able to perform step 2 and 3 together.
+
+In our class _myservice.mynamespace.service.DemoEntityProcessor.java_, we’ve already added the navigation capability for to-one navigation.
+How can we find out that we aren’t called for a to-one navigation, but instead, we’re responding to a to-many navigation with key access?  
+The difference is the “key predicate”.  
+The necessary info about it can be obtained from the URI segment.  
+In the first chapter, we’ve already learned that there’s a special interface responsible for navigation segments, the _org.apache.olingo.server.api.uri.UriResourceNavigation_  
+It also provides a method _getKeyPredicates()_
+We can make use of it in order to distinguish between “to-one navigation” and “navigation with key access”.  
+If the call to
+
+    :::java
+    List<UriParmeter> navKeyPredicates = uriResourceNavigation.getKeyPredicates();
+
+returns an empty list, then we can assume that our OData service has been called for a “to-one navigation”.  
+This to-one navigation has been explained in the chapter 3.3. above.
+If  the service request is like
+/Categories(3)/Products(5)  
+then the method _getKeyPredicates()_ will return a list of with one element that contains ID=5
+
+In our implementation of the _EntityProcessor_, we add the following code:
+
+    :::java
+    List<UriParameter> navKeyPredicates = uriResourceNavigation.getKeyPredicates();
+    if(navKeyPredicates.isEmpty()){
+	    responseEntity = storage.getRelatedEntity(sourceEntity, responseEdmEntityType);
+    }else{
+	    responseEntity = storage.getRelatedEntity(sourceEntity, responseEdmEntityType, navKeyPredicates);
+    }
+
+We get the key predicates for the navigation segment.  
+Then we check if returned list is empty.  
+If yes, we use the line that we implemented in chapter 3.3.  
+If not, we have to create a new helper method that uses the key predicates for retrieving the desired entity.  
+The new helper method
+
+    :::java
+    responseEntity = storage.getRelatedEntity(sourceEntity, responseEdmEntityType, navKeyPredicates);
+
+will take care of getting the collection of products (_responseEntityType_) that are in scope of the chosen category (_sourceEntity_) and will then pick the requested product, based on the given key (_navKeyPredicates_).
+
+One last thing to consider:
+As we mentioned above, the user of our service is expected to specify a key of a product that is contained in the collection of products that is addressed by e.g.
+/Categories(3)/Products  
+e.g.
+/Categories(3)/Products(5)  
+But he might specify a product ID that is existing, but not valid for the addressed navigation.
+e.g.
+/Categories(3)/Products(1)  
+With other words: it is not valid to navigate from category "Monitors" to a product like "Notebook Basic 15"
+
+If this is the case, we have to throw an appropriate exception.  
+However, in our simple example we’re satisfied with simply checking if an entity was found at all:
+
+    :::java
+    if(responseEntity == null) {
+	    throw new ODataApplicationException("Nothing found.", HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ROOT);
+    }
+
+**Note**  
+When implementing this navigation for the first time, our first intention might have been:  
+Let’s just ignore the first segment and simply do a read operation for /Products(5)  
+Which would mean, from the list of all products, pick the one with ID=5  
+Why not?  
+The answer is that we cannot assume that the requested Product is automatically belonging to the specified Category.
+E.g. in our example, the following URI should throw an error:
+Categories(3)/Products(1)  
+As we know, Categories(3) is “Monitors” and Product(1) is a “Notebook”  
+
+
+That’s it.
+We don’t need to do an additional effort to retrieve the _EdmEntitySet_ for the ContextURL, because this has already been implemented in our _DemoEntityProcessor_ in the context of the previous chapter 3.3.
+
+
+So now we can finally have a look at the full implementation of the _readEntity()_ method, the covers both the cases of chapter 3.3. and 3.4.
+
+    :::java
+    public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat)
+				throws ODataApplicationException, SerializerException {
+
+
+    	EdmEntityType responseEdmEntityType = null; // we'll need this to build the ContextURL
+    	Entity responseEntity = null; // required for serialization of the response body
+    	EdmEntitySet responseEdmEntitySet = null; // we need this for building the contextUrl
+
+    	// 1st step: retrieve the requested Entity:
+        // can be "normal" read operation, or navigation (to-one)
+    	List<UriResource> resourceParts = uriInfo.getUriResourceParts();
+    	int segmentCount = resourceParts.size();
+
+    	UriResource uriResource = resourceParts.get(0);
+    	if (! (uriResource instanceof UriResourceEntitySet)) {
+    		throw new ODataApplicationException("Only EntitySet is supported", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(),
+    		                                        Locale.ROOT);
+    	}
+
+    	UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) uriResource;
+    	EdmEntitySet startEdmEntitySet = uriResourceEntitySet.getEntitySet();
+
+    	// Analyze the URI segments
+    	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
+    		UriResource navSegment = resourceParts.get(1);
+    		if(navSegment instanceof UriResourceNavigation){
+    			UriResourceNavigation uriResourceNavigation = (UriResourceNavigation) navSegment;
+    			EdmNavigationProperty edmNavigationProperty = uriResourceNavigation.getProperty();
+    			responseEdmEntityType = edmNavigationProperty.getType();
+    			responseEdmEntitySet = Util.getNavigationTargetEntitySet(startEdmEntitySet, edmNavigationProperty);
+
+    			// 2nd: fetch the data from backend.
+                // for:  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);
+
+    			// now we have to check if the navigation is
+    			// a) to-one: e.g. Products(1)/Category
+    			// b) to-many with key: e.g. Categories(3)/Products(5)
+    			List<UriParameter> navKeyPredicates = uriResourceNavigation.getKeyPredicates();
+
+    			if(navKeyPredicates.isEmpty()){
+                    // e.g. DemoService.svc/Products(1)/Category
+    				responseEntity = storage.getRelatedEntity(sourceEntity, responseEdmEntityType);
+    			}else{ // e.g. DemoService.svc/Categories(3)/Products(5)
+    				responseEntity = storage.getRelatedEntity(sourceEntity, responseEdmEntityType, navKeyPredicates);
+    			}
+    		}
+    	}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);
+    	}
+
+    	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);
+    	}
+
+    	// 3. serialize
+    	ContextURL contextUrl = ContextURL.with().entitySet(responseEdmEntitySet).suffix(Suffix.ENTITY).build();
+    	EntitySerializerOptions opts = EntitySerializerOptions.with().contextURL(contextUrl).build();  
+
+    	ODataFormat oDataFormat = ODataFormat.fromContentType(responseFormat);
+    	ODataSerializer serializer = this.odata.createSerializer(oDataFormat);
+    	SerializerResult serializerResult = serializer.entity(this.srvMetadata, responseEdmEntityType, responseEntity, opts);
+
+    	//4. configure the response object
+    	response.setContent(serializerResult.getContent());
+    	response.setStatusCode(HttpStatusCode.OK.getStatusCode());
+    	response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
+    }
+
+---
+
+# 4. Run the implemented service
+
+After building and deploying your service to your server, you can try the following URLs:  
+
+  * Metadata and Service documents  
+    * <http://localhost:8080/DemoService/DemoService.svc/$metadata>
+    * <http://localhost:8080/DemoService/DemoService.svc>
+  * “Normal” query of both entity sets  
+    * <http://localhost:8080/DemoService/DemoService.svc/Products>
+    * <http://localhost:8080/DemoService/DemoService.svc/Categories>
+  * “Normal” read of both entity types  
+    * <http://localhost:8080/DemoService/DemoService.svc/Products(1)>
+    * <http://localhost:8080/DemoService/DemoService.svc/Categories(3)>
+  * “to-many” navigation  
+    * <http://localhost:8080/DemoService/DemoService.svc/Categories(3)/Products>
+  * “to-one” navigation  
+    * <http://localhost:8080/DemoService/DemoService.svc/Products(1)/Category>
+  * “to-many” navigation with key access  
+    * <http://localhost:8080/DemoService/DemoService.svc/Categories(1)/Products(2)>
+  * “to-many” navigation with key access of invalid key, throwing an error  
+    * <http://localhost:8080/DemoService/DemoService.svc/Categories(1)/Products(3)>
+
+
+---
+
+# 5. Summary
+
+In this tutorial we have learned how to add navigation capabilities to an OData service.  
+We’ve implemented the to-many and to-one relationship and also the READ access to one entity after a to-many navigation.  
+We’ve restricted the navigation to two segments, no more than navigating from one entity to another one.  
+The modification of relations has not been covered by this tutorial.
+Check the *Links* section for more OData V4 tutorials.  
+
+---
+
+# 6. Links
+
+Tutorial OData V4 service, part 1: [Read Entity Collection](/doc/odata4/tutorials/read/tutorial_read.html) | [sample project zip](http://olingo.apache.org/doc/odata4/tutorials/read/sample/DemoService_Tutorial_Read.zip)  
+Tutorial OData V4 service, part 2: [Read Entity, Read Property](/doc/odata4/tutorials/readep/tutorial_readep.html) | [sample project zip](http://www.apache.org/dyn/closer.cgi/olingo/odata4/Tutorials/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](http://www.apache.org/dyn/closer.cgi/olingo/odata4/Tutorials/DemoService_Tutorial_Write.zip)
+Tutorial OData V4 service, part 4: Navigation (this page) | sample project zip
+Tutorial OData V4 service, part 5: System Query Options  (to be announced)
+
+OData specification: http://odata.org/
+Olingo Javadoc: http://olingo.apache.org/javadoc/odata4/index.html
+
+---
+
+# 7. Appendix: code snippets
+
+When reaching the point where your OData service has to become productive and support complex scenarions, you’ll find the following code snippets useful.  
+
+## 7.1. Find the EdmEntitySet for the navigation target
+
+    :::java
+    public static EdmEntitySet getNavigationTargetEntitySet(final UriInfoResource uriInfo) throws ODataApplicationException {
+
+    	EdmEntitySet entitySet;
+    	final List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+
+    	// First must be entity set (hence function imports are not supported here).
+    	if (resourcePaths.get(0) instanceof UriResourceEntitySet) {
+    		entitySet = ((UriResourceEntitySet) resourcePaths.get(0)).getEntitySet();
+    	} else {
+    		throw new ODataApplicationException("Invalid resource type.",
+    				HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
+    	}
+
+    	int navigationCount = 0;
+    	while (entitySet != null
+    		&& ++navigationCount < resourcePaths.size()
+    		&& resourcePaths.get(navigationCount) instanceof UriResourceNavigation) {
+    		final UriResourceNavigation uriResourceNavigation = (UriResourceNavigation) resourcePaths.get(navigationCount);
+    		final EdmBindingTarget target = entitySet.getRelatedBindingTarget(uriResourceNavigation.getProperty().getName());
+    		if (target instanceof EdmEntitySet) {
+    			entitySet = (EdmEntitySet) target;
+    		} else {
+    			throw new ODataApplicationException("Singletons not supported", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(),
+    			                                     Locale.ROOT);
+    		}
+    	}
+
+    	return entitySet;
+    }
+
+## 7.2. Find the last navigation segment
+
+    :::java
+    public static UriResourceNavigation getLastNavigation(final UriInfoResource uriInfo) {
+
+    	final List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
+    	int navigationCount = 1;
+    	while (navigationCount < resourcePaths.size()
+    		&& resourcePaths.get(navigationCount) instanceof UriResourceNavigation) {
+    		navigationCount++;
+    	}
+
+    	return (UriResourceNavigation) resourcePaths.get(--navigationCount);
+    }

Propchange: websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/TutorialPart4.md
------------------------------------------------------------------------------
    svn:executable = *

Added: websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/browser_categories.JPG
==============================================================================
Binary file - no diff available.

Propchange: websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/browser_categories.JPG
------------------------------------------------------------------------------
    svn:executable = *

Propchange: websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/browser_categories.JPG
------------------------------------------------------------------------------
    svn:mime-type = image/jpeg

Added: websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/browser_categories1.jpg
==============================================================================
Binary file - no diff available.

Propchange: websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/browser_categories1.jpg
------------------------------------------------------------------------------
    svn:executable = *

Propchange: websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/browser_categories1.jpg
------------------------------------------------------------------------------
    svn:mime-type = image/jpeg

Added: websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/browser_categories1_products.jpg
==============================================================================
Binary file - no diff available.

Propchange: websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/browser_categories1_products.jpg
------------------------------------------------------------------------------
    svn:executable = *

Propchange: websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/browser_categories1_products.jpg
------------------------------------------------------------------------------
    svn:mime-type = image/jpeg

Added: websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/browser_metadataCategory.JPG
==============================================================================
Binary file - no diff available.

Propchange: websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/browser_metadataCategory.JPG
------------------------------------------------------------------------------
    svn:executable = *

Propchange: websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/browser_metadataCategory.JPG
------------------------------------------------------------------------------
    svn:mime-type = image/jpeg

Added: websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/model.JPG
==============================================================================
Binary file - no diff available.

Propchange: websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/model.JPG
------------------------------------------------------------------------------
    svn:executable = *

Propchange: websites/staging/olingo/trunk/content/doc/odata4/tutorials/navigation/model.JPG
------------------------------------------------------------------------------
    svn:mime-type = image/jpeg

Modified: websites/staging/olingo/trunk/content/doc/odata4/tutorials/read/tutorial_read.html
==============================================================================
--- websites/staging/olingo/trunk/content/doc/odata4/tutorials/read/tutorial_read.html (original)
+++ websites/staging/olingo/trunk/content/doc/odata4/tutorials/read/tutorial_read.html Wed Jul  8 12:15:07 2015
@@ -86,7 +86,18 @@
 
 			</div><!--/.nav-collapse -->
         </div><!--/.container-fluid -->
-      </div><!-- Main component for a primary marketing message or call to action --><h1 id="how-to-build-an-odata-service-with-olingo-v4">How to build an OData Service with Olingo V4</h1>
+      </div><!-- Main component for a primary marketing message or call to action --><style type="text/css">
+/* The following code is added by mdx_elementid.py
+   It was originally lifted from http://subversion.apache.org/style/site.css */
+/*
+ * Hide class="elementid-permalink", except when an enclosing heading
+ * has the :hover property.
+ */
+.headerlink, .elementid-permalink {
+  visibility: hidden;
+}
+h2:hover > .headerlink, h3:hover > .headerlink, h1:hover > .headerlink, h6:hover > .headerlink, h4:hover > .headerlink, h5:hover > .headerlink, dt:hover > .elementid-permalink { visibility: visible }</style>
+<h1 id="how-to-build-an-odata-service-with-olingo-v4">How to build an OData Service with Olingo V4<a class="headerlink" href="#how-to-build-an-odata-service-with-olingo-v4" title="Permanent link">&para;</a></h1>
 <p>This tutorial guides you through the steps required to write an OData Service based on the Olingo OData 4.0 Library for Java (based on current <em>Olingo 4.0.0-beta-03 release</em> which can be get via the <a href="../../download.html">Download-Page</a>).</p>
 <p>The final result can be download <a href="http://www.apache.org/dyn/closer.cgi/olingo/odata4/Tutorials/DemoService_Tutorial_Read.zip">here</a> (<a href="https://dist.apache.org/repos/dist/release/olingo/odata4/Tutorials/DemoService_Tutorial_Read.zip.md5">md5</a>, <a href="https://dist.apache.org/repos/dist/release/olingo/odata4/Tutorials/DemoService_Tutorial_Read.zip.sha512">sha512</a>, <a href="https://dist.apache.org/repos/dist/release/olingo/odata4/Tutorials/DemoService_Tutorial_Read.zip.asc">pgp</a>).</p>
 <p>We will create a Web Application and deploy it on a local Tomcat server.
@@ -157,7 +168,7 @@ Furthermore, for building with maven, we
 <li>Summary</li>
 </ol>
 <hr />
-<h1 id="1-prerequisites">1. Prerequisites</h1>
+<h1 id="1-prerequisites">1. Prerequisites<a class="headerlink" href="#1-prerequisites" title="Permanent link">&para;</a></h1>
 <p>In order to follow this tutorial, you should have</p>
 <ul>
 <li>Basic knowledge about OData and OData V4</li>
@@ -166,7 +177,7 @@ Furthermore, for building with maven, we
 <li>Optional: knowledge about building with Maven</li>
 </ul>
 <hr />
-<h1 id="2-preparation">2. Preparation</h1>
+<h1 id="2-preparation">2. Preparation<a class="headerlink" href="#2-preparation" title="Permanent link">&para;</a></h1>
 <p>Before starting off with the creation of our OData service, we need to prepare the following:</p>
 <ol>
 <li>Installed JDK 1.6 (or higher version)</li>
@@ -179,7 +190,7 @@ This means, you should install the pre-p
 <p><img alt="eclipseDownload" src="eclipseDownload.png" title="The Eclipse EE download" /></p>
 <p>This Eclipse package contains an embedded server and also an integrated Maven builder.</p>
 <hr />
-<h1 id="3-create-project">3. Create Project</h1>
+<h1 id="3-create-project">3. Create Project<a class="headerlink" href="#3-create-project" title="Permanent link">&para;</a></h1>
 <p>The recommended procedure to create a project is to use Maven, because it offers an archetype for generating the project skeleton.
 Furthermore, using Maven is convenient for managing the build dependencies.
 The description within this section is based on an Eclipse installation that contains the Maven integration.</p>
@@ -207,59 +218,59 @@ In the pom.xml file, we specify the depe
 Furthermore, the <em>pom.xml</em> file tells Maven which output we want to have as result of our build. In our case, this is a war file.</p>
 <p>In our example, the pom.xml file looks as follows:</p>
 <div class="codehilite"><pre><span class="nt">&lt;project</span> <span class="na">xmlns=</span><span class="s">&quot;http://maven.apache.org/POM/4.0.0&quot;</span> <span class="na">xmlns:xsi=</span><span class="s">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span>
-    <span class="na">xsi:schemaLocation=</span><span class="s">&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;</span><span class="nt">&gt;</span>
-    <span class="nt">&lt;modelVersion&gt;</span>4.0.0<span class="nt">&lt;/modelVersion&gt;</span>
-    <span class="nt">&lt;groupId&gt;</span>my.group.id<span class="nt">&lt;/groupId&gt;</span>
-    <span class="nt">&lt;artifactId&gt;</span>DemoService<span class="nt">&lt;/artifactId&gt;</span>
-    <span class="nt">&lt;packaging&gt;</span>war<span class="nt">&lt;/packaging&gt;</span>
-    <span class="nt">&lt;version&gt;</span>0.0.1<span class="nt">&lt;/version&gt;</span>
-
-    <span class="nt">&lt;name&gt;</span>DemoService Maven Webapp<span class="nt">&lt;/name&gt;</span>
-
-    <span class="nt">&lt;properties&gt;</span>
-        <span class="nt">&lt;javax.version&gt;</span>2.5<span class="nt">&lt;/javax.version&gt;</span>
-        <span class="nt">&lt;odata.version&gt;</span>4.0.0-beta-03<span class="nt">&lt;/odata.version&gt;</span>
-        <span class="nt">&lt;slf4j.version&gt;</span>1.7.7<span class="nt">&lt;/slf4j.version&gt;</span>
-    <span class="nt">&lt;/properties&gt;</span>
-
-    <span class="nt">&lt;dependencies&gt;</span>
-        <span class="nt">&lt;dependency&gt;</span>
-            <span class="nt">&lt;groupId&gt;</span>javax.servlet<span class="nt">&lt;/groupId&gt;</span>
-            <span class="nt">&lt;artifactId&gt;</span>servlet-api<span class="nt">&lt;/artifactId&gt;</span>
-            <span class="nt">&lt;version&gt;</span>${javax.version}<span class="nt">&lt;/version&gt;</span>
-            <span class="nt">&lt;scope&gt;</span>provided<span class="nt">&lt;/scope&gt;</span>
-        <span class="nt">&lt;/dependency&gt;</span>
-
-        <span class="nt">&lt;dependency&gt;</span>
-            <span class="nt">&lt;groupId&gt;</span>org.apache.olingo<span class="nt">&lt;/groupId&gt;</span>
-            <span class="nt">&lt;artifactId&gt;</span>odata-server-api<span class="nt">&lt;/artifactId&gt;</span>
-            <span class="nt">&lt;version&gt;</span>${odata.version}<span class="nt">&lt;/version&gt;</span>
-        <span class="nt">&lt;/dependency&gt;</span>
-        <span class="nt">&lt;dependency&gt;</span>
-            <span class="nt">&lt;groupId&gt;</span>org.apache.olingo<span class="nt">&lt;/groupId&gt;</span>
-            <span class="nt">&lt;artifactId&gt;</span>odata-server-core<span class="nt">&lt;/artifactId&gt;</span>
-            <span class="nt">&lt;version&gt;</span>${odata.version}<span class="nt">&lt;/version&gt;</span>
-            <span class="nt">&lt;scope&gt;</span>runtime<span class="nt">&lt;/scope&gt;</span>
-        <span class="nt">&lt;/dependency&gt;</span>
-
-        <span class="nt">&lt;dependency&gt;</span>
-            <span class="nt">&lt;groupId&gt;</span>org.apache.olingo<span class="nt">&lt;/groupId&gt;</span>
-            <span class="nt">&lt;artifactId&gt;</span>odata-commons-api<span class="nt">&lt;/artifactId&gt;</span>
-            <span class="nt">&lt;version&gt;</span>${odata.version}<span class="nt">&lt;/version&gt;</span>
-        <span class="nt">&lt;/dependency&gt;</span>
-        <span class="nt">&lt;dependency&gt;</span>
-            <span class="nt">&lt;groupId&gt;</span>org.apache.olingo<span class="nt">&lt;/groupId&gt;</span>
-            <span class="nt">&lt;artifactId&gt;</span>odata-commons-core<span class="nt">&lt;/artifactId&gt;</span>
-            <span class="nt">&lt;version&gt;</span>${odata.version}<span class="nt">&lt;/version&gt;</span>
-        <span class="nt">&lt;/dependency&gt;</span>
-
-        <span class="nt">&lt;dependency&gt;</span>
-            <span class="nt">&lt;groupId&gt;</span>org.slf4j<span class="nt">&lt;/groupId&gt;</span>
-            <span class="nt">&lt;artifactId&gt;</span>slf4j-simple<span class="nt">&lt;/artifactId&gt;</span>
-            <span class="nt">&lt;version&gt;</span>${slf4j.version}<span class="nt">&lt;/version&gt;</span>
-            <span class="nt">&lt;scope&gt;</span>runtime<span class="nt">&lt;/scope&gt;</span>
-        <span class="nt">&lt;/dependency&gt;</span>
-    <span class="nt">&lt;/dependencies&gt;</span>
+  <span class="na">xsi:schemaLocation=</span><span class="s">&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;</span><span class="nt">&gt;</span>
+  <span class="nt">&lt;modelVersion&gt;</span>4.0.0<span class="nt">&lt;/modelVersion&gt;</span>
+  <span class="nt">&lt;groupId&gt;</span>my.group.id<span class="nt">&lt;/groupId&gt;</span>
+  <span class="nt">&lt;artifactId&gt;</span>DemoService<span class="nt">&lt;/artifactId&gt;</span>
+  <span class="nt">&lt;packaging&gt;</span>war<span class="nt">&lt;/packaging&gt;</span>
+  <span class="nt">&lt;version&gt;</span>0.0.1<span class="nt">&lt;/version&gt;</span>
+
+  <span class="nt">&lt;name&gt;</span>DemoService Maven Webapp<span class="nt">&lt;/name&gt;</span>
+
+  <span class="nt">&lt;properties&gt;</span>
+    <span class="nt">&lt;javax.version&gt;</span>2.5<span class="nt">&lt;/javax.version&gt;</span>
+    <span class="nt">&lt;odata.version&gt;</span>4.0.0-beta-03<span class="nt">&lt;/odata.version&gt;</span>
+    <span class="nt">&lt;slf4j.version&gt;</span>1.7.7<span class="nt">&lt;/slf4j.version&gt;</span>
+  <span class="nt">&lt;/properties&gt;</span>
+
+  <span class="nt">&lt;dependencies&gt;</span>
+    <span class="nt">&lt;dependency&gt;</span>
+      <span class="nt">&lt;groupId&gt;</span>javax.servlet<span class="nt">&lt;/groupId&gt;</span>
+      <span class="nt">&lt;artifactId&gt;</span>servlet-api<span class="nt">&lt;/artifactId&gt;</span>
+      <span class="nt">&lt;version&gt;</span>${javax.version}<span class="nt">&lt;/version&gt;</span>
+      <span class="nt">&lt;scope&gt;</span>provided<span class="nt">&lt;/scope&gt;</span>
+    <span class="nt">&lt;/dependency&gt;</span>
+
+    <span class="nt">&lt;dependency&gt;</span>
+      <span class="nt">&lt;groupId&gt;</span>org.apache.olingo<span class="nt">&lt;/groupId&gt;</span>
+      <span class="nt">&lt;artifactId&gt;</span>odata-server-api<span class="nt">&lt;/artifactId&gt;</span>
+      <span class="nt">&lt;version&gt;</span>${odata.version}<span class="nt">&lt;/version&gt;</span>
+    <span class="nt">&lt;/dependency&gt;</span>
+    <span class="nt">&lt;dependency&gt;</span>
+      <span class="nt">&lt;groupId&gt;</span>org.apache.olingo<span class="nt">&lt;/groupId&gt;</span>
+      <span class="nt">&lt;artifactId&gt;</span>odata-server-core<span class="nt">&lt;/artifactId&gt;</span>
+      <span class="nt">&lt;version&gt;</span>${odata.version}<span class="nt">&lt;/version&gt;</span>
+      <span class="nt">&lt;scope&gt;</span>runtime<span class="nt">&lt;/scope&gt;</span>
+    <span class="nt">&lt;/dependency&gt;</span>
+
+    <span class="nt">&lt;dependency&gt;</span>
+      <span class="nt">&lt;groupId&gt;</span>org.apache.olingo<span class="nt">&lt;/groupId&gt;</span>
+      <span class="nt">&lt;artifactId&gt;</span>odata-commons-api<span class="nt">&lt;/artifactId&gt;</span>
+      <span class="nt">&lt;version&gt;</span>${odata.version}<span class="nt">&lt;/version&gt;</span>
+    <span class="nt">&lt;/dependency&gt;</span>
+    <span class="nt">&lt;dependency&gt;</span>
+      <span class="nt">&lt;groupId&gt;</span>org.apache.olingo<span class="nt">&lt;/groupId&gt;</span>
+      <span class="nt">&lt;artifactId&gt;</span>odata-commons-core<span class="nt">&lt;/artifactId&gt;</span>
+      <span class="nt">&lt;version&gt;</span>${odata.version}<span class="nt">&lt;/version&gt;</span>
+    <span class="nt">&lt;/dependency&gt;</span>
+
+    <span class="nt">&lt;dependency&gt;</span>
+      <span class="nt">&lt;groupId&gt;</span>org.slf4j<span class="nt">&lt;/groupId&gt;</span>
+      <span class="nt">&lt;artifactId&gt;</span>slf4j-simple<span class="nt">&lt;/artifactId&gt;</span>
+      <span class="nt">&lt;version&gt;</span>${slf4j.version}<span class="nt">&lt;/version&gt;</span>
+      <span class="nt">&lt;scope&gt;</span>runtime<span class="nt">&lt;/scope&gt;</span>
+    <span class="nt">&lt;/dependency&gt;</span>
+  <span class="nt">&lt;/dependencies&gt;</span>
 <span class="nt">&lt;/project&gt;</span>
 </pre></div>
 
@@ -292,7 +303,7 @@ If maven provides an error marker right
 From context menu on project node, choose Maven -&gt; update Project -&gt; <your project></p>
 </blockquote>
 <hr />
-<h1 id="4-implementation">4. Implementation</h1>
+<h1 id="4-implementation">4. Implementation<a class="headerlink" href="#4-implementation" title="Permanent link">&para;</a></h1>
 <p>The implementation of an OData service based on Olingo server library can be grouped in the following steps:  </p>
 <ul>
 <li>Declaring the metadata of the service</li>
@@ -303,8 +314,8 @@ From context menu on project node, choos
 <li>Web application implementation</li>
 </ul>
 <p>The following section will guide you through every step in detail.</p>
-<h2 id="41-declare-the-metadata">4.1. Declare the metadata</h2>
-<h3 id="411-background">4.1.1. Background</h3>
+<h2 id="41-declare-the-metadata">4.1. Declare the metadata<a class="headerlink" href="#41-declare-the-metadata" title="Permanent link">&para;</a></h2>
+<h3 id="411-background">4.1.1. Background<a class="headerlink" href="#411-background" title="Permanent link">&para;</a></h3>
 <p>According to the OData specification, an OData service has to declare its structure in the so-called <em>metadata document</em>.
 This document defines the contract, such that the user of the service knows which requests can be executed, the structure of the result and how the service can be navigated.</p>
 <p>The metadata document can be invoked via the following URI:</p>
@@ -321,7 +332,7 @@ Here, the user can see which Entity Coll
 
 <p>The information that is given by these 2 URIs, has to be implemented in the service code.
 Olingo provides API for it and we will use it in the implementation of our <em>CsdlEdmProvider</em>.</p>
-<h3 id="412-create-class">4.1.2. Create class</h3>
+<h3 id="412-create-class">4.1.2. Create class<a class="headerlink" href="#412-create-class" title="Permanent link">&para;</a></h3>
 <p>Create package <em>myservice.mynamespace.service</em><br />
 Create class <em>DemoEdmProvider</em> and specify the superclass <em>org.apache.olingo.commons.api.edm.provider.CsdlAbstractEdmProvider</em></p>
 <p>Note: <strong>edm</strong> is the abbreviation for <strong>Entity Data Model</strong>.<br />
@@ -332,7 +343,7 @@ Accordingly, we understand that the <em>
 <p>Some of these interfaces are going to be used in the following sections.
 Note:
 You can find the Javadoc here: <a href="http://olingo.apache.org/javadoc/odata4/index.html">http://olingo.apache.org/javadoc/odata4/index.html</a></p>
-<h3 id="413-implement-the-required-methods">4.1.3. Implement the required methods</h3>
+<h3 id="413-implement-the-required-methods">4.1.3. Implement the required methods<a class="headerlink" href="#413-implement-the-required-methods" title="Permanent link">&para;</a></h3>
 <p>The base class <em>CsdlAbstractEdmProvider</em> provides methods for declaring the metadata of all OData elements.</p>
 <p>For example:
 <em> The entries that are displayed in the service document are provided by the method
@@ -342,15 +353,15 @@ You can find the Javadoc here: <a href="
 These are:</p>
 <ul>
 <li><strong><em>getEntityType()</em></strong><br />
-    Here we declare the EntityType “Product” and a few of its properties</li>
+  Here we declare the EntityType “Product” and a few of its properties</li>
 <li><strong><em>getEntitySet()</em></strong><br />
-    Here we state that the list of products can be called via the EntitySet “Products”</li>
+  Here we state that the list of products can be called via the EntitySet “Products”</li>
 <li><strong><em>getEntityContainer()</em></strong><br />
-    Here we provide a Container element that is necessary to host the EntitySet.</li>
+  Here we provide a Container element that is necessary to host the EntitySet.</li>
 <li><strong><em>getSchemas()</em></strong><br />
-    The Schema is the root element to carry the elements.</li>
+  The Schema is the root element to carry the elements.</li>
 <li><strong><em>getEntityContainerInfo()</em></strong>
-    Information about the EntityContainer to be displayed in the Service Document</li>
+  Information about the EntityContainer to be displayed in the Service Document</li>
 </ul>
 <p>In Eclipse, in order to select the methods to override, right click into the Java editor and from the context menu choose <em>Source -&gt; Override/Implement Methods…</em>
 Select the mentioned methods and press OK.</p>
@@ -442,16 +453,16 @@ In our example, we have only one <em>Ent
 <div class="codehilite"><pre><span class="nd">@Override</span>
 <span class="kd">public</span> <span class="n">EntityContainer</span> <span class="nf">getEntityContainer</span><span class="o">()</span> <span class="kd">throws</span> <span class="n">ODataException</span> <span class="o">{</span>
 
-    <span class="c1">// create EntitySets</span>
-    <span class="n">List</span><span class="o">&lt;</span><span class="n">EntitySet</span><span class="o">&gt;</span> <span class="n">entitySets</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">EntitySet</span><span class="o">&gt;();</span>
-    <span class="n">entitySets</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">getEntitySet</span><span class="o">(</span><span class="n">CONTAINER</span><span class="o">,</span> <span class="n">ES_PRODUCTS_NAME</span><span class="o">));</span>
-
-    <span class="c1">// create EntityContainer</span>
-    <span class="n">EntityContainer</span> <span class="n">entityContainer</span> <span class="o">=</span> <span class="k">new</span> <span class="n">EntityContainer</span><span class="o">();</span>
-    <span class="n">entityContainer</span><span class="o">.</span><span class="na">setName</span><span class="o">(</span><span class="n">CONTAINER_NAME</span><span class="o">);</span>
-    <span class="n">entityContainer</span><span class="o">.</span><span class="na">setEntitySets</span><span class="o">(</span><span class="n">entitySets</span><span class="o">);</span>
+  <span class="c1">// create EntitySets</span>
+  <span class="n">List</span><span class="o">&lt;</span><span class="n">EntitySet</span><span class="o">&gt;</span> <span class="n">entitySets</span> <span class="o">=</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">EntitySet</span><span class="o">&gt;();</span>
+  <span class="n">entitySets</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">getEntitySet</span><span class="o">(</span><span class="n">CONTAINER</span><span class="o">,</span> <span class="n">ES_PRODUCTS_NAME</span><span class="o">));</span>
+
+  <span class="c1">// create EntityContainer</span>
+  <span class="n">EntityContainer</span> <span class="n">entityContainer</span> <span class="o">=</span> <span class="k">new</span> <span class="n">EntityContainer</span><span class="o">();</span>
+  <span class="n">entityContainer</span><span class="o">.</span><span class="na">setName</span><span class="o">(</span><span class="n">CONTAINER_NAME</span><span class="o">);</span>
+  <span class="n">entityContainer</span><span class="o">.</span><span class="na">setEntitySets</span><span class="o">(</span><span class="n">entitySets</span><span class="o">);</span>
 
-    <span class="k">return</span> <span class="n">entityContainer</span><span class="o">;</span>
+  <span class="k">return</span> <span class="n">entityContainer</span><span class="o">;</span>
 <span class="o">}</span>
 </pre></div>
 
@@ -549,7 +560,7 @@ After implementing the <em>EdmProvider</
 If desired, you can proceed with implementing the required steps for web application as described in
 4.3. and run the application as described in chapter 5.</p>
 </blockquote>
-<h2 id="42-provide-the-data">4.2. Provide the data</h2>
+<h2 id="42-provide-the-data">4.2. Provide the data<a class="headerlink" href="#42-provide-the-data" title="Permanent link">&para;</a></h2>
 <p>After implementing the <em>EdmProvider</em>, the next step is the main task of an OData service: provide data.<br />
 In our example, we imagine that our OData service is invoked by a user who wants to see which products are offered by a web shop.<br />
 He invokes a URL and gets a list of products.<br />
@@ -566,7 +577,7 @@ Providing the list of products is the ta
       Since we are implementing a “processor”, the last step is to provide the response object</li>
 </ol>
 <p>These 4 steps will be considered in the implementation of the <code>readEntityCollection()</code> method.</p>
-<h3 id="421-background">4.2.1. Background</h3>
+<h3 id="421-background">4.2.1. Background<a class="headerlink" href="#421-background" title="Permanent link">&para;</a></h3>
 <p>In terms of <em>Olingo</em>, while processing a service request, a Processor instance is invoked that is supposed to understand the (user HTTP-) request and deliver the desired data.<br />
 <em>Olingo</em> provides API for processing different kind of service requests:<br />
 Such a service request can ask for a list of entities, or for one entity, or one property.</p>
@@ -579,14 +590,14 @@ Then our <code>EntityCollectionProcessor
 <p>As we have already mentioned, the metadata document is the contract for providing data.
 This means that when it comes to provide the actual data, we have to do it according to the specified metadata.<br />
 For example, the property names have to match, also the types of the properties, and, if specified, the length of the strings, etc</p>
-<h3 id="422-create-class">4.2.2. Create class</h3>
+<h3 id="422-create-class">4.2.2. Create class<a class="headerlink" href="#422-create-class" title="Permanent link">&para;</a></h3>
 <p>Within our package <code>myservice.mynamespace.service</code>, we create a Java class <code>DemoEntityCollectionProcessor</code>  that implements the interface <code>org.apache.olingo.server.api.processor.EntityCollectionProcessor</code>.</p>
 <p><img alt="createJavaClass" src="createJavaClass.png" title="The Eclipse dialog for creating a Java class" /></p>
-<h3 id="423-implement-the-required-methods">4.2.3. Implement the required methods</h3>
+<h3 id="423-implement-the-required-methods">4.2.3. Implement the required methods<a class="headerlink" href="#423-implement-the-required-methods" title="Permanent link">&para;</a></h3>
 <p>After creation of the Java class, we can see that there are 2 methods to be implemented:</p>
 <ul>
 <li><em>init()</em><br />
-      This method is invoked by the <em>Olingo</em> library, allowing us to store the context object</li>
+    This method is invoked by the <em>Olingo</em> library, allowing us to store the context object</li>
 <li><em>readEntityCollection()</em><br />
     Here we have to fetch the required data and pass it back to the <em>Olingo</em> library</li>
 </ul>
@@ -597,7 +608,7 @@ The <em>Olingo</em> framework initialize
 According to the Javadoc, this object is the “Root object for serving factory tasks…”
 We will need it later, so we store it as member variable.</p>
 <div class="codehilite"><pre><span class="kd">public</span> <span class="kt">void</span> <span class="nf">init</span><span class="o">(</span><span class="n">OData</span> <span class="n">odata</span><span class="o">,</span> <span class="n">ServiceMetadata</span> <span class="n">serviceMetadata</span><span class="o">)</span> <span class="o">{</span>
-    <span class="k">this</span><span class="o">.</span><span class="na">odata</span> <span class="o">=</span> <span class="n">odata</span><span class="o">;</span>
+  <span class="k">this</span><span class="o">.</span><span class="na">odata</span> <span class="o">=</span> <span class="n">odata</span><span class="o">;</span>
 <span class="o">}</span>
 </pre></div>
 
@@ -728,14 +739,14 @@ We create the entities and their propert
 </pre></div>
 
 
-<h2 id="43-web-application">4.3. Web Application</h2>
+<h2 id="43-web-application">4.3. Web Application<a class="headerlink" href="#43-web-application" title="Permanent link">&para;</a></h2>
 <p>After declaring the metadata and providing the data, our OData service implementation is done.<br />
 The last step is to enable our OData service to be called on a web server.<br />
 Therefore, we are wrapping our service by a web application.</p>
 <p>The web application is defined in the web.xml file, where a servlet is registered.
 The servlet is a standard <em>HttpServlet</em> which dispatches the user requests to the <em>Olingo</em> framework.</p>
 <p>Let’s quickly do the remaining steps:</p>
-<h3 id="431-create-and-implement-the-servlet">4.3.1. Create and implement the Servlet</h3>
+<h3 id="431-create-and-implement-the-servlet">4.3.1. Create and implement the Servlet<a class="headerlink" href="#431-create-and-implement-the-servlet" title="Permanent link">&para;</a></h3>
 <p>Create a new package <em>myservice.mynamespace.web</em>.
 Create Java class with name <code>DemoServlet</code> that inherits from <code>HttpServlet</code>.</p>
 <p><img alt="createJavaServletClass" src="createJavaServletClass.png" title="Creating the servlet class" /></p>
@@ -752,8 +763,8 @@ Furthermore, the <code>ODataHttpHandler<
 
   <span class="nd">@Override</span>
   <span class="kd">protected</span> <span class="kt">void</span> <span class="nf">service</span><span class="o">(</span><span class="kd">final</span> <span class="n">HttpServletRequest</span> <span class="n">req</span><span class="o">,</span> <span class="kd">final</span> <span class="n">HttpServletResponse</span> <span class="n">resp</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">ServletException</span><span class="o">,</span> <span class="n">IOException</span> <span class="o">{</span>
-        <span class="k">try</span> <span class="o">{</span>
-            <span class="c1">// create odata handler and configure it with CsdlEdmProvider and Processor</span>
+    <span class="k">try</span> <span class="o">{</span>
+      <span class="c1">// create odata handler and configure it with CsdlEdmProvider and Processor</span>
       <span class="n">OData</span> <span class="n">odata</span> <span class="o">=</span> <span class="n">OData</span><span class="o">.</span><span class="na">newInstance</span><span class="o">();</span>
       <span class="n">ServiceMetadata</span> <span class="n">edm</span> <span class="o">=</span> <span class="n">odata</span><span class="o">.</span><span class="na">createServiceMetadata</span><span class="o">(</span><span class="k">new</span> <span class="n">DemoEdmProvider</span><span class="o">(),</span> <span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;</span><span class="n">EdmxReference</span><span class="o">&gt;());</span>
       <span class="n">ODataHttpHandler</span> <span class="n">handler</span> <span class="o">=</span> <span class="n">odata</span><span class="o">.</span><span class="na">createHandler</span><span class="o">(</span><span class="n">edm</span><span class="o">);</span>
@@ -761,7 +772,6 @@ Furthermore, the <code>ODataHttpHandler<
 
       <span class="c1">// let the handler do the work</span>
       <span class="n">handler</span><span class="o">.</span><span class="na">process</span><span class="o">(</span><span class="n">req</span><span class="o">,</span> <span class="n">resp</span><span class="o">);</span>
-
     <span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">RuntimeException</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span>
       <span class="n">LOG</span><span class="o">.</span><span class="na">error</span><span class="o">(</span><span class="s">&quot;Server Error occurred in ExampleServlet&quot;</span><span class="o">,</span> <span class="n">e</span><span class="o">);</span>
       <span class="k">throw</span> <span class="k">new</span> <span class="nf">ServletException</span><span class="o">(</span><span class="n">e</span><span class="o">);</span>
@@ -771,7 +781,7 @@ Furthermore, the <code>ODataHttpHandler<
 </pre></div>
 
 
-<h3 id="432-edit-the-webxml">4.3.2. Edit the web.xml</h3>
+<h3 id="432-edit-the-webxml">4.3.2. Edit the web.xml<a class="headerlink" href="#432-edit-the-webxml" title="Permanent link">&para;</a></h3>
 <p>The very last step of our tutorial is to register the Servlet in the <em>web.xml</em> file.<br />
 Furthermore, we need to specify the <em>url-pattern</em> for the servlet, such that our OData service can be invoked.</p>
 <p>Open the <em>src/main/webapp/WEB-INF/web.xml</em> file and paste the following content into it:</p>
@@ -797,10 +807,10 @@ Furthermore, we need to specify the <em>
 
 <p>That’s it. Now we can build and run the web application.</p>
 <hr />
-<h1 id="5-run-the-service">5. Run the service</h1>
+<h1 id="5-run-the-service">5. Run the service<a class="headerlink" href="#5-run-the-service" title="Permanent link">&para;</a></h1>
 <p>Running the service means build the war file and deploy it on a server.<br />
 In our tutorial, we are using the Eclipse web integration tools, which make life easier.</p>
-<h3 id="run-with-eclipse">Run with Eclipse</h3>
+<h3 id="run-with-eclipse">Run with Eclipse<a class="headerlink" href="#run-with-eclipse" title="Permanent link">&para;</a></h3>
 <p>Select your project and from the context menu choose <em>Run As -&gt; Run on Server</em><br />
 If you don’t have any server configured in Eclipse, you have to “manually define a new server” in the subsequent dialog.<br />
 If you have installed a Tomcat server on your local file system, you can use it here.<br />
@@ -817,7 +827,7 @@ We ignore it. Instead, we open our OData
 <p>Note:
 If you face problems related to the server, it helps to restart your Eclipse IDE.</p>
 </blockquote>
-<h3 id="the-service-urls">The service-URLs</h3>
+<h3 id="the-service-urls">The service-URLs<a class="headerlink" href="#the-service-urls" title="Permanent link">&para;</a></h3>
 <p>Try the following URLs:</p>
 <p><strong>Service Document</strong></p>
 <div class="codehilite"><pre>http://localhost:8080/DemoService/DemoService.svc/
@@ -892,7 +902,7 @@ If you face problems related to the serv
 
 
 <hr />
-<h1 id="6-summary">6. Summary</h1>
+<h1 id="6-summary">6. Summary<a class="headerlink" href="#6-summary" title="Permanent link">&para;</a></h1>
 <p>Finally, we have created our first OData service based on the V4 version of the OData specification and using the V4 server library provided by <em>Olingo</em>.<br />
 Our first OData service is very simple; it only allows invoking one entity collection, apart from the service document and the metadata document.</p>
 <p>The project as final result can be download <a href="http://www.apache.org/dyn/closer.cgi/olingo/odata4/Tutorials/DemoService_Tutorial_Read.zip">here</a> (<a href="https://dist.apache.org/repos/dist/release/olingo/odata4/Tutorials/DemoService_Tutorial_Read.zip.md5">md5</a>, <a href="https://dist.apache.org/repos/dist/release/olingo/odata4/Tutorials/DemoService_Tutorial_Read.zip.sha512">sha512</a>, <a href="https://dist.apache.org/repos/dist/release/olingo/odata4/Tutorials/DemoService_Tutorial_Read.zip.asc">pgp</a>).</p>