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 2021/03/31 09:32:07 UTC

[camel] branch master updated (5e8e0ee -> a08f45a)

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 5e8e0ee  Regen for commit 27b1f4bfa6819b8ac11c158e73d62474065ba6e8
     new c5aad76  Camel-AWS2-Lambda: Producer operations refactoring - publishVersion
     new b053f0e  Camel-AWS2-Lambda: Producer operations refactoring - publishVersion
     new cb993d8  Camel-AWS2-Lambda: Producer operations refactoring - listVersions
     new 86ee6e8  Fixed CS
     new ffc3fbf  Camel-AWS2-Lambda: Producer operations refactoring - createAlias
     new a92cbdf  Camel-AWS2-Lambda: Producer operations refactoring - deleteAlias
     new 941954d  Camel-AWS2-Lambda: Producer operations refactoring - getAlias
     new 26101d0  Camel-AWS2-Lambda: Producer operations refactoring - listAliases
     new a08f45a  Fixed CS

The 9 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:
 .../component/aws2/lambda/Lambda2Producer.java     | 276 +++++++++------------
 1 file changed, 112 insertions(+), 164 deletions(-)

[camel] 07/09: Camel-AWS2-Lambda: Producer operations refactoring - getAlias

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 941954dc41b50cdda92683d9253ddd0758e81a39
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 31 11:24:32 2021 +0200

    Camel-AWS2-Lambda: Producer operations refactoring - getAlias
---
 .../component/aws2/lambda/Lambda2Producer.java     | 27 ++++++++--------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
