Lehel44 commented on code in PR #7051:
URL: https://github.com/apache/nifi/pull/7051#discussion_r1142672636
##########
nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/s3/AbstractS3Processor.java:
##########
@@ -198,6 +218,88 @@ protected AmazonS3Client createClient(final ProcessContext
context, final AWSCre
return s3;
}
+ protected Region resolveRegion(final ProcessContext context, final
Map<String, String> attributes) {
+ String regionValue = context.getProperty(S3_CUSTOM_REGION).getValue();
+
+ if (ATTRIBUTE_DRIVEN_REGION.getValue().equals(regionValue)) {
+ regionValue = attributes.get(S3_REGION_ATTRIBUTE);
+ }
+
+ return parseRegionValue(regionValue);
+ }
+
+ private Region parseRegionValue(String regionValue) {
+ if (regionValue == null) {
+ throw new ProcessException(format("[%s] was selected as region
source but [%s] attribute does not exist", ATTRIBUTE_DRIVEN_REGION,
S3_REGION_ATTRIBUTE));
+ }
+
+ try {
+ return Region.getRegion(Regions.fromName(regionValue));
+ } catch (Exception e) {
+ throw new ProcessException(format("The [%s] attribute contains an
invalid region value [%s]", S3_REGION_ATTRIBUTE, regionValue), e);
+ }
+ }
+
+ protected void setClientBasedOnRegionAttribute(final ProcessContext
context, final Map<String, String> attributes) {
Review Comment:
I recommend renaming this method to setClientAndRegion.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]