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 2020/04/10 08:43:20 UTC

[camel] 01/02: CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-translate use mandatory body

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 61d72c6a19efe8d3093be652e3e28a5bd1c03113
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Apr 10 10:39:23 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-translate use mandatory body
---
 .../camel/component/aws2/translate/Translate2Producer.java       | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Producer.java b/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Producer.java
index ef4ec84..bd6eaf53 100644
--- a/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Producer.java
+++ b/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2Producer.java
@@ -20,6 +20,7 @@ import java.util.Collection;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
+import org.apache.camel.InvalidPayloadException;
 import org.apache.camel.Message;
 import org.apache.camel.support.DefaultProducer;
 import org.apache.camel.util.ObjectHelper;
@@ -81,11 +82,10 @@ public class Translate2Producer extends DefaultProducer {
         return (Translate2Endpoint)super.getEndpoint();
     }
 
-    private void translateText(TranslateClient translateClient, Exchange exchange) {
+    private void translateText(TranslateClient translateClient, Exchange exchange) throws InvalidPayloadException {
         if (getConfiguration().isPojoRequest()) {
-            if (ObjectHelper.isNotEmpty(exchange.getIn().getBody())) {
-                if (exchange.getIn().getBody() instanceof TranslateTextRequest) {
-                    Object payload = exchange.getIn().getBody();
+        	Object payload = exchange.getIn().getMandatoryBody();
+                if (payload instanceof TranslateTextRequest) {
                     TranslateTextResponse result;
                     try {
                         result = translateClient.translateText((TranslateTextRequest)payload);
@@ -95,7 +95,6 @@ public class Translate2Producer extends DefaultProducer {
                     }
                     Message message = getMessageForResponse(exchange);
                     message.setBody(result.translatedText());
-                }
             }
         } else {
             Builder request = TranslateTextRequest.builder();