You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/08/31 12:15:01 UTC

[camel] branch master updated (28ddaca -> d4f0d33)

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

acosentino pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 28ddaca  Upgrade Jxmpp to version 0.6.3
     new 64b48e6  Better readResponse methods in camel-slack component
     new d4f0d33  Fixed CS

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../slack/SlackComponentVerifierExtension.java     | 19 +-------
 .../camel/component/slack/SlackConsumer.java       | 17 +------
 .../camel/component/slack/utils/SlackUtils.java    | 53 ++++++++++++++++++++++
 3 files changed, 57 insertions(+), 32 deletions(-)
 create mode 100644 components/camel-slack/src/main/java/org/apache/camel/component/slack/utils/SlackUtils.java


[camel] 02/02: Fixed CS

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d4f0d33703e700c037a11fed2250dfa83499fc98
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Aug 31 14:14:43 2018 +0200

    Fixed CS
---
 .../main/java/org/apache/camel/component/slack/utils/SlackUtils.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/components/camel-slack/src/main/java/org/apache/camel/component/slack/utils/SlackUtils.java b/components/camel-slack/src/main/java/org/apache/camel/component/slack/utils/SlackUtils.java
index f5e049f..5e367ee 100644
--- a/components/camel-slack/src/main/java/org/apache/camel/component/slack/utils/SlackUtils.java
+++ b/components/camel-slack/src/main/java/org/apache/camel/component/slack/utils/SlackUtils.java
@@ -32,8 +32,8 @@ public final class SlackUtils {
     public static String readResponse(HttpResponse response) throws IOException {
         ByteArrayOutputStream result = new ByteArrayOutputStream();
         try (InputStream s = response.getEntity().getContent()) {
-        byte[] buffer = new byte[1024];
-        int length;
+            byte[] buffer = new byte[1024];
+            int length;
             while ((length = s.read(buffer)) != -1) {
                 result.write(buffer, 0, length);
             }


[camel] 01/02: Better readResponse methods in camel-slack component

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 64b48e695937601c821b97edc64d02e7b5ca467c
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Aug 31 14:09:37 2018 +0200

    Better readResponse methods in camel-slack component
---
 .../slack/SlackComponentVerifierExtension.java     | 19 +-------
 .../camel/component/slack/SlackConsumer.java       | 17 +------
 .../camel/component/slack/utils/SlackUtils.java    | 53 ++++++++++++++++++++++
 3 files changed, 57 insertions(+), 32 deletions(-)

diff --git a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackComponentVerifierExtension.java b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackComponentVerifierExtension.java
index 9cdb350..7eb6650 100644
--- a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackComponentVerifierExtension.java
+++ b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackComponentVerifierExtension.java
@@ -16,11 +16,6 @@
  */
 package org.apache.camel.component.slack;
 
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -29,7 +24,6 @@ import java.util.Map;
 import org.apache.camel.component.extension.verifier.DefaultComponentVerifierExtension;
 import org.apache.camel.component.extension.verifier.ResultBuilder;
 import org.apache.camel.component.extension.verifier.ResultErrorBuilder;
-import org.apache.camel.component.extension.verifier.ResultErrorHelper;
 import org.apache.camel.component.slack.helper.SlackMessage;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.http.HttpResponse;
@@ -42,6 +36,8 @@ import org.apache.http.message.BasicNameValuePair;
 import org.json.simple.JSONObject;
 import org.json.simple.parser.JSONParser;
 
+import static org.apache.camel.component.slack.utils.SlackUtils.readResponse;
+
 public class SlackComponentVerifierExtension extends DefaultComponentVerifierExtension {
 
     public SlackComponentVerifierExtension() {
@@ -139,17 +135,6 @@ public class SlackComponentVerifierExtension extends DefaultComponentVerifierExt
         }
     }
 
-    private String readResponse(InputStream s) throws IOException, UnsupportedEncodingException {
-        ByteArrayOutputStream result = new ByteArrayOutputStream();
-        byte[] buffer = new byte[1024];
-        int length;
-        while ((length = s.read(buffer)) != -1) {
-            result.write(buffer, 0, length);
-        }
-        String jsonString = result.toString(StandardCharsets.UTF_8.name());
-        return jsonString;
-    }
-
     protected String asJson(SlackMessage message) {
         Map<String, Object> jsonMap = new HashMap<>();
 
diff --git a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackConsumer.java b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackConsumer.java
index c2b1acd..948a38c 100644
--- a/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackConsumer.java
+++ b/components/camel-slack/src/main/java/org/apache/camel/component/slack/SlackConsumer.java
@@ -16,10 +16,7 @@
  */
 package org.apache.camel.component.slack;
 
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -44,6 +41,8 @@ import org.json.simple.parser.ParseException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.camel.component.slack.utils.SlackUtils.readResponse;
+
 public class SlackConsumer extends ScheduledBatchPollingConsumer {
 
     private static final Logger LOG = LoggerFactory.getLogger(SlackConsumer.class);
@@ -159,16 +158,4 @@ public class SlackConsumer extends ScheduledBatchPollingConsumer {
         return jsonString;
     }
 
-    private String readResponse(HttpResponse response) throws IOException {
-        InputStream s = response.getEntity().getContent();
-        ByteArrayOutputStream result = new ByteArrayOutputStream();
-        byte[] buffer = new byte[1024];
-        int length;
-        while ((length = s.read(buffer)) != -1) {
-            result.write(buffer, 0, length);
-        }
-        String jsonString = result.toString(StandardCharsets.UTF_8.name());
-        return jsonString;
-    }
-
 }
diff --git a/components/camel-slack/src/main/java/org/apache/camel/component/slack/utils/SlackUtils.java b/components/camel-slack/src/main/java/org/apache/camel/component/slack/utils/SlackUtils.java
new file mode 100644
index 0000000..f5e049f
--- /dev/null
+++ b/components/camel-slack/src/main/java/org/apache/camel/component/slack/utils/SlackUtils.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.slack.utils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.http.HttpResponse;
+
+public final class SlackUtils {
+
+    private SlackUtils() {
+    }
+
+    public static String readResponse(HttpResponse response) throws IOException {
+        ByteArrayOutputStream result = new ByteArrayOutputStream();
+        try (InputStream s = response.getEntity().getContent()) {
+        byte[] buffer = new byte[1024];
+        int length;
+            while ((length = s.read(buffer)) != -1) {
+                result.write(buffer, 0, length);
+            }
+        }
+        return result.toString(StandardCharsets.UTF_8.name());
+    }
+
+    public static String readResponse(InputStream s) throws IOException, UnsupportedEncodingException {
+        ByteArrayOutputStream result = new ByteArrayOutputStream();
+        byte[] buffer = new byte[1024];
+        int length;
+        while ((length = s.read(buffer)) != -1) {
+            result.write(buffer, 0, length);
+        }
+        return result.toString(StandardCharsets.UTF_8.name());
+    }
+}