You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2022/04/13 13:35:17 UTC

[camel] 07/12: CAMEL-17962: cleanup duplicated charset features in camel-olingo4

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 46c020358b4c7eb68b98327d387a8400a24c032d
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Wed Apr 13 13:53:21 2022 +0200

    CAMEL-17962: cleanup duplicated charset features in camel-olingo4
---
 .../component/olingo4/api/impl/Olingo4AppImpl.java  | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
index 889f929b700..d7f042efd5f 100644
--- a/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
+++ b/components/camel-olingo4/camel-olingo4-api/src/main/java/org/apache/camel/component/olingo4/api/impl/Olingo4AppImpl.java
@@ -22,6 +22,7 @@ import java.io.Closeable;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -726,7 +727,7 @@ public final class Olingo4AppImpl implements Olingo4App {
         final ByteArrayOutputStream batchRequestHeaderOutputStream = new ByteArrayOutputStream();
 
         try {
-            batchRequestHeaderOutputStream.write(boundary.getBytes(Constants.UTF8));
+            batchRequestHeaderOutputStream.write(boundary.getBytes(StandardCharsets.UTF_8));
             batchRequestHeaderOutputStream.write(ODataStreamer.CRLF);
 
             for (Olingo4BatchRequest batchPart : batchParts) {
@@ -744,7 +745,7 @@ public final class Olingo4AppImpl implements Olingo4App {
                     batchRequestHeaderOutputStream.write(ODataStreamer.CRLF);
 
                     batchRequestHeaderOutputStream.write(
-                            (HttpGet.METHOD_NAME + " " + batchQueryUri + " " + HttpVersion.HTTP_1_1).getBytes(Constants.UTF8));
+                            (HttpGet.METHOD_NAME + " " + batchQueryUri + " " + HttpVersion.HTTP_1_1).getBytes(StandardCharsets.UTF_8));
                     batchRequestHeaderOutputStream.write(ODataStreamer.CRLF);
                     final ContentType acceptType = getResourceContentType(uriInfo);
                     final String acceptCharset = acceptType.getParameter(ContentType.PARAMETER_CHARSET);
@@ -756,7 +757,7 @@ public final class Olingo4AppImpl implements Olingo4App {
                     }
 
                     batchRequestHeaderOutputStream.write(ODataStreamer.CRLF);
-                    batchRequestHeaderOutputStream.write(boundary.getBytes(Constants.UTF8));
+                    batchRequestHeaderOutputStream.write(boundary.getBytes(StandardCharsets.UTF_8));
                     batchRequestHeaderOutputStream.write(ODataStreamer.CRLF);
                 } else if (batchPart instanceof Olingo4BatchChangeRequest) {
                     final Olingo4BatchChangeRequest batchChangePart = (Olingo4BatchChangeRequest) batchPart;
@@ -773,7 +774,7 @@ public final class Olingo4AppImpl implements Olingo4App {
                     batchRequestHeaderOutputStream.write(ODataStreamer.CRLF);
                     batchRequestHeaderOutputStream
                             .write((batchChangePart.getOperation().getHttpMethod() + " " + batchChangeUri + " "
-                                    + HttpVersion.HTTP_1_1).getBytes(Constants.UTF8));
+                                    + HttpVersion.HTTP_1_1).getBytes(StandardCharsets.UTF_8));
                     batchRequestHeaderOutputStream.write(ODataStreamer.CRLF);
                     writeHttpHeader(batchRequestHeaderOutputStream, HttpHeader.ODATA_VERSION,
                             ODataServiceVersion.V40.toString());
@@ -798,7 +799,7 @@ public final class Olingo4AppImpl implements Olingo4App {
                         batchRequestHeaderOutputStream.write(ODataStreamer.CRLF);
                     }
 
-                    batchRequestHeaderOutputStream.write(boundary.getBytes(Constants.UTF8));
+                    batchRequestHeaderOutputStream.write(boundary.getBytes(StandardCharsets.UTF_8));
                     batchRequestHeaderOutputStream.write(ODataStreamer.CRLF);
                 } else {
                     throw new ODataException("Unsupported batch part request object type: " + batchPart);
@@ -812,7 +813,7 @@ public final class Olingo4AppImpl implements Olingo4App {
 
     private void writeHttpHeader(ByteArrayOutputStream headerOutputStream, String headerName, String headerValue)
             throws IOException {
-        headerOutputStream.write(createHttpHeader(headerName, headerValue).getBytes(Constants.UTF8));
+        headerOutputStream.write(createHttpHeader(headerName, headerValue).getBytes(StandardCharsets.UTF_8));
         headerOutputStream.write(ODataStreamer.CRLF);
     }
 
@@ -827,7 +828,7 @@ public final class Olingo4AppImpl implements Olingo4App {
         try {
             final Header[] contentHeaders = response.getHeaders(HttpHeader.CONTENT_TYPE);
             final ODataBatchLineIterator batchLineIterator
-                    = new ODataBatchLineIteratorImpl(IOUtils.lineIterator(response.getEntity().getContent(), Constants.UTF8));
+                    = new ODataBatchLineIteratorImpl(IOUtils.lineIterator(response.getEntity().getContent(), StandardCharsets.UTF_8));
             final String batchBoundary = ODataBatchUtilities.getBoundaryFromHeader(getHeadersCollection(contentHeaders));
             final ODataBatchController batchController = new ODataBatchController(batchLineIterator, batchBoundary);
 
@@ -895,7 +896,7 @@ public final class Olingo4AppImpl implements Olingo4App {
     }
 
     private HttpResponse constructBatchPartHttpResponse(InputStream batchPartStream) throws IOException, HttpException {
-        final LineIterator lines = IOUtils.lineIterator(batchPartStream, Constants.UTF8);
+        final LineIterator lines = IOUtils.lineIterator(batchPartStream, StandardCharsets.UTF_8);
         final ByteArrayOutputStream headerOutputStream = new ByteArrayOutputStream();
         final ByteArrayOutputStream bodyOutputStream = new ByteArrayOutputStream();
 
@@ -917,11 +918,11 @@ public final class Olingo4AppImpl implements Olingo4App {
             }
             if (startBatchPartHeader) {
                 // Write header to the output stream
-                headerOutputStream.write(line.getBytes(Constants.UTF8));
+                headerOutputStream.write(line.getBytes(StandardCharsets.UTF_8));
                 headerOutputStream.write(ODataStreamer.CRLF);
             } else if (startBatchPartBody && StringUtils.isNotBlank(line)) {
                 // Write body to the output stream
-                bodyOutputStream.write(line.getBytes(Constants.UTF8));
+                bodyOutputStream.write(line.getBytes(StandardCharsets.UTF_8));
                 bodyOutputStream.write(ODataStreamer.CRLF);
             }
         }