index 8d4efa1..e960a67 100644
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
+++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
@@ -672,36 +672,27 @@ public class Lambda2Producer extends DefaultProducer {
     }
 
     private void getAlias(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {
+    	GetAliasRequest request = null;
+    	GetAliasResponse result;
         if (getConfiguration().isPojoRequest()) {
-            Object payload = exchange.getIn().getMandatoryBody();
-            if (payload instanceof GetAliasRequest) {
-                GetAliasResponse result;
-                try {
-                    result = lambdaClient.getAlias((GetAliasRequest) payload);
-                } catch (AwsServiceException ase) {
-                    LOG.trace("getAlias command returned the error code {}", ase.awsErrorDetails().errorCode());
-                    throw ase;
-                }
-                Message message = getMessageForResponse(exchange);
-                message.setBody(result);
-            }
+            request = exchange.getIn().getMandatoryBody(GetAliasRequest.class);
         } else {
-            GetAliasResponse result;
-            try {
-                GetAliasRequest.Builder request = GetAliasRequest.builder().functionName(getEndpoint().getFunction());
+                GetAliasRequest.Builder builder = GetAliasRequest.builder();
+                builder.functionName(getEndpoint().getFunction());
                 String aliasName = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_ALIAS_NAME, String.class);
                 if (ObjectHelper.isEmpty(aliasName)) {
                     throw new IllegalArgumentException("Function alias must be specified to get an alias");
                 }
-                request.name(aliasName);
-                result = lambdaClient.getAlias(request.build());
+                builder.name(aliasName);
+        }
+                try {
+                result = lambdaClient.getAlias(request);
             } catch (AwsServiceException ase) {
                 LOG.trace("getAlias command returned the error code {}", ase.awsErrorDetails().errorCode());
                 throw ase;
             }
             Message message = getMessageForResponse(exchange);
             message.setBody(result);
-        }
     }
 
     private void listAliases(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {

[camel] 01/09: Camel-AWS2-Lambda: Producer operations refactoring - publishVersion

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 c5aad76af54390f9b2b34c6d50e9ba8a3d1422ef
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 31 11:03:59 2021 +0200

    Camel-AWS2-Lambda: Producer operations refactoring - publishVersion
---
 .../component/aws2/lambda/Lambda2Producer.java     | 31 ++++++++--------------
 1 file changed, 11 insertions(+), 20 deletions(-)

diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
index 6ae671b..755aebc 100644
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
+++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
@@ -567,40 +567,31 @@ public class Lambda2Producer extends DefaultProducer {
     }
 
     private void publishVersion(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {
+    	PublishVersionRequest request = null;
+    	PublishVersionResponse result;
         if (getConfiguration().isPojoRequest()) {
-            Object payload = exchange.getIn().getMandatoryBody();
-            if (payload instanceof PublishVersionRequest) {
-                PublishVersionResponse result;
-                try {
-                    result = lambdaClient.publishVersion((PublishVersionRequest) payload);
-                } catch (AwsServiceException ase) {
-                    LOG.trace("publishVersion command returned the error code {}", ase.awsErrorDetails().errorCode());
-                    throw ase;
-                }
-                Message message = getMessageForResponse(exchange);
-                message.setBody(result);
-            }
+            request = exchange.getIn().getMandatoryBody(PublishVersionRequest.class);
         } else {
-            PublishVersionResponse result;
-            try {
-                PublishVersionRequest.Builder request
-                        = PublishVersionRequest.builder().functionName(getEndpoint().getFunction());
+                PublishVersionRequest.Builder builder = PublishVersionRequest.builder();
+                builder.functionName(getEndpoint().getFunction());
                 if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(Lambda2Constants.VERSION_DESCRIPTION))) {
                     String description = exchange.getIn().getHeader(Lambda2Constants.VERSION_DESCRIPTION, String.class);
-                    request.description(description);
+                    builder.description(description);
                 }
                 if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(Lambda2Constants.VERSION_REVISION_ID))) {
                     String revisionId = exchange.getIn().getHeader(Lambda2Constants.VERSION_REVISION_ID, String.class);
-                    request.revisionId(revisionId);
+                    builder.revisionId(revisionId);
                 }
-                result = lambdaClient.publishVersion(request.build());
+                request = builder.build();
+        }
+        try {
+                result = lambdaClient.publishVersion(request);
             } catch (AwsServiceException ase) {
                 LOG.trace("publishVersion command returned the error code {}", ase.awsErrorDetails().errorCode());
                 throw ase;
             }
             Message message = getMessageForResponse(exchange);
             message.setBody(result);
-        }
     }
 
     private void listVersions(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {

[camel] 09/09: 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 a08f45af7be72199f862b3c656edfbbe5791171c
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 31 11:28:47 2021 +0200

    Fixed CS
---
 .../component/aws2/lambda/Lambda2Producer.java     | 150 ++++++++++-----------
 1 file changed, 75 insertions(+), 75 deletions(-)

diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
index 9d0aeaa..cfd5660 100644
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
+++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
@@ -615,108 +615,108 @@ public class Lambda2Producer extends DefaultProducer {
     }
 
     private void createAlias(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {
-    	CreateAliasRequest request = null;
-    	CreateAliasResponse result;
+        CreateAliasRequest request = null;
+        CreateAliasResponse result;
         if (getConfiguration().isPojoRequest()) {
             request = exchange.getIn().getMandatoryBody(CreateAliasRequest.class);
         } else {
-                CreateAliasRequest.Builder builder = CreateAliasRequest.builder();
-                builder.functionName(getEndpoint().getFunction());
-                String version = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_VERSION, String.class);
-                String aliasName = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_ALIAS_NAME, String.class);
-                if (ObjectHelper.isEmpty(version) || ObjectHelper.isEmpty(aliasName)) {
-                    throw new IllegalArgumentException("Function Version and alias must be specified to create an alias");
-                }
-                builder.functionVersion(version);
-                builder.name(aliasName);
-                if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(Lambda2Constants.FUNCTION_ALIAS_DESCRIPTION))) {
-                    String aliasDescription
-                            = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_ALIAS_DESCRIPTION, String.class);
-                    builder.description(aliasDescription);
-                }
-                request = builder.build();
+            CreateAliasRequest.Builder builder = CreateAliasRequest.builder();
+            builder.functionName(getEndpoint().getFunction());
+            String version = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_VERSION, String.class);
+            String aliasName = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_ALIAS_NAME, String.class);
+            if (ObjectHelper.isEmpty(version) || ObjectHelper.isEmpty(aliasName)) {
+                throw new IllegalArgumentException("Function Version and alias must be specified to create an alias");
+            }
+            builder.functionVersion(version);
+            builder.name(aliasName);
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(Lambda2Constants.FUNCTION_ALIAS_DESCRIPTION))) {
+                String aliasDescription
+                        = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_ALIAS_DESCRIPTION, String.class);
+                builder.description(aliasDescription);
+            }
+            request = builder.build();
         }
         try {
-                result = lambdaClient.createAlias(request);
-            } catch (AwsServiceException ase) {
-                LOG.trace("createAlias command returned the error code {}", ase.awsErrorDetails().errorCode());
-                throw ase;
-            }
-            Message message = getMessageForResponse(exchange);
-            message.setBody(result);
+            result = lambdaClient.createAlias(request);
+        } catch (AwsServiceException ase) {
+            LOG.trace("createAlias command returned the error code {}", ase.awsErrorDetails().errorCode());
+            throw ase;
+        }
+        Message message = getMessageForResponse(exchange);
+        message.setBody(result);
     }
 
     private void deleteAlias(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {
-    	DeleteAliasRequest request = null;
-    	DeleteAliasResponse result;
+        DeleteAliasRequest request = null;
+        DeleteAliasResponse result;
         if (getConfiguration().isPojoRequest()) {
             request = exchange.getIn().getMandatoryBody(DeleteAliasRequest.class);
         } else {
-                DeleteAliasRequest.Builder builder = DeleteAliasRequest.builder();
-                builder.functionName(getEndpoint().getFunction());
-                String aliasName = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_ALIAS_NAME, String.class);
-                if (ObjectHelper.isEmpty(aliasName)) {
-                    throw new IllegalArgumentException("Function alias must be specified to delete an alias");
-                }
-                builder.name(aliasName);
-                request = builder.build();
-        }
-        try  {
-                result = lambdaClient.deleteAlias(request);
-            } catch (AwsServiceException ase) {
-                LOG.trace("deleteAlias command returned the error code {}", ase.awsErrorDetails().errorCode());
-                throw ase;
+            DeleteAliasRequest.Builder builder = DeleteAliasRequest.builder();
+            builder.functionName(getEndpoint().getFunction());
+            String aliasName = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_ALIAS_NAME, String.class);
+            if (ObjectHelper.isEmpty(aliasName)) {
+                throw new IllegalArgumentException("Function alias must be specified to delete an alias");
             }
-            Message message = getMessageForResponse(exchange);
-            message.setBody(result);
+            builder.name(aliasName);
+            request = builder.build();
+        }
+        try {
+            result = lambdaClient.deleteAlias(request);
+        } catch (AwsServiceException ase) {
+            LOG.trace("deleteAlias command returned the error code {}", ase.awsErrorDetails().errorCode());
+            throw ase;
+        }
+        Message message = getMessageForResponse(exchange);
+        message.setBody(result);
     }
 
     private void getAlias(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {
-    	GetAliasRequest request = null;
-    	GetAliasResponse result;
+        GetAliasRequest request = null;
+        GetAliasResponse result;
         if (getConfiguration().isPojoRequest()) {
             request = exchange.getIn().getMandatoryBody(GetAliasRequest.class);
         } else {
-                GetAliasRequest.Builder builder = GetAliasRequest.builder();
-                builder.functionName(getEndpoint().getFunction());
-                String aliasName = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_ALIAS_NAME, String.class);
-                if (ObjectHelper.isEmpty(aliasName)) {
-                    throw new IllegalArgumentException("Function alias must be specified to get an alias");
-                }
-                builder.name(aliasName);
-        }
-                try {
-                result = lambdaClient.getAlias(request);
-            } catch (AwsServiceException ase) {
-                LOG.trace("getAlias command returned the error code {}", ase.awsErrorDetails().errorCode());
-                throw ase;
+            GetAliasRequest.Builder builder = GetAliasRequest.builder();
+            builder.functionName(getEndpoint().getFunction());
+            String aliasName = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_ALIAS_NAME, String.class);
+            if (ObjectHelper.isEmpty(aliasName)) {
+                throw new IllegalArgumentException("Function alias must be specified to get an alias");
             }
-            Message message = getMessageForResponse(exchange);
-            message.setBody(result);
+            builder.name(aliasName);
+        }
+        try {
+            result = lambdaClient.getAlias(request);
+        } catch (AwsServiceException ase) {
+            LOG.trace("getAlias command returned the error code {}", ase.awsErrorDetails().errorCode());
+            throw ase;
+        }
+        Message message = getMessageForResponse(exchange);
+        message.setBody(result);
     }
 
     private void listAliases(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {
-    	ListAliasesRequest request = null;
-    	ListAliasesResponse result;
+        ListAliasesRequest request = null;
+        ListAliasesResponse result;
         if (getConfiguration().isPojoRequest()) {
             request = exchange.getIn().getMandatoryBody(ListAliasesRequest.class);
         } else {
-                ListAliasesRequest.Builder builder = ListAliasesRequest.builder();
-                builder.functionName(getEndpoint().getFunction());
-                String version = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_VERSION, String.class);
-                if (ObjectHelper.isEmpty(version)) {
-                    throw new IllegalArgumentException("Function Version must be specified to list aliases for a function");
-                }
-                builder.functionVersion(version);
+            ListAliasesRequest.Builder builder = ListAliasesRequest.builder();
+            builder.functionName(getEndpoint().getFunction());
+            String version = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_VERSION, String.class);
+            if (ObjectHelper.isEmpty(version)) {
+                throw new IllegalArgumentException("Function Version must be specified to list aliases for a function");
+            }
+            builder.functionVersion(version);
         }
         try {
-                result = lambdaClient.listAliases(request);
-            } catch (AwsServiceException ase) {
-                LOG.trace("listAliases command returned the error code {}", ase.awsErrorDetails().errorCode());
-                throw ase;
-            }
-            Message message = getMessageForResponse(exchange);
-            message.setBody(result);
+            result = lambdaClient.listAliases(request);
+        } catch (AwsServiceException ase) {
+            LOG.trace("listAliases command returned the error code {}", ase.awsErrorDetails().errorCode());
+            throw ase;
+        }
+        Message message = getMessageForResponse(exchange);
+        message.setBody(result);
     }
 
     private Lambda2Operations determineOperation(Exchange exchange) {

[camel] 02/09: Camel-AWS2-Lambda: Producer operations refactoring - publishVersion

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 b053f0e1c760e4567fbcb33d3a9bfb746aa74ee9
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 31 11:07:50 2021 +0200

    Camel-AWS2-Lambda: Producer operations refactoring - publishVersion
---
 .../component/aws2/lambda/Lambda2Producer.java     | 40 +++++++++++-----------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
index 755aebc..4e57f7e 100644
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
+++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
@@ -567,31 +567,31 @@ public class Lambda2Producer extends DefaultProducer {
     }
 
     private void publishVersion(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {
-    	PublishVersionRequest request = null;
-    	PublishVersionResponse result;
+        PublishVersionRequest request = null;
+        PublishVersionResponse result;
         if (getConfiguration().isPojoRequest()) {
             request = exchange.getIn().getMandatoryBody(PublishVersionRequest.class);
         } else {
-                PublishVersionRequest.Builder builder = PublishVersionRequest.builder();
-                builder.functionName(getEndpoint().getFunction());
-                if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(Lambda2Constants.VERSION_DESCRIPTION))) {
-                    String description = exchange.getIn().getHeader(Lambda2Constants.VERSION_DESCRIPTION, String.class);
-                    builder.description(description);
-                }
-                if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(Lambda2Constants.VERSION_REVISION_ID))) {
-                    String revisionId = exchange.getIn().getHeader(Lambda2Constants.VERSION_REVISION_ID, String.class);
-                    builder.revisionId(revisionId);
-                }
-                request = builder.build();
+            PublishVersionRequest.Builder builder = PublishVersionRequest.builder();
+            builder.functionName(getEndpoint().getFunction());
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(Lambda2Constants.VERSION_DESCRIPTION))) {
+                String description = exchange.getIn().getHeader(Lambda2Constants.VERSION_DESCRIPTION, String.class);
+                builder.description(description);
+            }
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(Lambda2Constants.VERSION_REVISION_ID))) {
+                String revisionId = exchange.getIn().getHeader(Lambda2Constants.VERSION_REVISION_ID, String.class);
+                builder.revisionId(revisionId);
+            }
+            request = builder.build();
         }
         try {
-                result = lambdaClient.publishVersion(request);
-            } catch (AwsServiceException ase) {
-                LOG.trace("publishVersion command returned the error code {}", ase.awsErrorDetails().errorCode());
-                throw ase;
-            }
-            Message message = getMessageForResponse(exchange);
-            message.setBody(result);
+            result = lambdaClient.publishVersion(request);
+        } catch (AwsServiceException ase) {
+            LOG.trace("publishVersion command returned the error code {}", ase.awsErrorDetails().errorCode());
+            throw ase;
+        }
+        Message message = getMessageForResponse(exchange);
+        message.setBody(result);
     }
 
     private void listVersions(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {

[camel] 04/09: 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 86ee6e805c11e89f84442aeef7d346b5bb1cb7af
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 31 11:13:01 2021 +0200

    Fixed CS
---
 .../component/aws2/lambda/Lambda2Producer.java     | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
index d545aae..3005689 100644
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
+++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
@@ -597,21 +597,21 @@ public class Lambda2Producer extends DefaultProducer {
     private void listVersions(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {
         ListVersionsByFunctionRequest request = null;
         ListVersionsByFunctionResponse result;
-    	if (getConfiguration().isPojoRequest()) {
+        if (getConfiguration().isPojoRequest()) {
             request = exchange.getIn().getMandatoryBody(ListVersionsByFunctionRequest.class);
         } else {
-                ListVersionsByFunctionRequest.Builder builder = ListVersionsByFunctionRequest.builder();
-                builder.functionName(getEndpoint().getFunction());
-                request = builder.build();
+            ListVersionsByFunctionRequest.Builder builder = ListVersionsByFunctionRequest.builder();
+            builder.functionName(getEndpoint().getFunction());
+            request = builder.build();
         }
-    	try {
-                result = lambdaClient.listVersionsByFunction(request);
-            } catch (AwsServiceException ase) {
-                LOG.trace("publishVersion command returned the error code {}", ase.awsErrorDetails().errorCode());
-                throw ase;
-            }
-            Message message = getMessageForResponse(exchange);
-            message.setBody(result);
+        try {
+            result = lambdaClient.listVersionsByFunction(request);
+        } catch (AwsServiceException ase) {
+            LOG.trace("publishVersion command returned the error code {}", ase.awsErrorDetails().errorCode());
+            throw ase;
+        }
+        Message message = getMessageForResponse(exchange);
+        message.setBody(result);
     }
 
     private void createAlias(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {

[camel] 08/09: Camel-AWS2-Lambda: Producer operations refactoring - listAliases

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 26101d0a73aaf291d3270dcd94fd90cd4204c2b4
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 31 11:26:04 2021 +0200

    Camel-AWS2-Lambda: Producer operations refactoring - listAliases
---
 .../component/aws2/lambda/Lambda2Producer.java     | 27 ++++++++--------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
index e960a67..9d0aeaa 100644
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
+++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
@@ -696,36 +696,27 @@ public class Lambda2Producer extends DefaultProducer {
     }
 
     private void listAliases(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {
+    	ListAliasesRequest request = null;
+    	ListAliasesResponse result;
         if (getConfiguration().isPojoRequest()) {
-            Object payload = exchange.getIn().getMandatoryBody();
-            if (payload instanceof ListAliasesRequest) {
-                ListAliasesResponse result;
-                try {
-                    result = lambdaClient.listAliases((ListAliasesRequest) payload);
-                } catch (AwsServiceException ase) {
-                    LOG.trace("listAliases command returned the error code {}", ase.awsErrorDetails().errorCode());
-                    throw ase;
-                }
-                Message message = getMessageForResponse(exchange);
-                message.setBody(result);
-            }
+            request = exchange.getIn().getMandatoryBody(ListAliasesRequest.class);
         } else {
-            ListAliasesResponse result;
-            try {
-                ListAliasesRequest.Builder request = ListAliasesRequest.builder().functionName(getEndpoint().getFunction());
+                ListAliasesRequest.Builder builder = ListAliasesRequest.builder();
+                builder.functionName(getEndpoint().getFunction());
                 String version = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_VERSION, String.class);
                 if (ObjectHelper.isEmpty(version)) {
                     throw new IllegalArgumentException("Function Version must be specified to list aliases for a function");
                 }
-                request.functionVersion(version);
-                result = lambdaClient.listAliases(request.build());
+                builder.functionVersion(version);
+        }
+        try {
+                result = lambdaClient.listAliases(request);
             } catch (AwsServiceException ase) {
                 LOG.trace("listAliases command returned the error code {}", ase.awsErrorDetails().errorCode());
                 throw ase;
             }
             Message message = getMessageForResponse(exchange);
             message.setBody(result);
-        }
     }
 
     private Lambda2Operations determineOperation(Exchange exchange) {

[camel] 05/09: Camel-AWS2-Lambda: Producer operations refactoring - createAlias

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 ffc3fbfb1f17bd2de793a17d716426129cb9b7f4
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 31 11:21:21 2021 +0200

    Camel-AWS2-Lambda: Producer operations refactoring - createAlias
---
 .../component/aws2/lambda/Lambda2Producer.java     | 32 ++++++++--------------
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
index 3005689..3cda5e8 100644
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
+++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
@@ -615,43 +615,35 @@ public class Lambda2Producer extends DefaultProducer {
     }
 
     private void createAlias(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {
+    	CreateAliasRequest request = null;
+    	CreateAliasResponse result;
         if (getConfiguration().isPojoRequest()) {
-            Object payload = exchange.getIn().getMandatoryBody();
-            if (payload instanceof CreateAliasRequest) {
-                CreateAliasResponse result;
-                try {
-                    result = lambdaClient.createAlias((CreateAliasRequest) payload);
-                } catch (AwsServiceException ase) {
-                    LOG.trace("createAlias command returned the error code {}", ase.awsErrorDetails().errorCode());
-                    throw ase;
-                }
-                Message message = getMessageForResponse(exchange);
-                message.setBody(result);
-            }
+            request = exchange.getIn().getMandatoryBody(CreateAliasRequest.class);
         } else {
-            CreateAliasResponse result;
-            try {
-                CreateAliasRequest.Builder request = CreateAliasRequest.builder().functionName(getEndpoint().getFunction());
+                CreateAliasRequest.Builder builder = CreateAliasRequest.builder();
+                builder.functionName(getEndpoint().getFunction());
                 String version = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_VERSION, String.class);
                 String aliasName = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_ALIAS_NAME, String.class);
                 if (ObjectHelper.isEmpty(version) || ObjectHelper.isEmpty(aliasName)) {
                     throw new IllegalArgumentException("Function Version and alias must be specified to create an alias");
                 }
-                request.functionVersion(version);
-                request.name(aliasName);
+                builder.functionVersion(version);
+                builder.name(aliasName);
                 if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(Lambda2Constants.FUNCTION_ALIAS_DESCRIPTION))) {
                     String aliasDescription
                             = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_ALIAS_DESCRIPTION, String.class);
-                    request.description(aliasDescription);
+                    builder.description(aliasDescription);
                 }
-                result = lambdaClient.createAlias(request.build());
+                request = builder.build();
+        }
+        try {
+                result = lambdaClient.createAlias(request);
             } catch (AwsServiceException ase) {
                 LOG.trace("createAlias command returned the error code {}", ase.awsErrorDetails().errorCode());
                 throw ase;
             }
             Message message = getMessageForResponse(exchange);
             message.setBody(result);
-        }
     }
 
     private void deleteAlias(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {

[camel] 06/09: Camel-AWS2-Lambda: Producer operations refactoring - deleteAlias

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 a92cbdf0a10830096ebd08c0fb97da1d16593944
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 31 11:22:45 2021 +0200

    Camel-AWS2-Lambda: Producer operations refactoring - deleteAlias
---
 .../component/aws2/lambda/Lambda2Producer.java     | 28 ++++++++--------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
index 3cda5e8..8d4efa1 100644
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
+++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
@@ -647,36 +647,28 @@ public class Lambda2Producer extends DefaultProducer {
     }
 
     private void deleteAlias(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {
+    	DeleteAliasRequest request = null;
+    	DeleteAliasResponse result;
         if (getConfiguration().isPojoRequest()) {
-            Object payload = exchange.getIn().getMandatoryBody();
-            if (payload instanceof DeleteAliasRequest) {
-                DeleteAliasResponse result;
-                try {
-                    result = lambdaClient.deleteAlias((DeleteAliasRequest) payload);
-                } catch (AwsServiceException ase) {
-                    LOG.trace("deleteAlias command returned the error code {}", ase.awsErrorDetails().errorCode());
-                    throw ase;
-                }
-                Message message = getMessageForResponse(exchange);
-                message.setBody(result);
-            }
+            request = exchange.getIn().getMandatoryBody(DeleteAliasRequest.class);
         } else {
-            DeleteAliasResponse result;
-            try {
-                DeleteAliasRequest.Builder request = DeleteAliasRequest.builder().functionName(getEndpoint().getFunction());
+                DeleteAliasRequest.Builder builder = DeleteAliasRequest.builder();
+                builder.functionName(getEndpoint().getFunction());
                 String aliasName = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_ALIAS_NAME, String.class);
                 if (ObjectHelper.isEmpty(aliasName)) {
                     throw new IllegalArgumentException("Function alias must be specified to delete an alias");
                 }
-                request.name(aliasName);
-                result = lambdaClient.deleteAlias(request.build());
+                builder.name(aliasName);
+                request = builder.build();
+        }
+        try  {
+                result = lambdaClient.deleteAlias(request);
             } catch (AwsServiceException ase) {
                 LOG.trace("deleteAlias command returned the error code {}", ase.awsErrorDetails().errorCode());
                 throw ase;
             }
             Message message = getMessageForResponse(exchange);
             message.setBody(result);
-        }
     }
 
     private void getAlias(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {

[camel] 03/09: Camel-AWS2-Lambda: Producer operations refactoring - listVersions

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 cb993d80b464728858e45bbde3032a74041a7f52
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 31 11:10:13 2021 +0200

    Camel-AWS2-Lambda: Producer operations refactoring - listVersions
---
 .../component/aws2/lambda/Lambda2Producer.java     | 27 ++++++++--------------
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
index 4e57f7e..d545aae 100644
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
+++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
@@ -595,24 +595,16 @@ public class Lambda2Producer extends DefaultProducer {
     }
 
     private void listVersions(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {
-        if (getConfiguration().isPojoRequest()) {
-            Object payload = exchange.getIn().getMandatoryBody();
-            if (payload instanceof ListVersionsByFunctionRequest) {
-                ListVersionsByFunctionResponse result;
-                try {
-                    result = lambdaClient.listVersionsByFunction((ListVersionsByFunctionRequest) payload);
-                } catch (AwsServiceException ase) {
-                    LOG.trace("publishVersion command returned the error code {}", ase.awsErrorDetails().errorCode());
-                    throw ase;
-                }
-                Message message = getMessageForResponse(exchange);
-                message.setBody(result);
-            }
+        ListVersionsByFunctionRequest request = null;
+        ListVersionsByFunctionResponse result;
+    	if (getConfiguration().isPojoRequest()) {
+            request = exchange.getIn().getMandatoryBody(ListVersionsByFunctionRequest.class);
         } else {
-            ListVersionsByFunctionResponse result;
-            try {
-                ListVersionsByFunctionRequest request
-                        = ListVersionsByFunctionRequest.builder().functionName(getEndpoint().getFunction()).build();
+                ListVersionsByFunctionRequest.Builder builder = ListVersionsByFunctionRequest.builder();
+                builder.functionName(getEndpoint().getFunction());
+                request = builder.build();
+        }
+    	try {
                 result = lambdaClient.listVersionsByFunction(request);
             } catch (AwsServiceException ase) {
                 LOG.trace("publishVersion command returned the error code {}", ase.awsErrorDetails().errorCode());
@@ -620,7 +612,6 @@ public class Lambda2Producer extends DefaultProducer {
             }
             Message message = getMessageForResponse(exchange);
             message.setBody(result);
-        }
     }
 
     private void createAlias(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {