From 833ec4409c20c5f2323b61b87bab7c10557f7041 Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Mon, 26 Sep 2016 10:17:02 -0400 Subject: [PATCH] NIFI-2758: - Updating move verification to account for Controller Service moving out of scope. This closes #1064 Signed-off-by: jpercivall --- .../nifi/groups/StandardProcessGroup.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java index 901c42ee8e..6f0dd84526 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java @@ -39,6 +39,7 @@ import org.apache.nifi.connectable.Port; import org.apache.nifi.connectable.Position; import org.apache.nifi.connectable.Positionable; import org.apache.nifi.controller.ConfigurationContext; +import org.apache.nifi.controller.ControllerService; import org.apache.nifi.controller.FlowController; import org.apache.nifi.controller.ProcessorNode; import org.apache.nifi.controller.ScheduledState; @@ -2470,6 +2471,30 @@ public final class StandardProcessGroup implements ProcessGroup { throw new IllegalStateException("Cannot perform Move Operation because of a naming conflict with another port in the destination Process Group"); } } + + for (final String id : snippet.getProcessors().keySet()) { + final ProcessorNode processorNode = getProcessor(id); + for (final PropertyDescriptor descriptor : processorNode.getProperties().keySet()) { + final Class serviceDefinition = descriptor.getControllerServiceDefinition(); + + // if this descriptor identifies a controller service + if (serviceDefinition != null) { + final String serviceId = processorNode.getProperty(descriptor); + + // if the processor is configured with a service + if (serviceId != null) { + // get all the available services + final Set currentControllerServiceIds = controllerServiceProvider.getControllerServiceIdentifiers(serviceDefinition, getIdentifier()); + final Set proposedControllerServiceIds = controllerServiceProvider.getControllerServiceIdentifiers(serviceDefinition, newProcessGroup.getIdentifier()); + + // ensure the configured service is an allowed service if it's still a valid service + if (currentControllerServiceIds.contains(serviceId) && !proposedControllerServiceIds.contains(serviceId)) { + throw new IllegalStateException("Cannot perform Move Operation because a Processor references a service that is not available in the destination Process Group"); + } + } + } + } + } } finally { readLock.unlock(); }