This is an automated email from the ASF dual-hosted git repository.

joewitt pushed a commit to branch support/nifi-1.19
in repository https://gitbox.apache.org/repos/asf/nifi.git

commit 2834aab432ed1c43627a54e8445fba3ab00de366
Author: Peter Turcsanyi <turcsa...@apache.org>
AuthorDate: Mon Nov 21 17:27:31 2022 +0100

    NIFI-10850: Fixed Query Parameters property in InvokeAWSGatewayApi should 
support FlowFile attributes in EL
    
    Signed-off-by: Pierre Villard <pierre.villard...@gmail.com>
    
    This closes #6692.
---
 .../nifi/processors/aws/wag/AbstractAWSGatewayApiProcessor.java  | 9 +++++----
 .../nifi/processors/aws/wag/TestInvokeAmazonGatewayApiMock.java  | 5 +++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git 
a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/wag/AbstractAWSGatewayApiProcessor.java
 
b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/wag/AbstractAWSGatewayApiProcessor.java
index 7cde727fa0..66068a863e 100644
--- 
a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/wag/AbstractAWSGatewayApiProcessor.java
+++ 
b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/wag/AbstractAWSGatewayApiProcessor.java
@@ -402,7 +402,7 @@ public abstract class AbstractAWSGatewayApiProcessor extends
                 
context.getProperty(PROP_METHOD).evaluateAttributeExpressions(requestFlowFile)
                         .getValue()).toUpperCase();
         final HttpMethodName methodName = HttpMethodName.fromValue(method);
-        return configureRequest(context, session, 
resourcePath,requestFlowFile, methodName, attributes);
+        return configureRequest(context, session, resourcePath, 
requestFlowFile, methodName, attributes);
     }
 
     protected GenericApiGatewayRequest configureRequest(final ProcessContext 
context,
@@ -414,7 +414,7 @@ public abstract class AbstractAWSGatewayApiProcessor extends
 
         GenericApiGatewayRequestBuilder builder = new 
GenericApiGatewayRequestBuilder()
             .withResourcePath(resourcePath);
-        final Map<String, List<String>> parameters = getParameters(context);
+        final Map<String, List<String>> parameters = getParameters(context, 
attributes);
         builder = builder.withParameters(parameters);
 
         InputStream requestBody;
@@ -522,15 +522,16 @@ public abstract class AbstractAWSGatewayApiProcessor 
extends
      * Returns a map of Query Parameter Name to Values
      *
      * @param context ProcessContext
+     * @param flowFileAttributes map of FlowFile attributes used for EL 
evaluation
      * @return Map of names and values
      */
-    protected Map<String, List<String>> getParameters(final ProcessContext 
context) {
+    protected Map<String, List<String>> getParameters(final ProcessContext 
context, Map<String, String> flowFileAttributes) {
 
         if (!context.getProperty(PROP_QUERY_PARAMS).isSet()) {
             return new HashMap<>();
         }
         final String queryString = context.getProperty(PROP_QUERY_PARAMS)
-                                          
.evaluateAttributeExpressions().getValue();
+                                          
.evaluateAttributeExpressions(flowFileAttributes).getValue();
         final List<NameValuePair> params = URLEncodedUtils
             .parse(queryString, Charsets.toCharset("UTF-8"));
 
diff --git 
a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/wag/TestInvokeAmazonGatewayApiMock.java
 
b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/wag/TestInvokeAmazonGatewayApiMock.java
index 5b7927dd31..b3a4a970e8 100644
--- 
a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/wag/TestInvokeAmazonGatewayApiMock.java
+++ 
b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/wag/TestInvokeAmazonGatewayApiMock.java
@@ -178,7 +178,7 @@ public class TestInvokeAmazonGatewayApiMock {
 
         // add dynamic property
         runner.setProperty("dynamicHeader", "yes!");
-        runner.setProperty(InvokeAWSGatewayApi.PROP_QUERY_PARAMS, 
"apples=oranges&dogs=cats");
+        runner.setProperty(InvokeAWSGatewayApi.PROP_QUERY_PARAMS, 
"apples=oranges&dogs=cats&filename=${filename}");
 
         // set the regex
         runner.setProperty(InvokeAWSGatewayApi.PROP_ATTRIBUTES_TO_SEND, "F.*");
@@ -186,6 +186,7 @@ public class TestInvokeAmazonGatewayApiMock {
         final Map<String, String> attributes = new HashMap<>();
         attributes.put(CoreAttributes.MIME_TYPE.key(), 
"application/plain-text");
         attributes.put("Foo", "Bar");
+        attributes.put("filename", "testfile");
         runner.enqueue("Hello".getBytes(StandardCharsets.UTF_8), attributes);
         // execute
         runner.assertValid();
@@ -197,7 +198,7 @@ public class TestInvokeAmazonGatewayApiMock {
                                 && 
argument.getFirstHeader("Authorization").getValue().startsWith("AWS4")
                                 && 
argument.getFirstHeader("dynamicHeader").getValue().equals("yes!")
                                 && 
argument.getFirstHeader("Foo").getValue().equals("Bar")
-                                && 
argument.getURI().toString().equals("https://foobar.execute-api.us-east-1.amazonaws.com/TEST?dogs=cats&apples=oranges";)),
+                                && 
argument.getURI().toString().equals("https://foobar.execute-api.us-east-1.amazonaws.com/TEST?filename=testfile&dogs=cats&apples=oranges";)),
                         any(HttpContext.class));
         // check
         runner.assertTransferCount(InvokeAWSGatewayApi.REL_SUCCESS_REQ, 1);

Reply via email to