NIFI-6767 Persist registry URL after service restart.

This closes #4006.

Signed-off-by: Bryan Bende <bbende@apache.org>
This commit is contained in:
Kristjan Antunovic 2020-01-22 16:01:49 +01:00 committed by Bryan Bende
parent 861b83f314
commit 483af3a460
No known key found for this signature in database
GPG Key ID: A0DDA9ED50711C39
1 changed files with 5 additions and 3 deletions

View File

@ -28,6 +28,8 @@ import org.apache.nifi.security.util.TlsConfiguration;
import org.apache.nifi.security.util.TlsException;
import org.apache.nifi.util.NiFiProperties;
import org.apache.http.client.utils.URIBuilder;
public class StandardFlowRegistryClient implements FlowRegistryClient {
private NiFiProperties nifiProperties;
private ConcurrentMap<String, FlowRegistry> registryById = new ConcurrentHashMap<>();
@ -61,7 +63,8 @@ public class StandardFlowRegistryClient implements FlowRegistryClient {
public FlowRegistry addFlowRegistry(final String registryId, final String registryName, final String registryUrl, final String description) {
final URI uri;
try {
uri = new URI(registryUrl);
// Handles case where the URI entered has a trailing slash, or includes the trailing /nifi-registry-api
uri = new URIBuilder(registryUrl).setPath("").removeQuery().build();
} catch (URISyntaxException e) {
throw new IllegalArgumentException("The given Registry URL is not valid: " + registryUrl);
}
@ -71,8 +74,7 @@ public class StandardFlowRegistryClient implements FlowRegistryClient {
throw new IllegalArgumentException("The given Registry URL is not valid: " + registryUrl);
}
// Handles case where the URI entered has a trailing slash, or includes the trailing /nifi-registry-api
final String registryBaseUrl = uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort();
final String registryBaseUrl = uri.toString();
final FlowRegistry registry;
if (uriScheme.equalsIgnoreCase("http") || uriScheme.equalsIgnoreCase("https")) {