Repository: nifi Updated Branches: refs/heads/master b213ed95e -> 8412d2662
http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestStandardProcessScheduler.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestStandardProcessScheduler.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestStandardProcessScheduler.java index 7141ee3..3c3b5fd 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestStandardProcessScheduler.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestStandardProcessScheduler.java @@ -61,6 +61,8 @@ import org.apache.nifi.processor.ProcessSession; import org.apache.nifi.processor.Processor; import org.apache.nifi.processor.StandardValidationContextFactory; import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.registry.VariableRegistry; +import org.apache.nifi.registry.VariableRegistryUtils; import org.apache.nifi.reporting.AbstractReportingTask; import org.apache.nifi.reporting.InitializationException; import org.apache.nifi.reporting.ReportingContext; @@ -76,6 +78,7 @@ public class TestStandardProcessScheduler { private ReportingTaskNode taskNode = null; private TestReportingTask reportingTask = null; private final StateManagerProvider stateMgrProvider = Mockito.mock(StateManagerProvider.class); + private VariableRegistry variableRegistry = VariableRegistryUtils.createSystemVariableRegistry(); private FlowController controller; private ProcessGroup rootGroup; @@ -83,7 +86,7 @@ public class TestStandardProcessScheduler { public void setup() throws InitializationException { System.setProperty("nifi.properties.file.path", "src/test/resources/nifi.properties"); this.refreshNiFiProperties(); - scheduler = new StandardProcessScheduler(Mockito.mock(ControllerServiceProvider.class), null, stateMgrProvider); + scheduler = new StandardProcessScheduler(Mockito.mock(ControllerServiceProvider.class), null, stateMgrProvider,variableRegistry); scheduler.setSchedulingAgent(SchedulingStrategy.TIMER_DRIVEN, Mockito.mock(SchedulingAgent.class)); reportingTask = new TestReportingTask(); @@ -91,8 +94,8 @@ public class TestStandardProcessScheduler { Mockito.mock(ComponentLog.class), null); reportingTask.initialize(config); - final ValidationContextFactory validationContextFactory = new StandardValidationContextFactory(null); - taskNode = new StandardReportingTaskNode(reportingTask, UUID.randomUUID().toString(), null, scheduler, validationContextFactory); + final ValidationContextFactory validationContextFactory = new StandardValidationContextFactory(null, variableRegistry); + taskNode = new StandardReportingTaskNode(reportingTask, UUID.randomUUID().toString(), null, scheduler, validationContextFactory, variableRegistry); controller = Mockito.mock(FlowController.class); rootGroup = new MockProcessGroup(); @@ -127,12 +130,12 @@ public class TestStandardProcessScheduler { public void testDisableControllerServiceWithProcessorTryingToStartUsingIt() throws InterruptedException { final Processor proc = new ServiceReferencingProcessor(); - final StandardControllerServiceProvider serviceProvider = new StandardControllerServiceProvider(controller, scheduler, null, Mockito.mock(StateManagerProvider.class)); + final StandardControllerServiceProvider serviceProvider = new StandardControllerServiceProvider(controller, scheduler, null, Mockito.mock(StateManagerProvider.class),variableRegistry); final ControllerServiceNode service = serviceProvider.createControllerService(NoStartServiceImpl.class.getName(), "service", true); rootGroup.addControllerService(service); final ProcessorNode procNode = new StandardProcessorNode(proc, UUID.randomUUID().toString(), - new StandardValidationContextFactory(serviceProvider), scheduler, serviceProvider); + new StandardValidationContextFactory(serviceProvider, variableRegistry), scheduler, serviceProvider); rootGroup.addProcessor(procNode); procNode.setProperty(ServiceReferencingProcessor.SERVICE_DESC.getName(), service.getIdentifier()); @@ -211,7 +214,7 @@ public class TestStandardProcessScheduler { @Test public void validateServiceEnablementLogicHappensOnlyOnce() throws Exception { final ProcessScheduler scheduler = createScheduler(); - final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateMgrProvider); + final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateMgrProvider,variableRegistry); final ControllerServiceNode serviceNode = provider.createControllerService(SimpleTestService.class.getName(), "1", false); assertFalse(serviceNode.isActive()); @@ -250,7 +253,7 @@ public class TestStandardProcessScheduler { @Test public void validateDisabledServiceCantBeDisabled() throws Exception { final ProcessScheduler scheduler = createScheduler(); - final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateMgrProvider); + final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateMgrProvider, variableRegistry); final ControllerServiceNode serviceNode = provider.createControllerService(SimpleTestService.class.getName(), "1", false); final SimpleTestService ts = (SimpleTestService) serviceNode.getControllerServiceImplementation(); @@ -288,7 +291,7 @@ public class TestStandardProcessScheduler { @Test public void validateEnabledServiceCanOnlyBeDisabledOnce() throws Exception { final ProcessScheduler scheduler = createScheduler(); - final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateMgrProvider); + final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateMgrProvider,variableRegistry); final ControllerServiceNode serviceNode = provider.createControllerService(SimpleTestService.class.getName(), "1", false); final SimpleTestService ts = (SimpleTestService) serviceNode.getControllerServiceImplementation(); @@ -322,7 +325,7 @@ public class TestStandardProcessScheduler { @Test public void validateDisablingOfTheFailedService() throws Exception { final ProcessScheduler scheduler = createScheduler(); - final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateMgrProvider); + final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateMgrProvider, variableRegistry); final ControllerServiceNode serviceNode = provider.createControllerService(FailingService.class.getName(), "1", false); scheduler.enableControllerService(serviceNode); @@ -353,7 +356,7 @@ public class TestStandardProcessScheduler { @Test public void validateEnabledDisableMultiThread() throws Exception { final ProcessScheduler scheduler = createScheduler(); - final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateMgrProvider); + final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateMgrProvider, variableRegistry); final ExecutorService executor = Executors.newCachedThreadPool(); for (int i = 0; i < 200; i++) { final ControllerServiceNode serviceNode = provider @@ -396,7 +399,7 @@ public class TestStandardProcessScheduler { @Test public void validateNeverEnablingServiceCanStillBeDisabled() throws Exception { final ProcessScheduler scheduler = createScheduler(); - final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateMgrProvider); + final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateMgrProvider,variableRegistry); final ControllerServiceNode serviceNode = provider.createControllerService(LongEnablingService.class.getName(), "1", false); final LongEnablingService ts = (LongEnablingService) serviceNode.getControllerServiceImplementation(); @@ -421,7 +424,7 @@ public class TestStandardProcessScheduler { @Test public void validateLongEnablingServiceCanStillBeDisabled() throws Exception { final ProcessScheduler scheduler = createScheduler(); - final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateMgrProvider); + final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateMgrProvider, variableRegistry); final ControllerServiceNode serviceNode = provider.createControllerService(LongEnablingService.class.getName(), "1", false); final LongEnablingService ts = (LongEnablingService) serviceNode.getControllerServiceImplementation(); @@ -518,6 +521,6 @@ public class TestStandardProcessScheduler { } private ProcessScheduler createScheduler() { - return new StandardProcessScheduler(null, null, stateMgrProvider); + return new StandardProcessScheduler(null, null, stateMgrProvider, variableRegistry); } } http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/StandardControllerServiceProviderTest.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/StandardControllerServiceProviderTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/StandardControllerServiceProviderTest.java index aca13c2..9b551ce 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/StandardControllerServiceProviderTest.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/StandardControllerServiceProviderTest.java @@ -22,6 +22,8 @@ import org.apache.nifi.controller.ControllerService; import org.apache.nifi.controller.StandardFlowServiceTest; import org.apache.nifi.nar.ExtensionManager; import org.apache.nifi.nar.NarClassLoaders; +import org.apache.nifi.registry.VariableRegistry; +import org.apache.nifi.registry.VariableRegistryUtils; import org.apache.nifi.reporting.InitializationException; import org.apache.nifi.util.NiFiProperties; import org.junit.Before; @@ -33,6 +35,7 @@ public class StandardControllerServiceProviderTest { private ControllerService proxied; private ControllerService implementation; + private static VariableRegistry variableRegistry; @BeforeClass public static void setupSuite() throws Exception { @@ -40,6 +43,7 @@ public class StandardControllerServiceProviderTest { NiFiProperties properties = NiFiProperties.getInstance(); NarClassLoaders.getInstance().init(properties.getFrameworkWorkingDirectory(), properties.getExtensionsWorkingDirectory()); ExtensionManager.discoverExtensions(NarClassLoaders.getInstance().getExtensionClassLoaders()); + variableRegistry = VariableRegistryUtils.createCustomVariableRegistry(properties.getVariableRegistryPropertiesPaths()); } @Before @@ -67,7 +71,7 @@ public class StandardControllerServiceProviderTest { @Override public void onComponentRemoved(String componentId) { } - }); + }, variableRegistry); ControllerServiceNode node = provider.createControllerService(clazz, id, true); proxied = node.getProxiedControllerService(); implementation = node.getControllerServiceImplementation(); http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/TestStandardControllerServiceProvider.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/TestStandardControllerServiceProvider.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/TestStandardControllerServiceProvider.java index 65a6380..f3ef85d 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/TestStandardControllerServiceProvider.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/service/TestStandardControllerServiceProvider.java @@ -1,3 +1,4 @@ + /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -45,6 +46,8 @@ import org.apache.nifi.controller.service.mock.ServiceC; import org.apache.nifi.groups.ProcessGroup; import org.apache.nifi.groups.StandardProcessGroup; import org.apache.nifi.processor.StandardValidationContextFactory; +import org.apache.nifi.registry.VariableRegistry; +import org.apache.nifi.registry.VariableRegistryUtils; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -74,13 +77,15 @@ public class TestStandardControllerServiceProvider { } }; + private static VariableRegistry variableRegistry = VariableRegistryUtils.createSystemVariableRegistry(); + @BeforeClass public static void setNiFiProps() { System.setProperty("nifi.properties.file.path", "src/test/resources/nifi.properties"); } private StandardProcessScheduler createScheduler() { - return new StandardProcessScheduler(null, null, stateManagerProvider); + return new StandardProcessScheduler(null, null, stateManagerProvider,variableRegistry); } @Test @@ -90,7 +95,7 @@ public class TestStandardControllerServiceProvider { Mockito.when(controller.getGroup(Mockito.anyString())).thenReturn(procGroup); final ProcessScheduler scheduler = createScheduler(); - final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateManagerProvider); + final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateManagerProvider,variableRegistry); final ControllerServiceNode serviceNode = provider.createControllerService(ServiceB.class.getName(), "B", false); provider.enableControllerService(serviceNode); @@ -104,7 +109,7 @@ public class TestStandardControllerServiceProvider { Mockito.when(controller.getGroup(Mockito.anyString())).thenReturn(group); final ProcessScheduler scheduler = createScheduler(); - final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateManagerProvider); + final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateManagerProvider,variableRegistry); final ControllerServiceNode serviceNodeB = provider.createControllerService(ServiceB.class.getName(), "B", false); final ControllerServiceNode serviceNodeA = provider.createControllerService(ServiceA.class.getName(), "A", false); @@ -163,7 +168,7 @@ public class TestStandardControllerServiceProvider { final FlowController controller = Mockito.mock(FlowController.class); Mockito.when(controller.getGroup(Mockito.anyString())).thenReturn(procGroup); - final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateManagerProvider); + final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateManagerProvider,variableRegistry); // build a graph of controller services with dependencies as such: // @@ -215,7 +220,7 @@ public class TestStandardControllerServiceProvider { final FlowController controller = Mockito.mock(FlowController.class); Mockito.when(controller.getGroup(Mockito.anyString())).thenReturn(procGroup); - final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, null, null, stateManagerProvider); + final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, null, null, stateManagerProvider,variableRegistry); final ControllerServiceNode serviceNode1 = provider.createControllerService(ServiceA.class.getName(), "1", false); final ControllerServiceNode serviceNode2 = provider.createControllerService(ServiceB.class.getName(), "2", false); @@ -359,9 +364,9 @@ public class TestStandardControllerServiceProvider { private ProcessorNode createProcessor(final StandardProcessScheduler scheduler, final ControllerServiceProvider serviceProvider) { final ProcessorNode procNode = new StandardProcessorNode(new DummyProcessor(), UUID.randomUUID().toString(), - new StandardValidationContextFactory(serviceProvider), scheduler, serviceProvider); + new StandardValidationContextFactory(serviceProvider, null), scheduler, serviceProvider); - final ProcessGroup group = new StandardProcessGroup(UUID.randomUUID().toString(), serviceProvider, scheduler, null, null, null); + final ProcessGroup group = new StandardProcessGroup(UUID.randomUUID().toString(), serviceProvider, scheduler, null, null, null, variableRegistry); group.addProcessor(procNode); procNode.setProcessGroup(group); @@ -375,7 +380,7 @@ public class TestStandardControllerServiceProvider { Mockito.when(controller.getGroup(Mockito.anyString())).thenReturn(procGroup); final StandardProcessScheduler scheduler = createScheduler(); - final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, null, null, stateManagerProvider); + final StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, null, null, stateManagerProvider,variableRegistry); final ControllerServiceNode serviceNode = provider.createControllerService(ServiceA.class.getName(), "1", false); final ProcessorNode procNode = createProcessor(scheduler, provider); @@ -394,7 +399,7 @@ public class TestStandardControllerServiceProvider { public void validateEnableServices() { StandardProcessScheduler scheduler = createScheduler(); FlowController controller = Mockito.mock(FlowController.class); - StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateManagerProvider); + StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateManagerProvider,variableRegistry); ProcessGroup procGroup = new MockProcessGroup(); Mockito.when(controller.getGroup(Mockito.anyString())).thenReturn(procGroup); @@ -439,7 +444,7 @@ public class TestStandardControllerServiceProvider { StandardProcessScheduler scheduler = createScheduler(); FlowController controller = Mockito.mock(FlowController.class); StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, - stateManagerProvider); + stateManagerProvider, variableRegistry); ProcessGroup procGroup = new MockProcessGroup(); Mockito.when(controller.getGroup(Mockito.anyString())).thenReturn(procGroup); @@ -475,7 +480,7 @@ public class TestStandardControllerServiceProvider { public void validateEnableServicesWithDisabledMissingService() { StandardProcessScheduler scheduler = createScheduler(); FlowController controller = Mockito.mock(FlowController.class); - StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateManagerProvider); + StandardControllerServiceProvider provider = new StandardControllerServiceProvider(controller, scheduler, null, stateManagerProvider,variableRegistry); ProcessGroup procGroup = new MockProcessGroup(); Mockito.when(controller.getGroup(Mockito.anyString())).thenReturn(procGroup); http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/providers/local/TestWriteAheadLocalStateProvider.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/providers/local/TestWriteAheadLocalStateProvider.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/providers/local/TestWriteAheadLocalStateProvider.java index 9f7c4c9..19a8405 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/providers/local/TestWriteAheadLocalStateProvider.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/providers/local/TestWriteAheadLocalStateProvider.java @@ -32,6 +32,8 @@ import org.apache.nifi.components.state.StateProvider; import org.apache.nifi.components.state.StateProviderInitializationContext; import org.apache.nifi.controller.state.StateMapUpdate; import org.apache.nifi.controller.state.providers.AbstractTestStateProvider; +import org.apache.nifi.registry.VariableRegistry; +import org.apache.nifi.registry.VariableRegistryUtils; import org.junit.After; import org.junit.Before; import org.wali.WriteAheadRepository; @@ -43,9 +45,9 @@ public class TestWriteAheadLocalStateProvider extends AbstractTestStateProvider @Before public void setup() throws IOException { provider = new WriteAheadLocalStateProvider(); - + final VariableRegistry variableRegistry = VariableRegistryUtils.createSystemVariableRegistry(); final Map<PropertyDescriptor, PropertyValue> properties = new HashMap<>(); - properties.put(WriteAheadLocalStateProvider.PATH, new StandardPropertyValue("target/local-state-provider/" + UUID.randomUUID().toString(), null)); + properties.put(WriteAheadLocalStateProvider.PATH, new StandardPropertyValue("target/local-state-provider/" + UUID.randomUUID().toString(), null, variableRegistry)); provider.initialize(new StateProviderInitializationContext() { @Override @@ -62,7 +64,7 @@ public class TestWriteAheadLocalStateProvider extends AbstractTestStateProvider public PropertyValue getProperty(final PropertyDescriptor property) { final PropertyValue prop = properties.get(property); if (prop == null) { - return new StandardPropertyValue(null, null); + return new StandardPropertyValue(null, null, variableRegistry); } return prop; } http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/providers/zookeeper/TestZooKeeperStateProvider.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/providers/zookeeper/TestZooKeeperStateProvider.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/providers/zookeeper/TestZooKeeperStateProvider.java index 8ce97fa..c0ef068 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/providers/zookeeper/TestZooKeeperStateProvider.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/state/providers/zookeeper/TestZooKeeperStateProvider.java @@ -31,6 +31,8 @@ import org.apache.nifi.components.state.StateProvider; import org.apache.nifi.components.state.StateProviderInitializationContext; import org.apache.nifi.components.state.exception.StateTooLargeException; import org.apache.nifi.controller.state.providers.AbstractTestStateProvider; +import org.apache.nifi.registry.VariableRegistry; +import org.apache.nifi.registry.VariableRegistryUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -40,6 +42,7 @@ public class TestZooKeeperStateProvider extends AbstractTestStateProvider { private StateProvider provider; private TestingServer zkServer; + private VariableRegistry variableRegistry; private static final Map<PropertyDescriptor, String> defaultProperties = new HashMap<>(); @@ -58,6 +61,7 @@ public class TestZooKeeperStateProvider extends AbstractTestStateProvider { final Map<PropertyDescriptor, String> properties = new HashMap<>(defaultProperties); properties.put(ZooKeeperStateProvider.CONNECTION_STRING, zkServer.getConnectString()); this.provider = createProvider(properties); + variableRegistry = VariableRegistryUtils.createSystemVariableRegistry(); } private void initializeProvider(final ZooKeeperStateProvider provider, final Map<PropertyDescriptor, String> properties) throws IOException { @@ -71,7 +75,7 @@ public class TestZooKeeperStateProvider extends AbstractTestStateProvider { public Map<PropertyDescriptor, PropertyValue> getProperties() { final Map<PropertyDescriptor, PropertyValue> propValueMap = new HashMap<>(); for (final Map.Entry<PropertyDescriptor, String> entry : properties.entrySet()) { - propValueMap.put(entry.getKey(), new StandardPropertyValue(entry.getValue(), null)); + propValueMap.put(entry.getKey(), new StandardPropertyValue(entry.getValue(), null, variableRegistry)); } return propValueMap; } @@ -79,7 +83,7 @@ public class TestZooKeeperStateProvider extends AbstractTestStateProvider { @Override public PropertyValue getProperty(final PropertyDescriptor property) { final String prop = properties.get(property); - return new StandardPropertyValue(prop, null); + return new StandardPropertyValue(prop, null, variableRegistry); } @Override http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/processor/TestStandardPropertyValue.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/processor/TestStandardPropertyValue.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/processor/TestStandardPropertyValue.java index 4488f68..33327eb 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/processor/TestStandardPropertyValue.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/processor/TestStandardPropertyValue.java @@ -29,15 +29,19 @@ import org.apache.nifi.controller.ControllerService; import org.apache.nifi.controller.ControllerServiceLookup; import org.apache.nifi.controller.repository.StandardFlowFileRecord; import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.registry.VariableRegistry; +import org.apache.nifi.registry.VariableRegistryUtils; import org.junit.Test; + public class TestStandardPropertyValue { private final ControllerServiceLookup lookup = new TestControllerServiceLookup(); + private final VariableRegistry variableRegistry = VariableRegistryUtils.createSystemVariableRegistry(); @Test public void testSubstituteAttributesWithOneMatchingArg() { - final PropertyValue value = new StandardPropertyValue("Hello, ${audience}!", lookup); + final PropertyValue value = new StandardPropertyValue("Hello, ${audience}!", lookup, variableRegistry); final Map<String, String> attributes = new HashMap<>(); attributes.put("audience", "World"); assertEquals("Hello, World!", value.evaluateAttributeExpressions(createFlowFile(attributes)).getValue()); @@ -45,7 +49,7 @@ public class TestStandardPropertyValue { @Test public void testMissingEndBraceEvaluatesToStringLiteral() { - final PropertyValue value = new StandardPropertyValue("Hello, ${audience!", lookup); + final PropertyValue value = new StandardPropertyValue("Hello, ${audience!", lookup, variableRegistry); final Map<String, String> attributes = new HashMap<>(); attributes.put("audience", "World"); assertEquals("Hello, ${audience!", value.evaluateAttributeExpressions(createFlowFile(attributes)).getValue()); @@ -53,7 +57,7 @@ public class TestStandardPropertyValue { @Test public void testEscaped() { - final PropertyValue value = new StandardPropertyValue("Hello, $${audience}!", lookup); + final PropertyValue value = new StandardPropertyValue("Hello, $${audience}!", lookup, variableRegistry); final Map<String, String> attributes = new HashMap<>(); attributes.put("audience", "World"); assertEquals("Hello, ${audience}!", value.evaluateAttributeExpressions(createFlowFile(attributes)).getValue()); @@ -61,7 +65,7 @@ public class TestStandardPropertyValue { @Test public void testSubstituteAttributesWithMultipleMatchingArgs() { - final PropertyValue value = new StandardPropertyValue("Hello, ${audience}${comma}${question}!", lookup); + final PropertyValue value = new StandardPropertyValue("Hello, ${audience}${comma}${question}!", lookup, variableRegistry); final Map<String, String> attributes = new HashMap<>(); attributes.put("audience", "World"); attributes.put("comma", ","); @@ -71,14 +75,14 @@ public class TestStandardPropertyValue { @Test public void testSubstituteAttributesWithNoMatch() { - final PropertyValue value = new StandardPropertyValue("Hello, ${audience}${comma}${question:replaceNull('')}!", lookup); + final PropertyValue value = new StandardPropertyValue("Hello, ${audience}${comma}${question:replaceNull('')}!", lookup, variableRegistry); final Map<String, String> attributes = new HashMap<>(); assertEquals("Hello, !", value.evaluateAttributeExpressions(createFlowFile(attributes)).getValue()); } @Test public void testSubstituteAttributesRecursively() { - final PropertyValue value = new StandardPropertyValue("Hello, ${'${a}${b}'}!", lookup); + final PropertyValue value = new StandardPropertyValue("Hello, ${'${a}${b}'}!", lookup, variableRegistry); final Map<String, String> attributes = new HashMap<>(); attributes.put("a", "b"); attributes.put("b", "World"); @@ -88,7 +92,7 @@ public class TestStandardPropertyValue { @Test public void testGetValueAsIntegerAfterSubstitute() { - final PropertyValue value = new StandardPropertyValue("1${value}", lookup); + final PropertyValue value = new StandardPropertyValue("1${value}", lookup, variableRegistry); final Map<String, String> attributes = new HashMap<>(); attributes.put("value", "39"); assertEquals(139, value.evaluateAttributeExpressions(createFlowFile(attributes)).asInteger().intValue()); @@ -96,7 +100,7 @@ public class TestStandardPropertyValue { @Test(expected = NumberFormatException.class) public void testGetValueAsIntegerAfterSubstitutingWithNonInteger() { - final PropertyValue value = new StandardPropertyValue("1${value}", lookup); + final PropertyValue value = new StandardPropertyValue("1${value}", lookup, variableRegistry); final Map<String, String> attributes = new HashMap<>(); attributes.put("value", "Yes"); final PropertyValue substituted = value.evaluateAttributeExpressions(createFlowFile(attributes)); @@ -105,7 +109,7 @@ public class TestStandardPropertyValue { @Test public void testFileSize() { - final PropertyValue value = new StandardPropertyValue("${fileSize}", lookup); + final PropertyValue value = new StandardPropertyValue("${fileSize}", lookup, variableRegistry); final FlowFile flowFile = new StandardFlowFileRecord.Builder().size(1024 * 1024L).build(); final long val = value.evaluateAttributeExpressions(flowFile).asLong().longValue(); assertEquals(1024 * 1024L, val); @@ -115,7 +119,7 @@ public class TestStandardPropertyValue { public void testFlowFileEntryYear() { final Calendar now = Calendar.getInstance(); final int year = now.get(Calendar.YEAR); - final PropertyValue value = new StandardPropertyValue("${entryDate:toNumber():toDate():format('yyyy')}", lookup); + final PropertyValue value = new StandardPropertyValue("${entryDate:toNumber():toDate():format('yyyy')}", lookup, variableRegistry); final FlowFile flowFile = new StandardFlowFileRecord.Builder().entryDate(now.getTimeInMillis()).build(); final int val = value.evaluateAttributeExpressions(flowFile).asInteger().intValue(); assertEquals(year, val); @@ -125,7 +129,7 @@ public class TestStandardPropertyValue { public void testSystemProperty() { System.setProperty("Prop1", "Foo"); System.setProperty("Prop2", "Bar"); - final PropertyValue value = new StandardPropertyValue("${Prop1}${Prop2}${abc}", lookup); + final PropertyValue value = new StandardPropertyValue("${Prop1}${Prop2}${abc}", lookup, VariableRegistryUtils.createSystemVariableRegistry()); final Map<String, String> attributes = new HashMap<>(); attributes.put("abc", "Baz"); final FlowFile flowFile = createFlowFile(attributes); @@ -171,5 +175,6 @@ public class TestStandardPropertyValue { public boolean isControllerServiceEnabling(final String serviceIdentifier) { return false; } + } } http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties index ed417d2..e2d3385 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties @@ -184,4 +184,8 @@ nifi.zookeeper.root.node=${nifi.zookeeper.root.node} nifi.kerberos.krb5.file=${nifi.kerberos.krb5.file} nifi.kerberos.service.principal=${nifi.kerberos.service.principal} nifi.kerberos.keytab.location=${nifi.kerberos.keytab.location} -nifi.kerberos.authentication.expiration=${nifi.kerberos.authentication.expiration} \ No newline at end of file +nifi.kerberos.authentication.expiration=${nifi.kerberos.authentication.expiration} + +# external properties files for variable registry +# supports a comma delimited list of file locations +nifi.variable.registry.properties= \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java index 20a641b..d5a1f83 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java @@ -44,6 +44,7 @@ import org.apache.nifi.cluster.manager.exception.NoClusterCoordinatorException; import org.apache.nifi.cluster.protocol.NodeIdentifier; import org.apache.nifi.controller.ControllerService; import org.apache.nifi.controller.reporting.ReportingTaskProvider; +import org.apache.nifi.registry.VariableRegistry; import org.apache.nifi.controller.service.ControllerServiceProvider; import org.apache.nifi.util.NiFiProperties; import org.apache.nifi.web.api.dto.ControllerServiceDTO; @@ -91,6 +92,7 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration private ReportingTaskProvider reportingTaskProvider; private AuditService auditService; private Authorizer authorizer; + private VariableRegistry variableRegistry; private void authorizeFlowAccess(final NiFiUser user) { // authorize access @@ -287,6 +289,11 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration } + @Override + public VariableRegistry getVariableRegistry() { + return this.variableRegistry; + } + private NodeResponse replicate(final String method, final URI uri, final Object entity, final Map<String, String> headers) throws InterruptedException { final NodeIdentifier coordinatorNode = clusterCoordinator.getElectedActiveCoordinatorNode(); if (coordinatorNode == null) { @@ -885,4 +892,8 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration public void setAuthorizer(final Authorizer authorizer) { this.authorizer = authorizer; } + + public void setVariableRegistry(final VariableRegistry variableRegistry){ + this.variableRegistry = variableRegistry; + } } http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java index aa9a8ac..2152c76 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/ControllerFacade.java @@ -78,6 +78,7 @@ import org.apache.nifi.provenance.search.QuerySubmission; import org.apache.nifi.provenance.search.SearchTerm; import org.apache.nifi.provenance.search.SearchTerms; import org.apache.nifi.provenance.search.SearchableField; +import org.apache.nifi.registry.VariableRegistry; import org.apache.nifi.remote.RootGroupPort; import org.apache.nifi.reporting.BulletinRepository; import org.apache.nifi.reporting.ReportingTask; @@ -147,7 +148,7 @@ public class ControllerFacade implements Authorizable { // properties private NiFiProperties properties; private DtoFactory dtoFactory; - + private VariableRegistry variableRegistry; /** * Returns the group id that contains the specified processor. @@ -1503,6 +1504,8 @@ public class ControllerFacade implements Authorizable { return dto; } + + private ComponentSearchResultDTO search(final String searchStr, final ProcessorNode procNode) { final List<String> matches = new ArrayList<>(); final Processor processor = procNode.getProcessor(); @@ -1572,8 +1575,7 @@ public class ControllerFacade implements Authorizable { if (processor instanceof Searchable) { final Searchable searchable = (Searchable) processor; - // prepare the search context - final SearchContext context = new StandardSearchContext(searchStr, procNode, flowController); + final SearchContext context = new StandardSearchContext(searchStr, procNode, flowController, variableRegistry); // search the processor using the appropriate thread context classloader try (final NarCloseable x = NarCloseable.withNarLoader()) { @@ -1781,4 +1783,8 @@ public class ControllerFacade implements Authorizable { public void setBulletinRepository(BulletinRepository bulletinRepository) { this.bulletinRepository = bulletinRepository; } + + public void setVariableRegistry(VariableRegistry variableRegistry) { + this.variableRegistry = variableRegistry; + } } http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/StandardSearchContext.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/StandardSearchContext.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/StandardSearchContext.java index f673075..da060e1 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/StandardSearchContext.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/controller/StandardSearchContext.java @@ -23,6 +23,7 @@ import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.components.PropertyValue; import org.apache.nifi.controller.ControllerServiceLookup; import org.apache.nifi.controller.ProcessorNode; +import org.apache.nifi.registry.VariableRegistry; import org.apache.nifi.search.SearchContext; /** @@ -33,11 +34,13 @@ public class StandardSearchContext implements SearchContext { private final String searchTerm; private final ProcessorNode processorNode; private final ControllerServiceLookup controllerServiceLookup; + private final VariableRegistry variableRegistry; - public StandardSearchContext(final String searchTerm, final ProcessorNode processorNode, final ControllerServiceLookup controllerServiceLookup) { + public StandardSearchContext(final String searchTerm, final ProcessorNode processorNode, final ControllerServiceLookup controllerServiceLookup, VariableRegistry variableRegistry) { this.searchTerm = searchTerm; this.processorNode = processorNode; this.controllerServiceLookup = controllerServiceLookup; + this.variableRegistry = variableRegistry; } @Override @@ -53,7 +56,7 @@ public class StandardSearchContext implements SearchContext { @Override public PropertyValue getProperty(PropertyDescriptor property) { final String configuredValue = processorNode.getProperty(property); - return new StandardPropertyValue(configuredValue == null ? property.getDefaultValue() : configuredValue, controllerServiceLookup, null); + return new StandardPropertyValue(configuredValue == null ? property.getDefaultValue() : configuredValue, controllerServiceLookup,variableRegistry); } @Override http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml index bc3cc08..456b7eb 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/resources/nifi-web-api-context.xml @@ -119,6 +119,7 @@ <property name="authorizer" ref="authorizer"/> <property name="dtoFactory" ref="dtoFactory"/> <property name="bulletinRepository" ref="bulletinRepository"/> + <property name="variableRegistry" ref="variableRegistry"/> </bean> <bean id="authorizableLookup" class="org.apache.nifi.authorization.StandardAuthorizableLookup"> <property name="controllerFacade" ref="controllerFacade"/> @@ -176,6 +177,7 @@ <property name="controllerServiceProvider" ref="controllerServiceProvider"/> <property name="reportingTaskProvider" ref="reportingTaskProvider"/> <property name="authorizer" ref="authorizer"/> + <property name="variableRegistry" ref="variableRegistry"/> </bean> <!-- rest endpoints --> http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-ranger-bundle/nifi-ranger-plugin/src/test/java/org/apache/nifi/ranger/authorization/TestRangerNiFiAuthorizer.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-ranger-bundle/nifi-ranger-plugin/src/test/java/org/apache/nifi/ranger/authorization/TestRangerNiFiAuthorizer.java b/nifi-nar-bundles/nifi-ranger-bundle/nifi-ranger-plugin/src/test/java/org/apache/nifi/ranger/authorization/TestRangerNiFiAuthorizer.java index 876b3f3..8768348 100644 --- a/nifi-nar-bundles/nifi-ranger-bundle/nifi-ranger-plugin/src/test/java/org/apache/nifi/ranger/authorization/TestRangerNiFiAuthorizer.java +++ b/nifi-nar-bundles/nifi-ranger-bundle/nifi-ranger-plugin/src/test/java/org/apache/nifi/ranger/authorization/TestRangerNiFiAuthorizer.java @@ -29,6 +29,8 @@ import org.apache.nifi.authorization.RequestAction; import org.apache.nifi.authorization.Resource; import org.apache.nifi.authorization.UserContextKeys; import org.apache.nifi.authorization.exception.AuthorizerCreationException; +import org.apache.nifi.registry.VariableRegistry; +import org.apache.nifi.registry.VariableRegistryUtils; import org.apache.nifi.util.MockPropertyValue; import org.apache.nifi.util.NiFiProperties; import org.apache.ranger.plugin.policyengine.RangerAccessRequest; @@ -64,6 +66,7 @@ public class TestRangerNiFiAuthorizer { private RangerBasePluginWithPolicies rangerBasePlugin; private AuthorizerConfigurationContext configurationContext; private NiFiProperties nifiProperties; + private VariableRegistry variableRegistry; private String serviceType = "nifiService"; private String appId = "nifiAppId"; @@ -95,22 +98,23 @@ public class TestRangerNiFiAuthorizer { notAllowedResult = Mockito.mock(RangerAccessResult.class); when(notAllowedResult.getIsAllowed()).thenReturn(false); + variableRegistry = VariableRegistryUtils.createSystemVariableRegistry(); } private AuthorizerConfigurationContext createMockConfigContext() { AuthorizerConfigurationContext configurationContext = Mockito.mock(AuthorizerConfigurationContext.class); when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_SECURITY_PATH_PROP))) - .thenReturn(new MockPropertyValue("src/test/resources/ranger/ranger-nifi-security.xml", null)); + .thenReturn(new MockPropertyValue("src/test/resources/ranger/ranger-nifi-security.xml", null,variableRegistry)); when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_AUDIT_PATH_PROP))) - .thenReturn(new MockPropertyValue("src/test/resources/ranger/ranger-nifi-audit.xml", null)); + .thenReturn(new MockPropertyValue("src/test/resources/ranger/ranger-nifi-audit.xml", null,variableRegistry)); when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_APP_ID_PROP))) - .thenReturn(new MockPropertyValue(appId, null)); + .thenReturn(new MockPropertyValue(appId, null,variableRegistry)); when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_SERVICE_TYPE_PROP))) - .thenReturn(new MockPropertyValue(serviceType, null)); + .thenReturn(new MockPropertyValue(serviceType, null,variableRegistry)); return configurationContext; } @@ -126,7 +130,7 @@ public class TestRangerNiFiAuthorizer { @Test public void testKerberosEnabledWithoutKeytab() { when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_KERBEROS_ENABLED_PROP))) - .thenReturn(new MockPropertyValue("true", null)); + .thenReturn(new MockPropertyValue("true", null,variableRegistry)); nifiProperties = Mockito.mock(NiFiProperties.class); when(nifiProperties.getKerberosServicePrincipal()).thenReturn(""); @@ -146,7 +150,7 @@ public class TestRangerNiFiAuthorizer { @Test public void testKerberosEnabledWithoutPrincipal() { when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_KERBEROS_ENABLED_PROP))) - .thenReturn(new MockPropertyValue("true", null)); + .thenReturn(new MockPropertyValue("true", null,variableRegistry)); nifiProperties = Mockito.mock(NiFiProperties.class); when(nifiProperties.getKerberosKeytabLocation()).thenReturn(""); @@ -166,7 +170,7 @@ public class TestRangerNiFiAuthorizer { @Test public void testKerberosEnabledWithoutKeytabOrPrincipal() { when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_KERBEROS_ENABLED_PROP))) - .thenReturn(new MockPropertyValue("true", null)); + .thenReturn(new MockPropertyValue("true", null,variableRegistry)); nifiProperties = Mockito.mock(NiFiProperties.class); when(nifiProperties.getKerberosKeytabLocation()).thenReturn(""); @@ -200,7 +204,7 @@ public class TestRangerNiFiAuthorizer { @Test public void testKerberosEnabled() { when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_KERBEROS_ENABLED_PROP))) - .thenReturn(new MockPropertyValue("true", null)); + .thenReturn(new MockPropertyValue("true", null,variableRegistry)); nifiProperties = Mockito.mock(NiFiProperties.class); when(nifiProperties.getKerberosKeytabLocation()).thenReturn("test"); @@ -398,7 +402,7 @@ public class TestRangerNiFiAuthorizer { final String rangerAdminIdentity = "ranger-admin"; when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_ADMIN_IDENTITY_PROP))) - .thenReturn(new MockPropertyValue(rangerAdminIdentity, null)); + .thenReturn(new MockPropertyValue(rangerAdminIdentity, null,variableRegistry)); rangerBasePlugin = Mockito.mock(RangerBasePluginWithPolicies.class); authorizer = new MockRangerNiFiAuthorizer(rangerBasePlugin); @@ -446,10 +450,10 @@ public class TestRangerNiFiAuthorizer { final AuthorizerConfigurationContext configurationContext = Mockito.mock(AuthorizerConfigurationContext.class); when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_SECURITY_PATH_PROP))) - .thenReturn(new MockPropertyValue("src/test/resources/ranger/ranger-nifi-security.xml", null)); + .thenReturn(new MockPropertyValue("src/test/resources/ranger/ranger-nifi-security.xml", null,variableRegistry)); when(configurationContext.getProperty(eq(RangerNiFiAuthorizer.RANGER_AUDIT_PATH_PROP))) - .thenReturn(new MockPropertyValue("src/test/resources/ranger/ranger-nifi-audit.xml", null)); + .thenReturn(new MockPropertyValue("src/test/resources/ranger/ranger-nifi-audit.xml", null,variableRegistry)); Authorizer authorizer = new RangerNiFiAuthorizer(); try { http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/java/org/apache/nifi/processors/script/TestInvokeGroovy.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/java/org/apache/nifi/processors/script/TestInvokeGroovy.java b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/java/org/apache/nifi/processors/script/TestInvokeGroovy.java index e0007fe..e4e18f7 100644 --- a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/java/org/apache/nifi/processors/script/TestInvokeGroovy.java +++ b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/java/org/apache/nifi/processors/script/TestInvokeGroovy.java @@ -18,6 +18,8 @@ package org.apache.nifi.processors.script; import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.processor.Relationship; +import org.apache.nifi.registry.VariableRegistry; +import org.apache.nifi.registry.VariableRegistryUtils; import org.apache.nifi.util.MockFlowFile; import org.apache.nifi.util.MockProcessContext; import org.apache.nifi.util.MockProcessorInitializationContext; @@ -37,9 +39,12 @@ import static org.junit.Assert.assertTrue; public class TestInvokeGroovy extends BaseScriptTest { + private VariableRegistry variableRegistry; + @Before public void setup() throws Exception { super.setupInvokeScriptProcessor(); + variableRegistry = VariableRegistryUtils.createSystemVariableRegistry(); } /** @@ -72,7 +77,7 @@ public class TestInvokeGroovy extends BaseScriptTest { @Test public void testScriptDefinedAttribute() throws Exception { InvokeScriptedProcessor processor = new InvokeScriptedProcessor(); - MockProcessContext context = new MockProcessContext(processor); + MockProcessContext context = new MockProcessContext(processor, variableRegistry); MockProcessorInitializationContext initContext = new MockProcessorInitializationContext(processor, context); processor.initialize(initContext); @@ -81,7 +86,7 @@ public class TestInvokeGroovy extends BaseScriptTest { context.setProperty(InvokeScriptedProcessor.SCRIPT_FILE, "target/test/resources/groovy/test_reader.groovy"); context.setProperty(InvokeScriptedProcessor.MODULES, "target/test/resources/groovy"); // State Manger is unused, and a null reference is specified - processor.customValidate(new MockValidationContext(context, null)); + processor.customValidate(new MockValidationContext(context, null, variableRegistry)); processor.setup(context); List<PropertyDescriptor> descriptors = processor.getSupportedPropertyDescriptors(); @@ -106,7 +111,7 @@ public class TestInvokeGroovy extends BaseScriptTest { @Test public void testScriptDefinedRelationship() throws Exception { InvokeScriptedProcessor processor = new InvokeScriptedProcessor(); - MockProcessContext context = new MockProcessContext(processor); + MockProcessContext context = new MockProcessContext(processor, variableRegistry); MockProcessorInitializationContext initContext = new MockProcessorInitializationContext(processor, context); processor.initialize(initContext); @@ -114,7 +119,7 @@ public class TestInvokeGroovy extends BaseScriptTest { context.setProperty(InvokeScriptedProcessor.SCRIPT_ENGINE, "Groovy"); context.setProperty(InvokeScriptedProcessor.SCRIPT_FILE, "target/test/resources/groovy/test_reader.groovy"); // State Manger is unused, and a null reference is specified - processor.customValidate(new MockValidationContext(context, null)); + processor.customValidate(new MockValidationContext(context, null, variableRegistry)); processor.setup(context); Set<Relationship> relationships = processor.getRelationships(); http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/test/java/org/apache/nifi/reporting/TestSiteToSiteProvenanceReportingTask.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/test/java/org/apache/nifi/reporting/TestSiteToSiteProvenanceReportingTask.java b/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/test/java/org/apache/nifi/reporting/TestSiteToSiteProvenanceReportingTask.java index 4930094..0e8851c 100644 --- a/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/test/java/org/apache/nifi/reporting/TestSiteToSiteProvenanceReportingTask.java +++ b/nifi-nar-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/test/java/org/apache/nifi/reporting/TestSiteToSiteProvenanceReportingTask.java @@ -28,6 +28,7 @@ import org.apache.nifi.provenance.ProvenanceEventRecord; import org.apache.nifi.provenance.ProvenanceEventRepository; import org.apache.nifi.provenance.ProvenanceEventType; import org.apache.nifi.provenance.StandardProvenanceEventRecord; +import org.apache.nifi.registry.VariableRegistryUtils; import org.apache.nifi.remote.Transaction; import org.apache.nifi.remote.TransferDirection; import org.apache.nifi.remote.client.SiteToSiteClient; @@ -94,7 +95,7 @@ public class TestSiteToSiteProvenanceReportingTask { @Override public PropertyValue answer(final InvocationOnMock invocation) throws Throwable { final PropertyDescriptor descriptor = invocation.getArgumentAt(0, PropertyDescriptor.class); - return new MockPropertyValue(properties.get(descriptor), null); + return new MockPropertyValue(properties.get(descriptor), null, VariableRegistryUtils.createSystemVariableRegistry()); } }).when(context).getProperty(Mockito.any(PropertyDescriptor.class)); http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnAttribute.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnAttribute.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnAttribute.java index 66dc854..13bfe61 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnAttribute.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestRouteOnAttribute.java @@ -26,6 +26,8 @@ import java.util.Map; import org.apache.nifi.components.ValidationResult; import org.apache.nifi.processor.Relationship; +import org.apache.nifi.registry.VariableRegistry; +import org.apache.nifi.registry.VariableRegistryUtils; import org.apache.nifi.state.MockStateManager; import org.apache.nifi.util.MockFlowFile; import org.apache.nifi.util.MockProcessContext; @@ -36,10 +38,12 @@ import org.junit.Test; public class TestRouteOnAttribute { + private VariableRegistry variableRegistry = VariableRegistryUtils.createSystemVariableRegistry(); + @Test public void testInvalidOnMisconfiguredProperty() { final RouteOnAttribute proc = new RouteOnAttribute(); - final MockProcessContext ctx = new MockProcessContext(proc, new MockStateManager(proc)); + final MockProcessContext ctx = new MockProcessContext(proc, new MockStateManager(proc), variableRegistry); final ValidationResult validationResult = ctx.setProperty("RouteA", "${a:equals('b')"); // Missing closing brace assertFalse(validationResult.isValid()); } @@ -47,7 +51,7 @@ public class TestRouteOnAttribute { @Test public void testInvalidOnNonBooleanProperty() { final RouteOnAttribute proc = new RouteOnAttribute(); - final MockProcessContext ctx = new MockProcessContext(proc, new MockStateManager(proc)); + final MockProcessContext ctx = new MockProcessContext(proc, new MockStateManager(proc), variableRegistry); final ValidationResult validationResult = ctx.setProperty("RouteA", "${a:length()"); // Should be boolean assertFalse(validationResult.isValid()); } http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/test/java/org/apache/nifi/controller/MonitorMemoryTest.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/test/java/org/apache/nifi/controller/MonitorMemoryTest.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/test/java/org/apache/nifi/controller/MonitorMemoryTest.java index 824503a..488891c 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/test/java/org/apache/nifi/controller/MonitorMemoryTest.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-reporting-tasks/src/test/java/org/apache/nifi/controller/MonitorMemoryTest.java @@ -21,6 +21,7 @@ import org.apache.nifi.admin.service.AuditService; import org.apache.nifi.authorization.Authorizer; import org.apache.nifi.controller.repository.FlowFileEventRepository; import org.apache.nifi.provenance.MockProvenanceRepository; +import org.apache.nifi.registry.VariableRegistryUtils; import org.apache.nifi.util.CapturingLogger; import org.apache.nifi.util.NiFiProperties; import org.junit.After; @@ -136,6 +137,6 @@ public class MonitorMemoryTest { properties.setProperty("nifi.remote.input.secure", ""); return FlowController.createStandaloneInstance(mock(FlowFileEventRepository.class), properties, - mock(Authorizer.class), mock(AuditService.class), null, null); + mock(Authorizer.class), mock(AuditService.class), null, null, VariableRegistryUtils.createCustomVariableRegistry(properties.getVariableRegistryPropertiesPaths())); } } http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-server/src/test/java/org/apache/nifi/distributed/cache/server/TestServerAndClient.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-server/src/test/java/org/apache/nifi/distributed/cache/server/TestServerAndClient.java b/nifi-nar-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-server/src/test/java/org/apache/nifi/distributed/cache/server/TestServerAndClient.java index 82e4a99..078bd6b 100644 --- a/nifi-nar-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-server/src/test/java/org/apache/nifi/distributed/cache/server/TestServerAndClient.java +++ b/nifi-nar-bundles/nifi-standard-services/nifi-distributed-cache-services-bundle/nifi-distributed-cache-server/src/test/java/org/apache/nifi/distributed/cache/server/TestServerAndClient.java @@ -41,6 +41,8 @@ import org.apache.nifi.distributed.cache.client.exception.DeserializationExcepti import org.apache.nifi.distributed.cache.server.map.DistributedMapCacheServer; import org.apache.nifi.processor.Processor; import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.registry.VariableRegistry; +import org.apache.nifi.registry.VariableRegistryUtils; import org.apache.nifi.reporting.InitializationException; import org.apache.nifi.util.MockConfigurationContext; import org.apache.nifi.util.MockControllerServiceInitializationContext; @@ -55,6 +57,7 @@ import org.slf4j.LoggerFactory; public class TestServerAndClient { private static Logger LOGGER; + private static VariableRegistry variableRegistry; static { System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "info"); @@ -64,6 +67,7 @@ public class TestServerAndClient { System.setProperty("org.slf4j.simpleLogger.log.nifi.distributed.cache.server.TestServerAndClient", "debug"); System.setProperty("org.slf4j.simpleLogger.log.nifi.remote.io.socket.ssl.SSLSocketChannel", "trace"); LOGGER = LoggerFactory.getLogger(TestServerAndClient.class); + variableRegistry = VariableRegistryUtils.createSystemVariableRegistry(); } @Test @@ -329,7 +333,7 @@ public class TestServerAndClient { clientProperties.put(DistributedMapCacheClientService.HOSTNAME, "localhost"); clientProperties.put(DistributedMapCacheClientService.PORT, String.valueOf(server.getPort())); clientProperties.put(DistributedMapCacheClientService.COMMUNICATIONS_TIMEOUT, "360 secs"); - MockConfigurationContext clientContext = new MockConfigurationContext(clientProperties, clientInitContext.getControllerServiceLookup()); + MockConfigurationContext clientContext = new MockConfigurationContext(clientProperties, clientInitContext.getControllerServiceLookup(), variableRegistry); client.cacheConfig(clientContext); final Serializer<String> valueSerializer = new StringSerializer(); final Serializer<String> keySerializer = new StringSerializer(); @@ -375,7 +379,7 @@ public class TestServerAndClient { client2.initialize(clientInitContext2); MockConfigurationContext clientContext2 = new MockConfigurationContext(clientProperties, - clientInitContext2.getControllerServiceLookup()); + clientInitContext2.getControllerServiceLookup(), variableRegistry); client2.cacheConfig(clientContext2); assertFalse(client2.putIfAbsent("testKey", "test", keySerializer, valueSerializer)); assertTrue(client2.containsKey("testKey", keySerializer)); @@ -408,7 +412,7 @@ public class TestServerAndClient { server.initialize(serverInitContext); final Map<PropertyDescriptor, String> serverProperties = new HashMap<>(); - final MockConfigurationContext serverContext = new MockConfigurationContext(serverProperties, serverInitContext.getControllerServiceLookup()); + final MockConfigurationContext serverContext = new MockConfigurationContext(serverProperties, serverInitContext.getControllerServiceLookup(), variableRegistry); server.startServer(serverContext); DistributedMapCacheClientService client = new DistributedMapCacheClientService(); @@ -418,7 +422,7 @@ public class TestServerAndClient { final Map<PropertyDescriptor, String> clientProperties = new HashMap<>(); clientProperties.put(DistributedMapCacheClientService.HOSTNAME, "localhost"); clientProperties.put(DistributedMapCacheClientService.COMMUNICATIONS_TIMEOUT, "360 secs"); - MockConfigurationContext clientContext = new MockConfigurationContext(clientProperties, clientInitContext.getControllerServiceLookup()); + MockConfigurationContext clientContext = new MockConfigurationContext(clientProperties, clientInitContext.getControllerServiceLookup(), variableRegistry); client.cacheConfig(clientContext); final Serializer<String> valueSerializer = new StringSerializer(); final Serializer<String> keySerializer = new StringSerializer(); @@ -465,7 +469,7 @@ public class TestServerAndClient { final Map<PropertyDescriptor, String> clientProperties = new HashMap<>(); clientProperties.put(DistributedSetCacheClientService.HOSTNAME, "localhost"); clientProperties.put(DistributedSetCacheClientService.PORT, String.valueOf(port)); - final MockConfigurationContext clientContext = new MockConfigurationContext(clientProperties, clientInitContext.getControllerServiceLookup()); + final MockConfigurationContext clientContext = new MockConfigurationContext(clientProperties, clientInitContext.getControllerServiceLookup(), variableRegistry); client.onConfigured(clientContext); return client; http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/UpdateAttributeModelFactory.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/UpdateAttributeModelFactory.java b/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/UpdateAttributeModelFactory.java index 0182d61..6102e82 100644 --- a/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/UpdateAttributeModelFactory.java +++ b/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/UpdateAttributeModelFactory.java @@ -23,6 +23,7 @@ import org.apache.nifi.attribute.expression.language.Query; import org.apache.nifi.attribute.expression.language.StandardExpressionLanguageCompiler; import org.apache.nifi.attribute.expression.language.exception.AttributeExpressionLanguageParsingException; import org.apache.nifi.expression.AttributeExpression.ResultType; +import org.apache.nifi.registry.VariableRegistry; import org.apache.nifi.update.attributes.dto.ActionDTO; import org.apache.nifi.update.attributes.dto.ConditionDTO; import org.apache.nifi.update.attributes.dto.RuleDTO; @@ -32,6 +33,12 @@ import org.apache.nifi.update.attributes.dto.RuleDTO; */ public class UpdateAttributeModelFactory { + private final VariableRegistry variableRegistry; + + public UpdateAttributeModelFactory(VariableRegistry variableRegistry) { + this.variableRegistry = variableRegistry; + } + public Rule createRule(final RuleDTO dto) { if (dto == null) { throw new IllegalArgumentException("Rule must be specified."); @@ -72,7 +79,7 @@ public class UpdateAttributeModelFactory { } // validate the condition's expression - final StandardExpressionLanguageCompiler elCompiler = new StandardExpressionLanguageCompiler(); + final StandardExpressionLanguageCompiler elCompiler = new StandardExpressionLanguageCompiler(variableRegistry); final String syntaxError = elCompiler.validateExpression(dto.getExpression(), false); if (syntaxError != null) { throw new IllegalArgumentException(syntaxError); http://git-wip-us.apache.org/repos/asf/nifi/blob/8412d266/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/api/RuleResource.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/api/RuleResource.java b/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/api/RuleResource.java index 4158218..99c34cd 100644 --- a/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/api/RuleResource.java +++ b/nifi-nar-bundles/nifi-update-attribute-bundle/nifi-update-attribute-ui/src/main/java/org/apache/nifi/update/attributes/api/RuleResource.java @@ -46,6 +46,7 @@ import javax.ws.rs.core.Response.ResponseBuilder; import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; +import org.apache.nifi.registry.VariableRegistry; import org.apache.nifi.update.attributes.Action; import org.apache.nifi.update.attributes.Condition; import org.apache.nifi.update.attributes.Criteria; @@ -187,6 +188,7 @@ public class RuleResource { // get the web context final NiFiWebConfigurationContext configurationContext = (NiFiWebConfigurationContext) servletContext.getAttribute("nifi-web-configuration-context"); + final VariableRegistry variableRegistry = configurationContext.getVariableRegistry(); // ensure the rule has been specified if (requestEntity == null || requestEntity.getRule() == null) { @@ -219,7 +221,7 @@ public class RuleResource { // load the criteria final Criteria criteria = getCriteria(configurationContext, requestContext); - final UpdateAttributeModelFactory factory = new UpdateAttributeModelFactory(); + final UpdateAttributeModelFactory factory = new UpdateAttributeModelFactory(variableRegistry); // create the new rule final Rule rule; @@ -261,10 +263,14 @@ public class RuleResource { // generate a new id final String uuid = UUID.randomUUID().toString(); + // get the variable registry + final NiFiWebConfigurationContext configurationContext = (NiFiWebConfigurationContext) servletContext.getAttribute("nifi-web-configuration-context"); + final VariableRegistry variableRegistry = configurationContext.getVariableRegistry(); + final Condition condition; try { // create the condition object - final UpdateAttributeModelFactory factory = new UpdateAttributeModelFactory(); + final UpdateAttributeModelFactory factory = new UpdateAttributeModelFactory(variableRegistry); condition = factory.createCondition(requestEntity.getCondition()); condition.setId(uuid); } catch (final IllegalArgumentException iae) { @@ -295,10 +301,14 @@ public class RuleResource { // generate a new id final String uuid = UUID.randomUUID().toString(); + // get the variable registry + final NiFiWebConfigurationContext configurationContext = (NiFiWebConfigurationContext) servletContext.getAttribute("nifi-web-configuration-context"); + final VariableRegistry variableRegistry = configurationContext.getVariableRegistry(); + final Action action; try { // create the condition object - final UpdateAttributeModelFactory factory = new UpdateAttributeModelFactory(); + final UpdateAttributeModelFactory factory = new UpdateAttributeModelFactory(variableRegistry); action = factory.createAction(requestEntity.getAction()); action.setId(uuid); } catch (final IllegalArgumentException iae) { @@ -461,6 +471,8 @@ public class RuleResource { // get the web context final NiFiWebConfigurationContext nifiWebContext = (NiFiWebConfigurationContext) servletContext.getAttribute("nifi-web-configuration-context"); + // get the variable registry + final VariableRegistry variableRegistry = nifiWebContext.getVariableRegistry(); // ensure the rule has been specified if (requestEntity == null || requestEntity.getRule() == null) { @@ -497,7 +509,7 @@ public class RuleResource { requestEntity.getProcessorId(), requestEntity.getRevision(), requestEntity.getClientId()); // load the criteria - final UpdateAttributeModelFactory factory = new UpdateAttributeModelFactory(); + final UpdateAttributeModelFactory factory = new UpdateAttributeModelFactory(variableRegistry); final Criteria criteria = getCriteria(nifiWebContext, requestContext); // attempt to locate the rule
