Github user ijokarumawak commented on a diff in the pull request: https://github.com/apache/nifi/pull/2219#discussion_r159118517 --- Diff: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/registry/flow/StandardFlowRegistryClient.java --- @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +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; + +import javax.net.ssl.SSLContext; + +import org.apache.nifi.framework.security.util.SslContextFactory; +import org.apache.nifi.util.NiFiProperties; + +public class StandardFlowRegistryClient implements FlowRegistryClient { + private NiFiProperties nifiProperties; + private ConcurrentMap<String, FlowRegistry> registryById = new ConcurrentHashMap<>(); + + @Override + public FlowRegistry getFlowRegistry(String registryId) { + return registryById.get(registryId); + } + + @Override + public Set<String> getRegistryIdentifiers() { + return registryById.keySet(); + } + + @Override + public void addFlowRegistry(final FlowRegistry registry) { + final boolean duplicateName = registryById.values().stream() + .anyMatch(reg -> reg.getName().equals(registry.getName())); + + if (duplicateName) { + throw new IllegalStateException("Cannot add Flow Registry because a Flow Registry already exists with the name " + registry.getName()); --- End diff -- The same name duplication check should be done when a FlowRegistry is updated. Currently, the same name can be specified when updating.
---