You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by mi...@apache.org on 2015/07/20 21:41:53 UTC
[1/6] olingo-odata2 git commit: [OLINGO-733] Fix test
Repository: olingo-odata2
Updated Branches:
refs/heads/OLINGO-733_BatchFix 03858a15d -> e0311e19f
[OLINGO-733] Fix test
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/99e5049a
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/99e5049a
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/99e5049a
Branch: refs/heads/OLINGO-733_BatchFix
Commit: 99e5049ab941ad17d9c62ad768557f716b5ea40b
Parents: a9af400
Author: Michael Bolz <mi...@sap.com>
Authored: Mon Jul 20 07:44:42 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Mon Jul 20 08:09:43 2015 +0200
----------------------------------------------------------------------
.../odata2/core/batch/BatchRequestWriterITTest.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/99e5049a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java
index e2aa353..229603d 100644
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java
@@ -24,6 +24,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
+import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -126,6 +127,12 @@ public class BatchRequestWriterITTest {
assertEquals("application/json", oDataRequestPost.getRequestHeaderValue(HttpHeaders.CONTENT_TYPE));
}
+ /**
+ * BatchChangeSetPart can only handle utf-8 (DEFAULT_CHARSET for Olingo [BatchHelper.DEFAULT_ENCODING]).
+ * Hence it is not relevant which charset is set in changeSetHeader
+ *
+ * @throws Exception
+ */
@Test
public void testChangeSetIso() throws Exception {
List<BatchPart> batch = new ArrayList<BatchPart>();
@@ -168,7 +175,8 @@ public class BatchRequestWriterITTest {
final ODataRequest oDataRequestPost = partChangeSet.getRequests().get(0);
assertEquals("Employees", oDataRequestGet.getPathInfo().getODataSegments().get(0).getPath());
assertEquals("111", oDataRequestPost.getRequestHeaderValue(BatchHelper.MIME_HEADER_CONTENT_ID));
- assertEquals(body, streamToString(oDataRequestPost.getBody()));
+ StringHelper.Stream st = StringHelper.toStream(oDataRequestPost.getBody());
+ assertEquals(body, st.asString("utf-8"));
assertEquals("application/json; charset=" + charset,
oDataRequestPost.getRequestHeaderValue(HttpHeaders.CONTENT_TYPE));
}
[3/6] olingo-odata2 git commit: [OLINGO-725] Return after sending
exception response from servlet
Posted by mi...@apache.org.
[OLINGO-725] Return after sending exception response from servlet
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/5c4d06d9
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/5c4d06d9
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/5c4d06d9
Branch: refs/heads/OLINGO-733_BatchFix
Commit: 5c4d06d959a320ddc1d21056a18321dc531068e9
Parents: bc2a0f5
Author: Christian Amend <ch...@sap.com>
Authored: Mon Jul 20 16:13:44 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Mon Jul 20 16:13:44 2015 +0200
----------------------------------------------------------------------
.../java/org/apache/olingo/odata2/core/servlet/ODataServlet.java | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/5c4d06d9/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/servlet/ODataServlet.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/servlet/ODataServlet.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/servlet/ODataServlet.java
index d2ee57f..924316f 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/servlet/ODataServlet.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/servlet/ODataServlet.java
@@ -77,6 +77,7 @@ public class ODataServlet extends HttpServlet {
ODataExceptionWrapper wrapper = new ODataExceptionWrapper(req, serviceFactory);
createResponse(resp, wrapper.wrapInExceptionResponse(
new ODataBadRequestException(ODataBadRequestException.AMBIGUOUS_XMETHOD)));
+ return;
}
}
[2/6] olingo-odata2 git commit: [OLINGO-733] Fix test 2
Posted by mi...@apache.org.
[OLINGO-733] Fix test 2
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/bc2a0f57
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/bc2a0f57
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/bc2a0f57
Branch: refs/heads/OLINGO-733_BatchFix
Commit: bc2a0f572ffee36fdb7009ca2e9fb9c6e7cfd4ef
Parents: 99e5049
Author: Michael Bolz <mi...@sap.com>
Authored: Mon Jul 20 08:44:53 2015 +0200
Committer: Michael Bolz <mi...@sap.com>
Committed: Mon Jul 20 08:44:53 2015 +0200
----------------------------------------------------------------------
.../apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/bc2a0f57/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java
index 229603d..b66f5b1 100644
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java
@@ -43,6 +43,7 @@ import org.apache.olingo.odata2.core.PathInfoImpl;
import org.apache.olingo.odata2.core.batch.v2.BatchParser;
import org.apache.olingo.odata2.testutil.helper.StringHelper;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
public class BatchRequestWriterITTest {
@@ -134,6 +135,7 @@ public class BatchRequestWriterITTest {
* @throws Exception
*/
@Test
+ @Ignore("Rework for test necessary")
public void testChangeSetIso() throws Exception {
List<BatchPart> batch = new ArrayList<BatchPart>();
Map<String, String> headers = new HashMap<String, String>();
[5/6] olingo-odata2 git commit: [OLINGO-733] Merge branch 'master'
into OLINGO-733_BatchFix
Posted by mi...@apache.org.
[OLINGO-733] Merge branch 'master' into OLINGO-733_BatchFix
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/13b7b489
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/13b7b489
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/13b7b489
Branch: refs/heads/OLINGO-733_BatchFix
Commit: 13b7b4897e7a1e67852853e2dbefbdd1dc69d484
Parents: 03858a1 4ef73c4
Author: mibo <mi...@mirb.de>
Authored: Mon Jul 20 20:16:48 2015 +0200
Committer: mibo <mi...@mirb.de>
Committed: Mon Jul 20 20:16:48 2015 +0200
----------------------------------------------------------------------
.../java/org/apache/olingo/odata2/core/servlet/ODataServlet.java | 2 ++
.../apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java | 2 ++
2 files changed, 4 insertions(+)
----------------------------------------------------------------------
[6/6] olingo-odata2 git commit: [OLINGO-733] Fix missing
BatchParserCommon
Posted by mi...@apache.org.
[OLINGO-733] Fix missing BatchParserCommon
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/e0311e19
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/e0311e19
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/e0311e19
Branch: refs/heads/OLINGO-733_BatchFix
Commit: e0311e19f13a91d227eeb36f8c2474bbfd4c7515
Parents: 13b7b48
Author: mibo <mi...@mirb.de>
Authored: Mon Jul 20 20:15:37 2015 +0200
Committer: mibo <mi...@mirb.de>
Committed: Mon Jul 20 20:34:56 2015 +0200
----------------------------------------------------------------------
.../olingo/odata2/core/batch/BatchHelper.java | 7 ++++
.../odata2/core/batch/v2/BatchParserCommon.java | 37 ++++++++++++++------
.../batch/v2/BatchRequestTransformator.java | 7 +---
.../core/batch/BatchRequestWriterITTest.java | 6 ++--
4 files changed, 37 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/e0311e19/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchHelper.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchHelper.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchHelper.java
index 41ad0be..2f73216 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchHelper.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/BatchHelper.java
@@ -72,6 +72,13 @@ public class BatchHelper {
return getCharset(contentType);
}
+ public static Charset extractCharset(String contentType) {
+ if(contentType == null) {
+ return DEFAULT_CHARSET;
+ }
+ return getCharset(contentType);
+ }
+
private static Charset getCharset(String contentType) {
ContentType ct = ContentType.parse(contentType);
if(ct != null) {
http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/e0311e19/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchParserCommon.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchParserCommon.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchParserCommon.java
index dcf878c..2aa9311 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchParserCommon.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchParserCommon.java
@@ -20,6 +20,7 @@ package org.apache.olingo.odata2.core.batch.v2;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -34,6 +35,7 @@ import org.apache.olingo.odata2.api.batch.BatchException;
import org.apache.olingo.odata2.api.commons.HttpContentType;
import org.apache.olingo.odata2.api.commons.HttpHeaders;
import org.apache.olingo.odata2.core.batch.AcceptParser;
+import org.apache.olingo.odata2.core.batch.BatchHelper;
import org.apache.olingo.odata2.core.commons.Decoder;
public class BatchParserCommon {
@@ -69,18 +71,31 @@ public class BatchParserCommon {
return builder.toString();
}
- public static InputStream convertLineListToInputStream(final List<Line> messageList, final int contentLength)
+ /**
+ * Convert body of BatchQueryOperation into a InputStream.
+ * The body will get via the charset set in ContentType and
+ * if no charset is set with Olingo default charset (see <code>BatchHelper.DEFAULT_CHARSET</code>).
+ *
+ * If content length is a positive value the content is trimmed to according length.
+ * Otherwise the whole content is written into the InputStream.
+ *
+ * @param operation from which the content is written into the InputStream
+ * @param contentLength if it is a positive value the content is trimmed to according length.
+ * Otherwise the whole content is written into the InputStream.
+ * @return Content of BatchQueryOperation as InputStream in according charset and length
+ * @throws BatchException if something goes wrong
+ */
+ public static InputStream convertToInputStream(BatchQueryOperation operation, int contentLength)
throws BatchException {
- final String message = trimLineListToLength(messageList, contentLength);
-
- return new ByteArrayInputStream(message.getBytes());
- }
-
- public static InputStream convertLineListToInputStream(final List<Line> messageList)
- throws BatchException {
- final String message = lineListToString(messageList);
-
- return new ByteArrayInputStream(message.getBytes());
+ String contentType = operation.getHeaders().getHeader(HttpHeaders.CONTENT_TYPE);
+ Charset charset = BatchHelper.extractCharset(contentType);
+ final String message;
+ if(contentLength <= -1) {
+ message = lineListToString(operation.getBody());
+ } else {
+ message = trimLineListToLength(operation.getBody(), contentLength);
+ }
+ return new ByteArrayInputStream(message.getBytes(charset));
}
static List<List<Line>> splitMessageByBoundary(final List<Line> message, final String boundary)
http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/e0311e19/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchRequestTransformator.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchRequestTransformator.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchRequestTransformator.java
index 66600b5..a3b376b 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchRequestTransformator.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/batch/v2/BatchRequestTransformator.java
@@ -127,12 +127,7 @@ public class BatchRequestTransformator implements BatchTransformator {
return new ByteArrayInputStream(new byte[0]);
} else {
int contentLength = BatchTransformatorCommon.getContentLength(headers);
-
- if (contentLength == -1) {
- return BatchParserCommon.convertLineListToInputStream(operation.getBody());
- } else {
- return BatchParserCommon.convertLineListToInputStream(operation.getBody(), contentLength);
- }
+ return BatchParserCommon.convertToInputStream(operation, contentLength);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/e0311e19/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java
index b66f5b1..6e1626e 100644
--- a/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java
+++ b/odata2-lib/odata-core/src/test/java/org/apache/olingo/odata2/core/batch/BatchRequestWriterITTest.java
@@ -135,7 +135,6 @@ public class BatchRequestWriterITTest {
* @throws Exception
*/
@Test
- @Ignore("Rework for test necessary")
public void testChangeSetIso() throws Exception {
List<BatchPart> batch = new ArrayList<BatchPart>();
Map<String, String> headers = new HashMap<String, String>();
@@ -147,9 +146,10 @@ public class BatchRequestWriterITTest {
String charset = "iso-8859-1";
changeSetHeaders.put("content-type", "application/json; charset=" + charset);
String body = "äöü/9j/4AAQSkZJRgABAQEBLAEsAAD/4RM0RXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEA";
+ StringHelper.Stream stBody = StringHelper.toStream(body, charset);
BatchChangeSetPart changeRequest = BatchChangeSetPart.method(POST)
.uri("Employees")
- .body(body)
+ .body(stBody.asString(charset))
.headers(changeSetHeaders)
.contentId("111")
.build();
@@ -178,7 +178,7 @@ public class BatchRequestWriterITTest {
assertEquals("Employees", oDataRequestGet.getPathInfo().getODataSegments().get(0).getPath());
assertEquals("111", oDataRequestPost.getRequestHeaderValue(BatchHelper.MIME_HEADER_CONTENT_ID));
StringHelper.Stream st = StringHelper.toStream(oDataRequestPost.getBody());
- assertEquals(body, st.asString("utf-8"));
+ assertEquals(body, st.asString("utf-8"));
assertEquals("application/json; charset=" + charset,
oDataRequestPost.getRequestHeaderValue(HttpHeaders.CONTENT_TYPE));
}
[4/6] olingo-odata2 git commit: [OLINGO-725] Return after sending not
acceptable response
Posted by mi...@apache.org.
[OLINGO-725] Return after sending not acceptable response
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata2/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata2/commit/4ef73c4b
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata2/tree/4ef73c4b
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata2/diff/4ef73c4b
Branch: refs/heads/OLINGO-733_BatchFix
Commit: 4ef73c4b401199a2b8239db46f2a7eba5be458bc
Parents: 5c4d06d
Author: Christian Amend <ch...@sap.com>
Authored: Mon Jul 20 16:31:01 2015 +0200
Committer: Christian Amend <ch...@sap.com>
Committed: Mon Jul 20 16:31:01 2015 +0200
----------------------------------------------------------------------
.../java/org/apache/olingo/odata2/core/servlet/ODataServlet.java | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/olingo-odata2/blob/4ef73c4b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/servlet/ODataServlet.java
----------------------------------------------------------------------
diff --git a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/servlet/ODataServlet.java b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/servlet/ODataServlet.java
index 924316f..e83f46f 100644
--- a/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/servlet/ODataServlet.java
+++ b/odata2-lib/odata-core/src/main/java/org/apache/olingo/odata2/core/servlet/ODataServlet.java
@@ -179,6 +179,7 @@ public class ODataServlet extends HttpServlet {
}
if (req.getHeader(HttpHeaders.ACCEPT) != null && req.getHeader(HttpHeaders.ACCEPT).isEmpty()) {
createNotAcceptableResponse(req, ODataNotAcceptableException.COMMON, resp, serviceFactory);
+ return;
}
ODataRequest odataRequest = ODataRequest.method(method)
.contentType(RestUtil.extractRequestContentType(req.getContentType()).toContentTypeString())