NIFI-4436:

- Only enforcing the unique name check when the registry has a different identifier.

This closes #2385.

Signed-off-by: Bryan Bende <bbende@apache.org>
This commit is contained in:
Matt Gilman 2018-01-08 14:49:26 -05:00 committed by Bryan Bende
parent acdaeebac7
commit 8f635f1c0d
No known key found for this signature in database
GPG Key ID: A0DDA9ED50711C39
1 changed files with 4 additions and 6 deletions

View File

@ -16,9 +16,7 @@
*/ */
package org.apache.nifi.web; package org.apache.nifi.web;
import javax.ws.rs.WebApplicationException; import com.google.common.collect.Sets;
import javax.ws.rs.core.Response;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.nifi.action.Action; import org.apache.nifi.action.Action;
import org.apache.nifi.action.Component; import org.apache.nifi.action.Component;
@ -273,8 +271,8 @@ import org.apache.nifi.web.util.SnippetUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
@ -2452,7 +2450,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
final FlowRegistry registry = registryDAO.getFlowRegistry(registryDTO.getId()); final FlowRegistry registry = registryDAO.getFlowRegistry(registryDTO.getId());
final RevisionUpdate<FlowRegistry> revisionUpdate = revisionManager.updateRevision(revisionClaim, user, () -> { final RevisionUpdate<FlowRegistry> revisionUpdate = revisionManager.updateRevision(revisionClaim, user, () -> {
final boolean duplicateName = registryDAO.getFlowRegistries().stream() 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) { if (duplicateName) {
throw new IllegalStateException("Cannot update Flow Registry because a Flow Registry already exists with the name " + registryDTO.getName()); throw new IllegalStateException("Cannot update Flow Registry because a Flow Registry already exists with the name " + registryDTO.getName());