From 8f635f1c0ddd1a4d05ecbfa69804003cabe1d3a3 Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Mon, 8 Jan 2018 14:49:26 -0500 Subject: [PATCH] NIFI-4436: - Only enforcing the unique name check when the registry has a different identifier. This closes #2385. Signed-off-by: Bryan Bende --- .../org/apache/nifi/web/StandardNiFiServiceFacade.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java index 6e0e9d2663..3df75bb5f4 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java @@ -16,9 +16,7 @@ */ package org.apache.nifi.web; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; - +import com.google.common.collect.Sets; import org.apache.commons.collections4.CollectionUtils; import org.apache.nifi.action.Action; import org.apache.nifi.action.Component; @@ -273,8 +271,8 @@ import org.apache.nifi.web.util.SnippetUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.collect.Sets; - +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Response; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -2452,7 +2450,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { final FlowRegistry registry = registryDAO.getFlowRegistry(registryDTO.getId()); final RevisionUpdate revisionUpdate = revisionManager.updateRevision(revisionClaim, user, () -> { final boolean duplicateName = registryDAO.getFlowRegistries().stream() - .anyMatch(reg -> reg.getName().equals(registryDTO.getName())); + .anyMatch(reg -> reg.getName().equals(registryDTO.getName()) && !reg.getIdentifier().equals(registryDTO.getId())); if (duplicateName) { throw new IllegalStateException("Cannot update Flow Registry because a Flow Registry already exists with the name " + registryDTO.getName());