mirror of https://github.com/apache/nifi.git
NIFI-10850: Fixed Query Parameters property in InvokeAWSGatewayApi should support FlowFile attributes in EL
Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com> This closes #6692.
This commit is contained in:
parent
9cc9692c98
commit
40b46b4f5d
|
@ -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"));
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue