diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapper.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapper.java index f5b2a754c0..c04e94b6c2 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapper.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapper.java @@ -17,6 +17,7 @@ package org.apache.nifi.registry.flow.mapping; + import org.apache.commons.lang3.ClassUtils; import org.apache.nifi.bundle.BundleCoordinate; import org.apache.nifi.components.PropertyDescriptor; @@ -102,6 +103,7 @@ import java.util.stream.Collectors; public class NiFiRegistryFlowMapper { private static final String ENCRYPTED_PREFIX = "enc{"; private static final String ENCRYPTED_SUFFIX = "}"; + private static final String REGISTRY_URL_DESCRIPTOR_NAME = "url"; private final ExtensionManager extensionManager; private final FlowMappingOptions flowMappingOptions; @@ -193,7 +195,8 @@ public class NiFiRegistryFlowMapper { // This is specific for the {@code NifiRegistryFlowRegistryClient}, purely for backward compatibility private String getRegistryUrl(final FlowRegistryClientNode registry) { - return registry.getComponentType().equals("org.apache.nifi.registry.flow.NifiRegistryFlowRegistryClient") ? registry.getRawPropertyValue(registry.getPropertyDescriptor("URL")) : ""; + return registry.getComponentType().endsWith("NifiRegistryFlowRegistryClient") + ? registry.getRawPropertyValue(registry.getPropertyDescriptor(REGISTRY_URL_DESCRIPTOR_NAME)) : ""; } private InstantiatedVersionedProcessGroup mapGroup(final ProcessGroup group, final ControllerServiceProvider serviceProvider, diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapperTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapperTest.java index 9caded0063..fa5152a4a6 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapperTest.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/registry/flow/mapping/NiFiRegistryFlowMapperTest.java @@ -17,6 +17,7 @@ package org.apache.nifi.registry.flow.mapping; +import org.apache.commons.lang3.StringUtils; import org.apache.nifi.authorization.resource.ComponentAuthorizable; import org.apache.nifi.bundle.BundleCoordinate; import org.apache.nifi.components.PropertyDescriptor; @@ -71,6 +72,7 @@ import org.apache.nifi.parameter.ParameterDescriptor; import org.apache.nifi.parameter.ParameterProvider; import org.apache.nifi.parameter.ParameterProviderConfiguration; import org.apache.nifi.parameter.StandardParameterProviderConfiguration; +import org.apache.nifi.processor.util.StandardValidators; import org.apache.nifi.registry.ComponentVariableRegistry; import org.apache.nifi.registry.VariableDescriptor; import org.apache.nifi.registry.flow.FlowRegistryClientNode; @@ -133,8 +135,10 @@ public class NiFiRegistryFlowMapperTest { @Before public void setup() { final FlowRegistryClientNode flowRegistry = mock(FlowRegistryClientNode.class); - Mockito.when(flowRegistry.getComponentType()).thenReturn("org.apache.nifi.registry.flow.NifiRegistryFlowRegistryClient"); + Mockito.when(flowRegistry.getComponentType()).thenReturn(TestNifiRegistryFlowRegistryClient.class.getName()); Mockito.when(flowRegistry.getRawPropertyValue(Mockito.any())).thenReturn(""); + Mockito.when(flowRegistry.getPropertyDescriptor(TestNifiRegistryFlowRegistryClient.PROPERTY_URL.getName())).thenReturn(TestNifiRegistryFlowRegistryClient.PROPERTY_URL); + Mockito.when(flowRegistry.getRawPropertyValue(TestNifiRegistryFlowRegistryClient.PROPERTY_URL)).thenReturn("http://127.0.0.1:18080"); when(flowManager.getFlowRegistryClient(anyString())).thenReturn(flowRegistry); @@ -235,6 +239,9 @@ public class NiFiRegistryFlowMapperTest { final VersionedProcessGroup innerVersionedProcessGroup = versionedProcessGroup.getProcessGroups().iterator().next(); + // ensure the Registry URL has been set correctly in the flowManager + assert(StringUtils.isNotEmpty(innerVersionedProcessGroup.getVersionedFlowCoordinates().getStorageLocation())); + // verify root versioned process group contents only verifyVersionedProcessGroup(processGroup, versionedProcessGroup,false,false); @@ -847,4 +854,14 @@ public class NiFiRegistryFlowMapperTest { assertEquals(propertyDescriptor.getDisplayName(), versionedPropertyDescriptor.getDisplayName()); assertEquals(propertyDescriptor.isSensitive(), versionedPropertyDescriptor.isSensitive()); } + + private static class TestNifiRegistryFlowRegistryClient { + public static final PropertyDescriptor PROPERTY_URL = new PropertyDescriptor.Builder() + .name("url") + .displayName("URL") + .description("URL of the NiFi Registry") + .addValidator(StandardValidators.URL_VALIDATOR) + .required(true) + .build(); + } }