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 06:42:40 UTC
[camel] 01/02: Camel-AWS2-Lambda: Producer operations refactoring -
listTags
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 92a713eaae9941cf1b5fb24b2db96293da933358
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 31 08:39:11 2021 +0200
Camel-AWS2-Lambda: Producer operations refactoring - listTags
---
.../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 4784e3e..2d4dbf9 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
@@ -478,37 +478,28 @@ public class Lambda2Producer extends DefaultProducer {
}
private void listTags(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {
+ ListTagsRequest request = null;
+ ListTagsResponse result;
if (getConfiguration().isPojoRequest()) {
- Object payload = exchange.getIn().getMandatoryBody();
- if (payload instanceof ListTagsRequest) {
- ListTagsResponse result;
- try {
- result = lambdaClient.listTags((ListTagsRequest) payload);
- } catch (AwsServiceException ase) {
- LOG.trace("listTags command returned the error code {}", ase.awsErrorDetails().errorCode());
- throw ase;
- }
- Message message = getMessageForResponse(exchange);
- message.setBody(result);
- }
+ request = exchange.getIn().getMandatoryBody(ListTagsRequest.class);
} else {
- ListTagsResponse result;
- try {
- ListTagsRequest.Builder request = ListTagsRequest.builder();
+ ListTagsRequest.Builder builder = ListTagsRequest.builder();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(Lambda2Constants.RESOURCE_ARN))) {
String resource = exchange.getIn().getHeader(Lambda2Constants.RESOURCE_ARN, String.class);
- request.resource(resource);
+ builder.resource(resource);
} else {
throw new IllegalArgumentException("The resource ARN must be specified");
}
- result = lambdaClient.listTags(request.build());
+ request = builder.build();
+ }
+ try {
+ result = lambdaClient.listTags(request);
} catch (AwsServiceException ase) {
LOG.trace("listTags command returned the error code {}", ase.awsErrorDetails().errorCode());
throw ase;
}
Message message = getMessageForResponse(exchange);
message.setBody(result);
- }
}
@SuppressWarnings("unchecked")