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/14 09:35:50 UTC
[camel] 05/10: CAMEL-14868 - Camel-AWS2-*: Where possible,
give the possiblity to the end user to pass an AWS Request pojo as
body, aws2-kms describe key
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 b28d4da30f13b242e1381f101b32db550357b535
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Apr 14 11:12:37 2020 +0200
CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms describe key
---
.../apache/camel/component/aws2/kms/KMS2Producer.java | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
index 0d04235..8bf4631 100644
--- a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
+++ b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
@@ -209,7 +209,7 @@ public class KMS2Producer extends DefaultProducer {
}
}
- private void scheduleKeyDeletion(KmsClient kmsClient, Exchange exchange) {
+ private void scheduleKeyDeletion(KmsClient kmsClient, Exchange exchange) throws InvalidPayloadException {
if (getConfiguration().isPojoRequest()) {
Object payload = exchange.getIn().getMandatoryBody();
if (payload instanceof ScheduleKeyDeletionRequest) {
@@ -247,7 +247,21 @@ public class KMS2Producer extends DefaultProducer {
}
}
- private void describeKey(KmsClient kmsClient, Exchange exchange) {
+ private void describeKey(KmsClient kmsClient, Exchange exchange) throws InvalidPayloadException {
+ if (getConfiguration().isPojoRequest()) {
+ Object payload = exchange.getIn().getMandatoryBody();
+ if (payload instanceof DescribeKeyRequest) {
+ DescribeKeyResponse result;
+ try {
+ result = kmsClient.describeKey((DescribeKeyRequest) payload);
+ } catch (AwsServiceException ase) {
+ LOG.trace("Describe Key command returned the error code {}", ase.awsErrorDetails().errorCode());
+ throw ase;
+ }
+ Message message = getMessageForResponse(exchange);
+ message.setBody(result);
+ }
+ } else {
DescribeKeyRequest.Builder builder = DescribeKeyRequest.builder();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.KEY_ID))) {
String keyId = exchange.getIn().getHeader(KMS2Constants.KEY_ID, String.class);
@@ -264,6 +278,7 @@ public class KMS2Producer extends DefaultProducer {
}
Message message = getMessageForResponse(exchange);
message.setBody(result);
+ }
}
private void enableKey(KmsClient kmsClient, Exchange exchange) {