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/08 06:49:48 UTC

[camel] 01/03: CAMEL-14850 - Camel-AWS2-*: Improve the verifiers to check if a particular service works on a specified region, SQS

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 83877e35b7a78dd63fa151594454755de3e2eb75
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Apr 8 08:38:35 2020 +0200

    CAMEL-14850 - Camel-AWS2-*: Improve the verifiers to check if a particular service works on a specified region, SQS
---
 .../camel/component/aws2/sqs/Sqs2ComponentVerifierExtension.java     | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/components/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2ComponentVerifierExtension.java b/components/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2ComponentVerifierExtension.java
index 631c8c1..99ec4b9 100644
--- a/components/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2ComponentVerifierExtension.java
+++ b/components/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2ComponentVerifierExtension.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.aws2.sqs;
 
 import java.util.Map;
 
+import org.apache.camel.component.extension.ComponentVerifierExtension.VerificationError;
 import org.apache.camel.component.extension.verifier.DefaultComponentVerifierExtension;
 import org.apache.camel.component.extension.verifier.ResultBuilder;
 import org.apache.camel.component.extension.verifier.ResultErrorBuilder;
@@ -66,6 +67,10 @@ public class Sqs2ComponentVerifierExtension extends DefaultComponentVerifierExte
 
         try {
             Sqs2Configuration configuration = setProperties(new Sqs2Configuration(), parameters);
+            if (!SqsClient.serviceMetadata().regions().contains(Region.of(configuration.getRegion()))) {
+                ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.ILLEGAL_PARAMETER, "The service is not supported in this region");
+                return builder.error(errorBuilder.build()).build();
+            }
             AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey());
             SqsClientBuilder clientBuilder = SqsClient.builder();
             SqsClient client = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)).region(Region.of(configuration.getRegion())).build();