From df11e1d2c07c841561ed085810e2a712b84e02bc Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Tue, 2 Aug 2016 07:03:14 -0400 Subject: [PATCH] NIFI-2425 fixed ControllerService referebcing in DTOs/Templates. This closes #770 --- .../nifi/web/api/dto/FlowSnippetDTO.java | 34 ++++++++++++++++--- .../apache/nifi/controller/TemplateUtils.java | 1 - 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowSnippetDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowSnippetDTO.java index f2681345e4..12fb475cbf 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowSnippetDTO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowSnippetDTO.java @@ -18,6 +18,8 @@ package org.apache.nifi.web.api.dto; import java.util.Comparator; import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.TreeSet; import java.util.UUID; @@ -207,8 +209,33 @@ public class FlowSnippetDTO { id = UUID.fromString(componentDto.getParentGroupId()); id = new UUID(id.getMostSignificantBits(), 0); componentDto.setParentGroupId(id.toString()); - - if (componentDto instanceof ConnectionDTO) { + if (componentDto instanceof ControllerServiceDTO) { + ControllerServiceDTO csDTO = (ControllerServiceDTO) componentDto; + Map map = csDTO.getDescriptors(); + Map props = csDTO.getProperties(); + for (Entry entry : map.entrySet()) { + if (entry.getValue().getIdentifiesControllerService() != null) { + String key = entry.getKey(); + String value = props.get(key); + id = UUID.fromString(value); + id = new UUID(id.getMostSignificantBits(), 0); + props.put(key, id.toString()); + } + } + } else if (componentDto instanceof ProcessorDTO) { + ProcessorDTO processorDTO = (ProcessorDTO) componentDto; + Map map = processorDTO.getConfig().getDescriptors(); + Map props = processorDTO.getConfig().getProperties(); + for (Entry entry : map.entrySet()) { + if (entry.getValue().getIdentifiesControllerService() != null) { + String key = entry.getKey(); + String value = props.get(key); + id = UUID.fromString(value); + id = new UUID(id.getMostSignificantBits(), 0); + props.put(key, id.toString()); + } + } + } else if (componentDto instanceof ConnectionDTO) { ConnectionDTO connectionDTO = (ConnectionDTO) componentDto; ConnectableDTO cdto = connectionDTO.getSource(); @@ -228,8 +255,7 @@ public class FlowSnippetDTO { id = UUID.fromString(cdto.getGroupId()); id = new UUID(id.getMostSignificantBits(), 0); cdto.setGroupId(id.toString()); - } - if (componentDto instanceof ProcessGroupDTO) { + } else if (componentDto instanceof ProcessGroupDTO) { FlowSnippetDTO fsDTO = ((ProcessGroupDTO) componentDto).getContents(); this.removeInstanceIdentifierIfNecessary(fsDTO.getConnections()); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateUtils.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateUtils.java index 21dba95957..668872b591 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateUtils.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateUtils.java @@ -188,7 +188,6 @@ public class TemplateUtils { processorConfig.setCustomUiUrl(null); processorConfig.setDefaultConcurrentTasks(null); processorConfig.setDefaultSchedulingPeriod(null); - processorConfig.setDescriptors(null); processorConfig.setAutoTerminatedRelationships(null); }