NIFI-7622 Use param context name from inside nested versioned PG when importing

This closes #4401.

Signed-off-by: Andy LoPresto <alopresto@apache.org>
This commit is contained in:
Bryan Bende 2020-07-10 14:30:20 -04:00 committed by Andy LoPresto
parent d846a74730
commit 5cb8d24689
No known key found for this signature in database
GPG Key ID: 6EC293152D90B61D
2 changed files with 9 additions and 1 deletions

View File

@ -4211,7 +4211,7 @@ public final class StandardProcessGroup implements ProcessGroup {
return childSnapshot.getParameterContexts();
} catch (final NiFiRegistryException e) {
throw new IllegalArgumentException("The Flow Registry with ID " + registryId + " reports that no Flow exists with Bucket "
+ bucketId + ", Flow " + flowId + ", Version " + flowVersion);
+ bucketId + ", Flow " + flowId + ", Version " + flowVersion, e);
} catch (final IOException ioe) {
throw new IllegalStateException(
"Failed to communicate with Flow Registry when attempting to retrieve a versioned flow");
@ -4273,6 +4273,13 @@ public final class StandardProcessGroup implements ProcessGroup {
// Create a new Parameter Context based on the parameters provided
final VersionedParameterContext versionedParameterContext = versionedParameterContexts.get(proposedParameterContextName);
// Protect against NPE in the event somehow the proposed name is not in the set of contexts
if (versionedParameterContext == null) {
final String paramContextNames = StringUtils.join(versionedParameterContexts.keySet());
throw new IllegalStateException("Proposed parameter context name '" + proposedParameterContextName
+ "' does not exist in set of available parameter contexts [" + paramContextNames + "]");
}
final ParameterContext contextByName = getParameterContextByName(versionedParameterContext.getName());
final ParameterContext selectedParameterContext;
if (contextByName == null) {

View File

@ -258,6 +258,7 @@ public class RestBasedFlowRegistry implements FlowRegistry {
group.setProcessors(contents.getProcessors());
group.setRemoteProcessGroups(contents.getRemoteProcessGroups());
group.setVariables(contents.getVariables());
group.setParameterContextName(contents.getParameterContextName());
group.setFlowFileConcurrency(contents.getFlowFileConcurrency());
group.setFlowFileOutboundPolicy(contents.getFlowFileOutboundPolicy());
coordinates.setLatest(snapshot.isLatest());