NIFI-4436: Bug fixes

Signed-off-by: Matt Gilman <matt.c.gilman@gmail.com>
This commit is contained in:
Mark Payne 2017-12-13 13:57:59 -05:00 committed by Bryan Bende
parent f48808b1f4
commit 416b86145f
No known key found for this signature in database
GPG Key ID: A0DDA9ED50711C39
1 changed files with 11 additions and 11 deletions

View File

@ -18,6 +18,7 @@
package org.apache.nifi.registry.flow;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@ -58,8 +59,17 @@ public class StandardFlowRegistryClient implements FlowRegistryClient {
@Override
public FlowRegistry addFlowRegistry(final String registryId, final String registryName, final String registryUrl, final String description) {
final URI uri = URI.create(registryUrl);
final URI uri;
try {
uri = new URI(registryUrl);
} catch (URISyntaxException e) {
throw new IllegalArgumentException("The given Registry URL is not valid: " + registryUrl);
}
final String uriScheme = uri.getScheme();
if (uriScheme == null) {
throw new IllegalArgumentException("The given Registry URL is not valid: " + registryUrl);
}
final FlowRegistry registry;
if (uriScheme.equalsIgnoreCase("http") || uriScheme.equalsIgnoreCase("https")) {
@ -70,16 +80,6 @@ public class StandardFlowRegistryClient implements FlowRegistryClient {
+ "Please populate NiFi's Keystore/Truststore properties or connect to a NiFi Registry over http instead of https.");
}
registry = new RestBasedFlowRegistry(this, registryId, registryUrl, sslContext, registryName);
registry.setDescription(description);
} else if (uriScheme.equalsIgnoreCase("http") || uriScheme.equalsIgnoreCase("https")) {
final SSLContext sslContext = SslContextFactory.createSslContext(nifiProperties, false);
if (sslContext == null && uriScheme.equalsIgnoreCase("https")) {
throw new IllegalStateException("Failed to create Flow Registry for URI " + registryUrl
+ " because this NiFi is not configured with a Keystore/Truststore, so it is not capable of communicating with a secure Registry. "
+ "Please populate NiFi's Keystore/Truststore properties or connect to a NiFi Registry over http instead of https.");
}
registry = new RestBasedFlowRegistry(this, registryId, registryUrl, sslContext, registryName);
registry.setDescription(description);
} else {