olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbo...@apache.org
Subject git commit: improve batch request parsing
Date Thu, 05 Sep 2013 11:58:09 GMT
Updated Branches:
  refs/heads/master b7e9f394f -> 9640c7643


improve batch request parsing


Project: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/commit/9640c764
Tree: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/tree/9640c764
Diff: http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/diff/9640c764

Branch: refs/heads/master
Commit: 9640c76433059afb285caa49dbe6bf283907eabc
Parents: b7e9f39
Author: Tamara Boehm <tamara.boehm@sap.com>
Authored: Thu Sep 5 13:54:28 2013 +0200
Committer: Tamara Boehm <tamara.boehm@sap.com>
Committed: Thu Sep 5 13:55:56 2013 +0200

----------------------------------------------------------------------
 .../odata2/core/batch/BatchRequestParser.java     | 11 ++++++++++-
 .../odata2/core/batch/BatchRequestParserTest.java | 18 ++++++++----------
 2 files changed, 18 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/9640c764/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchRequestParser.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchRequestParser.java
b/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchRequestParser.java
index e37d572..e223a6e 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchRequestParser.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchRequestParser.java
@@ -123,7 +123,7 @@ public class BatchRequestParser {
       final String closeDelimiter = "--" + boundary + "--" + REG_EX_ZERO_OR_MORE_WHITESPACES;
       while (scanner.hasNext() && !scanner.hasNext(closeDelimiter)) {
         requests.add(parseMultipart(scanner, boundary, false));
-        parseNewLine(scanner);
+        parseOptionalLine(scanner);
       }
       if (scanner.hasNext(closeDelimiter)) {
         scanner.next(closeDelimiter);
@@ -246,6 +246,8 @@ public class BatchRequestParser {
       InputStream body = new ByteArrayInputStream(new byte[0]);
       if (isChangeSet) {
         body = parseBody(scanner);
+      } else {
+        parseNewLine(scanner);
       }
 
       ODataRequestBuilder requestBuilder = ODataRequest.method(httpMethod)
@@ -503,6 +505,13 @@ public class BatchRequestParser {
     }
   }
 
+  private void parseOptionalLine(final Scanner scanner) throws BatchException {
+    while (scanner.hasNext() && scanner.hasNext(REG_EX_BLANK_LINE)) {
+      scanner.next();
+      currentLineNumber++;
+    }
+  }
+
   private String getBaseUri() throws BatchException {
     if (batchRequestPathInfo != null) {
       if (batchRequestPathInfo.getServiceRoot() != null) {

http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/9640c764/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestParserTest.java
----------------------------------------------------------------------
diff --git a/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestParserTest.java
b/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestParserTest.java
index b0babf7..725a810 100644
--- a/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestParserTest.java
+++ b/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestParserTest.java
@@ -128,7 +128,14 @@ public class BatchRequestParserTest {
       throw new IOException("Requested file '" + fileName + "' was not found.");
     }
     String content = StringHelper.inputStreamToString(contentInputStream);
-    String batch = LF
+    String batch = "--batch_8194-cf13-1f56" + LF
+        + MIME_HEADERS
+        + LF
+        + "GET Employees?$filter=Age%20gt%2040 HTTP/1.1" + LF
+        + "Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1"
+ LF
+        + "MaxDataServiceVersion: 2.0" + LF
+        + LF
+        + LF
         + "--batch_8194-cf13-1f56" + LF
         + "Content-Type: multipart/mixed; boundary=changeset_f980-1cb6-94dd" + LF
         + LF
@@ -144,15 +151,6 @@ public class BatchRequestParserTest {
         + content + LF
         + LF
         + "--changeset_f980-1cb6-94dd--" + LF
-        + LF
-        + "--batch_8194-cf13-1f56" + LF
-        + MIME_HEADERS
-        + LF
-        + "GET Employees?$filter=Age%20gt%2040 HTTP/1.1" + LF
-        + "Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1"
+ LF
-        + "MaxDataServiceVersion: 2.0" + LF
-        + LF
-        + LF
         + "--batch_8194-cf13-1f56--";
     List<BatchRequestPart> BatchRequestParts = parse(batch);
     for (BatchRequestPart object : BatchRequestParts) {


Mime
View raw message