You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2015/11/17 11:02:51 UTC

svn commit: r1714747 - /olingo/site/trunk/content/doc/odata4/tutorials/batch/tutorial_batch.mdtext

Author: chrish
Date: Tue Nov 17 10:02:51 2015
New Revision: 1714747

URL: http://svn.apache.org/viewvc?rev=1714747&view=rev
Log:
CMS commit to olingo by chrish

Modified:
    olingo/site/trunk/content/doc/odata4/tutorials/batch/tutorial_batch.mdtext

Modified: olingo/site/trunk/content/doc/odata4/tutorials/batch/tutorial_batch.mdtext
URL: http://svn.apache.org/viewvc/olingo/site/trunk/content/doc/odata4/tutorials/batch/tutorial_batch.mdtext?rev=1714747&r1=1714746&r2=1714747&view=diff
==============================================================================
--- olingo/site/trunk/content/doc/odata4/tutorials/batch/tutorial_batch.mdtext (original)
+++ olingo/site/trunk/content/doc/odata4/tutorials/batch/tutorial_batch.mdtext Tue Nov 17 10:02:51 2015
@@ -42,38 +42,34 @@ This tutorial can be found in subdirecto
 # 1. Introduction
 
 Batch requests [(OData Version 4.0 Part 1: Protocol Plus Errata 02)](http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part1-protocol/odata-v4.0-errata02-os-part1-protocol-complete.html#_Toc406398359) allow grouping multiple operations into a single HTTP request payload. A batch request is represented as a Multipart MIME v1.0 message [(RFC2046)](https://www.ietf.org/rfc/rfc2046.txt).
-Each part of a Multipart MINE message can have a differtent content type. For example you can mix OData requests with Content-Type `application/json` and Media Ressource Requests with Content Type `image/png`.
+Each part of a Multipart MINE message can have a different content type. For example you can mix OData requests with Content-Type `application/json` and Media Ressource Requests with Content Type `image/png`.
 
 The content of batch requests can consist of a series of individual requests and Change Sets, each represented as a distinct MIME part. In difference to OData V2 an individual request can be a Data Request, Data Modification Request, Action invocation request or a Function invocation request. So all kinds of OData requests are allowed at top level. The order of individual requests and Change Set sets in significant. Within a Change Set you can use Data Modification requests and Action invocation requests. Due to the fact that all requests within a Change Set are unordered, GET requests must not be used within a Change Set. All operations in a change set represent a single change unit so a service must successfully process and apply all the requests in the change set or else apply none of them.
 
 **Example**
 
-The request below consists of a individual request (upper red box), actually a GET request(the upper blue box) to the Entity Set `Products` and a Change Set (lower red box). The Change Set contains a single POST request (lower blue box) to create a new `Procuct`. Please note that the *boundary delimiter* `abc123` is used in the request below.  The whole content must be wrapped in a single POST request issued againest the resource `/$batch`. The Content-Type of the POST request is consequently `Content-Type: multipart/mixed;boundary=abc123`
+The request below consists of an individual request (upper red box), actually a GET request(the upper blue box) to the Entity Set `Products` and a Change Set (lower red box). The Change Set contains a single POST request (lower blue box) to create a new `Product`. Please note that the *boundary delimiter* `abc123` is used in the request below.  The whole content must be wrapped in a single POST request issued against the resource `/$batch`. The Content-Type of the POST request is consequently `Content-Type: multipart/mixed;boundary=abc123`
 
 
 ![Test](request.png)
 
 # 2. Preparation
 
-You should read the previous tutorials first to have an idea how to read and write entities. In addition the following code is based on the write tutorial tutorial.
+You should read the previous tutorials first to have an idea how to read and write entities. In addition the following code is based on the write tutorial.
 
-As a shortcut you should checkout the prepared tutorial project in the [git repository](https://git-wip-us.apache.org/repos/asf/olingo-odata4) in folder /samples/tutorials/p3_write.
-
-Afterwards do a Deploy and run: it should be working. At this state you can perform CRUD operations and do navigations between products and categories.
-
-# 2. Implementation
+As a shortcut you should chec
 
 The main idea of the following implementation is to reuse the existing processors.
 To do so, we will implement a new processor, which takes a batch request and dispatches the single requests to the responsible processors.
 
-The folling steps have to be performed:
+The following steps have to be performed:
 
   - Modify the data store
   - Implement the interface `BatchProcessor`
 
-## Add transactional behaviour to the data store
+## Add transactional behavior to the data store
 
-Before we start with the actual processor implementation the data store has to be modified to provide transactional behavior. In real world service the underlaying database may supports transactional handling. This tutorial is not based on a database so we have implement a simple transaction handling by ourself.
+Before we start with the actual processor implementation the data store has to be modified to provide transactional behavior. In real world service the underlying database may supports transactional handling. This tutorial is not based on a database so we have implement a simple transaction handling by ourselves.
 
 Add the following methods to the class `myservice.mynamespace.data.Storage`. When a new transaction has been begun the data of the service is copied and stored in an instance variable. If `rollbackTransaction` has been called the current data is replaced with the previous copied one.
 
@@ -129,7 +125,7 @@ Add the following methods to the class `
 
 Create a new class `myservice.mynamespace.service.DemoBatchProcessor`. The class should implement the interface `org.apache.olingo.server.api.processor.BatchProcessor`.
 
-Create a constructor and pass the data store to the procesoor.
+Create a constructor and pass the data store to the processor.
 
     ::::java
     public class DemoBatchProcessor implements BatchProcessor {
@@ -159,7 +155,7 @@ Batch requests will be dispatched to the
             // 1. Extract the boundary
             final String boundary = facade.extractBoundaryFromContentType(request.getHeader(HttpHeader.CONTENT_TYPE));
 
-After that we are able to parse the multipart mixed body. The parser needs to know what the base uri and the service resolution paths are. The result of the parser is a list of BatchRequestParts. Each of these parts represents either a single request or a Change Set (Collection of one or more requests).
+After that we are able to parse the multipart mixed body. The parser needs to know what the base URI and the service resolution paths are. The result of the parser is a list of BatchRequestParts. Each of these parts represents either a single request or a Change Set (Collection of one or more requests).
 
     ::::java
         // 2. Prepare the batch options
@@ -171,7 +167,7 @@ After that we are able to parse the mult
         final List<BatchRequestPart> requestParts = odata.createFixedFormatDeserializer()
                                                          .parseBatchRequest(request.getBody(), boundary, options);
 
-Now the requests have to be executed by our service. If you like, you can do it by our own or simply call the method `handleBatchRequest`. This method dispatches individual requests directly to the responsible processor. If a Change Set is passed to `handleBatchRequest` the implementation dispaches the request to the method `processChangeSet` of our `DemoBatchProcessor`.
+Now the requests have to be executed by our service. If you like, you can do it by our own or simply call the method `handleBatchRequest`. This method dispatches individual requests directly to the responsible processor. If a Change Set is passed to `handleBatchRequest` the implementation dispatches the request to the method `processChangeSet` of our `DemoBatchProcessor`.
 
     ::::java
         // 4. Execute the batch request parts
@@ -180,7 +176,7 @@ Now the requests have to be executed by
             responseParts.add(facade.handleBatchRequest(part));
         }
 
-The last steps are to serialize the responses and setup the reponse of the batch request.
+The last steps are to serialize the responses and setup the response of the batch request.
 
     ::::java
         // 5. Serialize the response content
@@ -199,7 +195,7 @@ The last steps are to serialize the resp
 
 As mentioned above Change Sets are dispatched to the method `processChangeSet`.
 In this tutorial the implementation is quite simple. First we begin a new transaction. After that we try to execute all requests of the Change Set. If one of the requests fail all changes have to be rolled back.
-The comments in the source code give a detailed explaination about the steps done in this mehtod.
+The comments in the source code give a detailed explanation about the steps done in this method.
 
     ::::java
     @Override
@@ -283,7 +279,7 @@ Set the Content-Type header to `Content-
 
 **Example 1**    
 Please note that the second request in the Change Set references the first request of the Change Set.
-This is done by by prefixing the Content-Id of the referenced request with a $. e.g. `$abc`
+This is done by prefixing the Content-Id of the referenced request with a $. e.g. `$abc`
 
     --abc123
     Content-Type: application/http
@@ -327,7 +323,7 @@ This is done by by prefixing the Content
 
     --abc123--
 
-Now have a look at the response. As you can see a new product has been created and the desciption has been updated to 'With a changed Description'
+Now have a look at the response. As you can see a new product has been created and the description has been updated to 'With a changed Description'
 
     {
         "@odata.context": "$metadata#Products",
@@ -342,7 +338,7 @@ Now have a look at the response. As you
     }
 
 **Example 2**    
-Let us try what is happing if the send a invalid request within a Change Set. Use the same URI and Content Type as before and use the following body:
+Let us try what is happing if we send a invalid request within an Change Set. Use the same URI and Content-Type as before and use the following body:
 
     --abc123
     Content-Type: multipart/mixed;boundary=changeset_abc
@@ -371,7 +367,7 @@ Let us try what is happing if the send a
     --changeset_abc--
     --abc123--
 
-As you can see the reponse contains a single request response instead of a Change Set response. The error message in stored in the response body.
+As you can see the response contains a single request response instead of a Change Set response. The error message in stored in the response body.
 
 # 5. Links