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:10 UTC
[camel] 03/09: Camel-AWS2-Lambda: Producer operations refactoring -
listVersions
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 {