You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/05/17 06:30:44 UTC

[camel] branch master updated (536ed17 -> 9f55896)

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

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


    from 536ed17  Regen
     new 61e5de9  Polished
     new 9f55896  Regen

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:
 .../src/main/docs/soroush-component.adoc           | 15 ++--
 .../soroushbot/component/SoroushBotEndpoint.java   | 84 +++++++++-------------
 components/readme.adoc                             |  4 +-
 docs/components/modules/ROOT/nav.adoc              |  2 +-
 .../modules/ROOT/pages/soroush-component.adoc      | 15 ++--
 .../SoroushBotComponentConfiguration.java          |  3 +-
 6 files changed, 56 insertions(+), 67 deletions(-)


[camel] 01/02: Polished

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

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

commit 61e5de9a3a7e0a651a31132325548c5da8fc9004
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu May 16 20:19:35 2019 +0200

    Polished
---
 .../src/main/docs/soroush-component.adoc           | 13 ++--
 .../soroushbot/component/SoroushBotEndpoint.java   | 84 +++++++++-------------
 .../SoroushBotComponentConfiguration.java          |  3 +-
 3 files changed, 42 insertions(+), 58 deletions(-)

diff --git a/components/camel-soroush/src/main/docs/soroush-component.adoc b/components/camel-soroush/src/main/docs/soroush-component.adoc
index a3e4078..4fa1f18 100644
--- a/components/camel-soroush/src/main/docs/soroush-component.adoc
+++ b/components/camel-soroush/src/main/docs/soroush-component.adoc
@@ -1,7 +1,8 @@
-[[soroush-component]]
-== SoroushBot Component
+== Soroush Component
 
 *Available as of Camel version 3.0*
+*Available as of Camel version 3.0*
+
 
 The *Soroush* component provides access to the https://soroush-app.ir/developer.html[Soroush Bot API].
 It allows a Camel-based application to send and receive messages by acting as a Bot, i.e. participating in direct conversation with normal users and send and receive message and files
@@ -51,7 +52,7 @@ and store the urls in the message (`SoroushMessage.fileUrl`, `SoroushMessage.thu
 
 
 // component options: START
-The SoroushBot component supports 2 options, which are listed below.
+The Soroush component supports 2 options, which are listed below.
 
 
 
@@ -63,10 +64,10 @@ The SoroushBot component supports 2 options, which are listed below.
 |===
 // component options: END
 // endpoint options: START
-The SoroushBot endpoint is configured using URI syntax:
+The Soroush endpoint is configured using URI syntax:
 
 ----
-soroush:<endpoint>[/authorizationToken][?options]
+soroush:endpoint/authorizationToken
 ----
 
 with the following path and query parameters:
@@ -77,7 +78,7 @@ with the following path and query parameters:
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *endpoint* | *Required* The endpoint type. it support getMessage as consumer and sendMessage,uploadFile,downloadFile as producer |  | Endpoint
+| *endpoint* | *Required* The endpoint type. Support getMessage as consumer and sendMessage,uploadFile,downloadFile as producer |  | Endpoint
 |===
 
 
diff --git a/components/camel-soroush/src/main/java/org/apache/camel/component/soroushbot/component/SoroushBotEndpoint.java b/components/camel-soroush/src/main/java/org/apache/camel/component/soroushbot/component/SoroushBotEndpoint.java
index 7730381..e818887 100644
--- a/components/camel-soroush/src/main/java/org/apache/camel/component/soroushbot/component/SoroushBotEndpoint.java
+++ b/components/camel-soroush/src/main/java/org/apache/camel/component/soroushbot/component/SoroushBotEndpoint.java
@@ -53,17 +53,16 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * this class represents Soroush Endpoint, it is also a bean containing the configuration of the Endpoint
+ * To integrate with the Soroush chat bot.
  */
-@UriEndpoint(firstVersion = "3.0", scheme = "soroush", title = "SoroushBot", syntax = "soroush:<endpoint>[/authorizationToken][?options]", label = "chat")
+@UriEndpoint(firstVersion = "3.0", scheme = "soroush", title = "Soroush", syntax = "soroush:endpoint/authorizationToken", label = "chat")
 public class SoroushBotEndpoint extends DefaultEndpoint {
-    private static Logger log = LoggerFactory.getLogger(SoroushBotEndpoint.class);
 
-    @UriPath(name = "endpoint", enums = "Endpoint", javaType = "Endpoint",
-            description = "The endpoint type. it support `getMessage` as consumer and `sendMessage`,`uploadFile`,`downloadFile` as producer")
+    private static final Logger LOG = LoggerFactory.getLogger(SoroushBotEndpoint.class);
+
+    @UriPath(name = "endpoint", description = "The endpoint type. Support `getMessage` as consumer and `sendMessage`,`uploadFile`,`downloadFile` as producer")
     @Metadata(required = true)
     Endpoint type;
-
     @UriPath(label = "global,security", description = "The authorization token for using"
             + " the bot (ask the @mrbot) e.g. 9yDv09nqKvP9CkBGKNmKQHir1dj2qLpN-YWa8hP7Rm3LK\"\n"
             + "            + \"3MqQXYdXZIA5W4e0agPiUb-3eUKX69ozUNdY9yZBMlJiwnlksslkjWjsxcARo5cYtDnKTElig0xa\"\n"
@@ -140,7 +139,6 @@ public class SoroushBotEndpoint extends DefaultEndpoint {
         super(endpointUri, component);
     }
 
-
     /**
      * @return supported Soroush endpoint as string to display in error.
      */
@@ -294,8 +292,6 @@ public class SoroushBotEndpoint extends DefaultEndpoint {
 
     /**
      * return the lazily created instance of {@link SoroushBotEndpoint#uploadFileTarget} to used for uploading file to soroush.
-     *
-     * @return WebTarget
      */
     private WebTarget getUploadFileTarget() {
         if (uploadFileTarget == null) {
@@ -310,8 +306,6 @@ public class SoroushBotEndpoint extends DefaultEndpoint {
 
     /**
      * return the lazily created instance of {@link SoroushBotEndpoint#sendMessageTarget} to used for sending message to soroush.
-     *
-     * @return WebTarget
      */
     WebTarget getSendMessageTarget() {
         if (sendMessageTarget == null) {
@@ -462,10 +456,6 @@ public class SoroushBotEndpoint extends DefaultEndpoint {
 
     /**
      * try to upload an inputStream to server
-     *
-     * @param inputStream
-     * @param message
-     * @param fileType
      */
     private UploadFileResponse uploadToServer(InputStream inputStream, SoroushMessage message, String fileType) throws SoroushException, InterruptedException {
         javax.ws.rs.core.Response response;
@@ -476,8 +466,8 @@ public class SoroushBotEndpoint extends DefaultEndpoint {
             multipart.setMediaType(MediaType.MULTIPART_FORM_DATA_TYPE);
             multipart.bodyPart(new StreamDataBodyPart("file", inputStream, null, MediaType.APPLICATION_OCTET_STREAM_TYPE));
             try {
-                if (log.isDebugEnabled()) {
-                    log.debug("try to upload " + fileType + " for the " + StringUtils.ordinal(count + 1) + " time for message:" + message);
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("try to upload " + fileType + " for the " + StringUtils.ordinal(count + 1) + " time for message:" + message);
                 }
                 response = getUploadFileTarget().request(MediaType.APPLICATION_JSON_TYPE)
                         .post(Entity.entity(multipart, multipart.getMediaType()));
@@ -488,12 +478,12 @@ public class SoroushBotEndpoint extends DefaultEndpoint {
                     throw new MaximumConnectionRetryReachedException("uploading " + fileType + " for message " + message + " failed. Maximum retry limit reached!"
                             + " aborting upload file and send message", ex, message);
                 }
-                if (log.isWarnEnabled()) {
-                    log.warn("uploading " + fileType + " for message " + message + " failed", ex);
+                if (LOG.isWarnEnabled()) {
+                    LOG.warn("uploading " + fileType + " for message " + message + " failed", ex);
                 }
             }
         }
-        log.error("should never reach this line of code because maxConnectionRetry is greater than -1 and at least the above for must execute single time and");
+        LOG.error("should never reach this line of code because maxConnectionRetry is greater than -1 and at least the above for must execute single time and");
         //for backup
         throw new MaximumConnectionRetryReachedException("uploading " + fileType + " for message " + message + " failed. Maximum retry limit reached! aborting "
                 + "upload file and send message", message);
@@ -503,33 +493,32 @@ public class SoroushBotEndpoint extends DefaultEndpoint {
      * check if {@link SoroushMessage#file} or {@link SoroushMessage#thumbnail} is populated and upload them to the server.
      * after that it set {@link SoroushMessage#fileUrl} and {@link SoroushMessage#thumbnailUrl} to appropriate value
      *
-     * @param message
      * @throws SoroushException if soroush reject the file
      */
     void handleFileUpload(SoroushMessage message) throws SoroushException, InterruptedException {
-        if (log.isTraceEnabled()) {
-            log.trace("try to upload file(s) to server if exists for message:" + message.toString());
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("try to upload file(s) to server if exists for message:" + message.toString());
         }
         InputStream file = message.getFile();
         if (file != null && (message.getFileUrl() == null || forceUpload)) {
-            if (log.isDebugEnabled()) {
-                log.debug("uploading file to server for message: " + message);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("uploading file to server for message: " + message);
             }
             UploadFileResponse response = uploadToServer(file, message, "file");
             message.setFileUrl(response.getFileUrl());
-            if (log.isDebugEnabled()) {
-                log.debug("uploaded file url is: " + response.getFileUrl() + " for message: " + message);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("uploaded file url is: " + response.getFileUrl() + " for message: " + message);
             }
         }
         InputStream thumbnail = message.getThumbnail();
         if (thumbnail != null && message.getThumbnailUrl() == null) {
-            if (log.isDebugEnabled()) {
-                log.debug("uploading thumbnail to server for message: " + message);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("uploading thumbnail to server for message: " + message);
             }
             UploadFileResponse response = uploadToServer(thumbnail, message, "thumbnail");
             message.setThumbnailUrl(response.getFileUrl());
-            if (log.isDebugEnabled()) {
-                log.debug("uploaded thumbnail url is: " + response.getFileUrl() + " for message: " + message);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("uploaded thumbnail url is: " + response.getFileUrl() + " for message: " + message);
             }
         }
     }
@@ -539,28 +528,27 @@ public class SoroushBotEndpoint extends DefaultEndpoint {
      * this function only set {@link SoroushMessage#file} to {@link InputStream} get from {@link Response#readEntity(Class)} )}
      * and does not store the resource in file.
      *
-     * @param message
      * @throws SoroushException if the file does not exists on soroush or soroush reject the request
      */
     public void handleDownloadFiles(SoroushMessage message) throws SoroushException {
         if (message.getFileUrl() != null && (message.getFile() == null || forceDownload)) {
-            if (log.isDebugEnabled()) {
-                log.debug("downloading file from server for message: " + message);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("downloading file from server for message: " + message);
             }
             InputStream inputStream = downloadFromServer(message.getFileUrl(), message, "file");
             message.setFile(inputStream);
-            if (log.isDebugEnabled()) {
-                log.debug("file successfully downloaded for message: " + message);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("file successfully downloaded for message: " + message);
             }
         }
         if (downloadThumbnail && message.getThumbnailUrl() != null && (message.getThumbnail() == null || forceDownload)) {
-            if (log.isDebugEnabled()) {
-                log.debug("downloading thumbnail from server for message: " + message);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("downloading thumbnail from server for message: " + message);
             }
             InputStream inputStream = downloadFromServer(message.getThumbnailUrl(), message, "thumbnail");
             message.setThumbnail(inputStream);
-            if (log.isDebugEnabled()) {
-                log.debug("thumbnail successfully downloaded for message: " + message);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("thumbnail successfully downloaded for message: " + message);
             }
         }
     }
@@ -569,21 +557,17 @@ public class SoroushBotEndpoint extends DefaultEndpoint {
      * download the resource stored with the key {@code fileUrl} from Soroush Server.
      * other parameters are used only for logging.
      *
-     * @param fileUrl
-     * @param message
-     * @param type
-     * @return
      * @throws SoroushException if soroush reject the request
      */
     private InputStream downloadFromServer(String fileUrl, SoroushMessage message, String type) throws SoroushException {
         Response response = null;
         for (int i = 0; i <= maxConnectionRetry; i++) {
             WebTarget target = getDownloadFileTarget(fileUrl);
-            if (log.isDebugEnabled()) {
+            if (LOG.isDebugEnabled()) {
                 if (i != 0) {
-                    log.debug("retry downloading " + type + ": " + fileUrl + " for the " + StringUtils.ordinal(i) + " time");
+                    LOG.debug("retry downloading " + type + ": " + fileUrl + " for the " + StringUtils.ordinal(i) + " time");
                 }
-                log.debug("try to download " + type + ": " + fileUrl + " with url: " + target.getUri() + "\nfor message: " + message);
+                LOG.debug("try to download " + type + ": " + fileUrl + " with url: " + target.getUri() + "\nfor message: " + message);
             }
             try {
                 response = target.request().get();
@@ -592,13 +576,13 @@ public class SoroushBotEndpoint extends DefaultEndpoint {
                 if (i == maxConnectionRetry) {
                     throw new MaximumConnectionRetryReachedException("maximum connection retry reached for " + type + ": " + fileUrl, ex, message);
                 }
-                if (log.isWarnEnabled()) {
-                    log.warn("can not download " + type + ": " + fileUrl + " from soroush. Response code is", ex);
+                if (LOG.isWarnEnabled()) {
+                    LOG.warn("can not download " + type + ": " + fileUrl + " from soroush. Response code is", ex);
                 }
             }
         }
         //should never reach this line
-        log.error("should never reach this line. An exception should have been thrown by catch block for target.request().get");
+        LOG.error("should never reach this line. An exception should have been thrown by catch block for target.request().get");
         throw new MaximumConnectionRetryReachedException("can not upload " + type + ": " + fileUrl + " response:" + ((response == null) ? null : response.getStatus()), message);
     }
 
diff --git a/platforms/spring-boot/components-starter/camel-soroush-starter/src/main/java/org/apache/camel/component/soroushbot/component/springboot/SoroushBotComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-soroush-starter/src/main/java/org/apache/camel/component/soroushbot/component/springboot/SoroushBotComponentConfiguration.java
index e0968af..3c71c4d 100644
--- a/platforms/spring-boot/components-starter/camel-soroush-starter/src/main/java/org/apache/camel/component/soroushbot/component/springboot/SoroushBotComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-soroush-starter/src/main/java/org/apache/camel/component/soroushbot/component/springboot/SoroushBotComponentConfiguration.java
@@ -21,8 +21,7 @@ import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
 /**
- * this class represents Soroush Endpoint, it is also a bean containing the
- * configuration of the Endpoint
+ * To integrate with the Soroush chat bot.
  * 
  * Generated by camel-package-maven-plugin - do not edit this file!
  */


[camel] 02/02: Regen

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

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

commit 9f55896b624ef073cea108126373966b26710eeb
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri May 17 08:30:29 2019 +0200

    Regen
---
 .../camel-soroush/src/main/docs/soroush-component.adoc    |  4 +++-
 components/readme.adoc                                    |  4 ++--
 docs/components/modules/ROOT/nav.adoc                     |  2 +-
 docs/components/modules/ROOT/pages/soroush-component.adoc | 15 +++++++++------
 4 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/components/camel-soroush/src/main/docs/soroush-component.adoc b/components/camel-soroush/src/main/docs/soroush-component.adoc
index 4fa1f18..09cb21a 100644
--- a/components/camel-soroush/src/main/docs/soroush-component.adoc
+++ b/components/camel-soroush/src/main/docs/soroush-component.adoc
@@ -1,6 +1,8 @@
+[[soroush-component]]
 == Soroush Component
 
 *Available as of Camel version 3.0*
+
 *Available as of Camel version 3.0*
 
 
@@ -275,4 +277,4 @@ One way to handle these exceptions is by using `onException` route definition:
 onException(CongestionException.class).log("Failed to processing ${id}")
 -------------
 
-_Developed and supported by https://www.mohaymen.ir[Mohaymen ICT]_
+_Developed and supported by https://www.mohaymen.ir[Mohaymen ICT]_
\ No newline at end of file
diff --git a/components/readme.adoc b/components/readme.adoc
index 927e597..0a7386d 100644
--- a/components/readme.adoc
+++ b/components/readme.adoc
@@ -760,8 +760,8 @@ Number of Components: 295 in 232 JAR artifacts (0 deprecated)
 | link:camel-solr/src/main/docs/solr-component.adoc[Solr] (camel-solr) +
 `solr:url` | 2.9 | The solr component allows you to interface with an Apache Lucene Solr server.
 
-| link:camel-soroush/src/main/docs/soroush-component.adoc[SoroushBot] (camel-soroush) +
-`soroush:<endpoint>[/authorizationToken][?options]` | 3.0 | this class represents Soroush Endpoint, it is also a bean containing the configuration of the Endpoint
+| link:camel-soroush/src/main/docs/soroush-component.adoc[Soroush] (camel-soroush) +
+`soroush:endpoint/authorizationToken` | 3.0 | To integrate with the Soroush chat bot.
 
 | link:camel-spark-rest/src/main/docs/spark-rest-component.adoc[Spark Rest] (camel-spark-rest) +
 `spark-rest:verb:path` | 2.14 | The spark-rest component is used for hosting REST services which has been defined using Camel rest-dsl.
diff --git a/docs/components/modules/ROOT/nav.adoc b/docs/components/modules/ROOT/nav.adoc
index bb597ee..fb8a7cb 100644
--- a/docs/components/modules/ROOT/nav.adoc
+++ b/docs/components/modules/ROOT/nav.adoc
@@ -290,7 +290,7 @@
 * xref:snmp-component.adoc[SNMP Component]
 * xref:soapjaxb-dataformat.adoc[SOAP DataFormat]
 * xref:solr-component.adoc[Solr Component]
-* xref:soroush-component.adoc[SoroushBot Component]
+* xref:soroush-component.adoc[Soroush Component]
 * xref:spark-rest-component.adoc[Spark Rest Component]
 * xref:spark-component.adoc[Apache Spark Component]
 * xref:splunk-component.adoc[Splunk Component]
diff --git a/docs/components/modules/ROOT/pages/soroush-component.adoc b/docs/components/modules/ROOT/pages/soroush-component.adoc
index a3e4078..09cb21a 100644
--- a/docs/components/modules/ROOT/pages/soroush-component.adoc
+++ b/docs/components/modules/ROOT/pages/soroush-component.adoc
@@ -1,8 +1,11 @@
 [[soroush-component]]
-== SoroushBot Component
+== Soroush Component
 
 *Available as of Camel version 3.0*
 
+*Available as of Camel version 3.0*
+
+
 The *Soroush* component provides access to the https://soroush-app.ir/developer.html[Soroush Bot API].
 It allows a Camel-based application to send and receive messages by acting as a Bot, i.e. participating in direct conversation with normal users and send and receive message and files
 
@@ -51,7 +54,7 @@ and store the urls in the message (`SoroushMessage.fileUrl`, `SoroushMessage.thu
 
 
 // component options: START
-The SoroushBot component supports 2 options, which are listed below.
+The Soroush component supports 2 options, which are listed below.
 
 
 
@@ -63,10 +66,10 @@ The SoroushBot component supports 2 options, which are listed below.
 |===
 // component options: END
 // endpoint options: START
-The SoroushBot endpoint is configured using URI syntax:
+The Soroush endpoint is configured using URI syntax:
 
 ----
-soroush:<endpoint>[/authorizationToken][?options]
+soroush:endpoint/authorizationToken
 ----
 
 with the following path and query parameters:
@@ -77,7 +80,7 @@ with the following path and query parameters:
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
 | Name | Description | Default | Type
-| *endpoint* | *Required* The endpoint type. it support getMessage as consumer and sendMessage,uploadFile,downloadFile as producer |  | Endpoint
+| *endpoint* | *Required* The endpoint type. Support getMessage as consumer and sendMessage,uploadFile,downloadFile as producer |  | Endpoint
 |===
 
 
@@ -274,4 +277,4 @@ One way to handle these exceptions is by using `onException` route definition:
 onException(CongestionException.class).log("Failed to processing ${id}")
 -------------
 
-_Developed and supported by https://www.mohaymen.ir[Mohaymen ICT]_
+_Developed and supported by https://www.mohaymen.ir[Mohaymen ICT]_
\ No newline at end of file