NIFI-15829 - Support parameter value references to parameters from inherited parameter contexts#11130
Conversation
…s from inherited parameter contexts
| * @param value the parameter value to check | ||
| * @return the referenced parameter name if the value is a one-to-one reference, or null otherwise | ||
| */ | ||
| static String extractOneToOneParameterReference(final String value) { |
There was a problem hiding this comment.
I'm not sure that this util method should really be on the interface. It would make sense to pull this out into a separate util class.
| if (value == null || value.length() < 4) { | ||
| return null; | ||
| } | ||
| if (value.startsWith("#{") && value.endsWith("}") && value.indexOf('}') == value.length() - 1) { |
There was a problem hiding this comment.
This is a bit overly simplistic. It does not account for things like quoted parameter names. So it will work with #{MyParam} and properly catches issues like #{a}b}} But it misses cases like #{'My Parameter'}
We should instead probably make use of ExpressionLanguageAgnosticParameterParser, and do something along the lines of:
final ParameterParser parser = new ExpressionLanguageAgnosticParameterParser();
final ParameterTokenList tokenList = parser.parseTokens(value);
final List<ParameterToken> tokens = tokenList.toList();
if (tokens.size() != 1) {
logger.warn("Invalid Parameter Reference: " + value);
}
final ParameterToken firstToken = tokens.getFirst();
if (!firstToken.isParameterReference()) {
logger.warn("Invalid Parameter Reference: " + value);
}
return tokenList.toReferenceList().getFirst().getParameterName();
There was a problem hiding this comment.
Yeah, fair, I went for the easiest approach but you're absolutely right, especially with provided parameters, we may have names where simple quoting will be cleaner.
markap14
left a comment
There was a problem hiding this comment.
Thanks @pvillard31 I think the approach makes sense. I did flag a couple of concerns about how we're handling the parsing specifically but otherwise I think this is a reasonable approach. It would probably also be good to go ahead and update the User Guide as well.
|
Thanks @markap14 - I pushed a commit to address your comments |
markap14
left a comment
There was a problem hiding this comment.
Thanks @pvillard31 changes look good to me. +1 will merge on successful Github Actions completions.
Summary
NIFI-15829 - Support parameter value references to parameters from inherited parameter contexts
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000VerifiedstatusPull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
./mvnw clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation