From f6136b69e53feeb77768096afba6f5cd800014a1 Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Thu, 14 Jul 2016 10:06:46 -0400 Subject: [PATCH] NIFI-1413: Rebased against master and updated templates endpoint merge to use template entities instead of template dto's This closes #649 --- .../http/endpoints/TemplatesEndpointMerger.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/TemplatesEndpointMerger.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/TemplatesEndpointMerger.java index a07289de88..516cba95b4 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/TemplatesEndpointMerger.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/TemplatesEndpointMerger.java @@ -28,6 +28,7 @@ import java.util.stream.Collectors; import org.apache.nifi.cluster.coordination.http.EndpointResponseMerger; import org.apache.nifi.cluster.manager.NodeResponse; import org.apache.nifi.web.api.dto.TemplateDTO; +import org.apache.nifi.web.api.entity.TemplateEntity; import org.apache.nifi.web.api.entity.TemplatesEntity; public class TemplatesEndpointMerger implements EndpointResponseMerger { @@ -42,7 +43,7 @@ public class TemplatesEndpointMerger implements EndpointResponseMerger { return TemplatesEntity.class; } - protected Set getDtos(final TemplatesEntity entity) { + protected Set getDtos(final TemplatesEntity entity) { return entity.getTemplates(); } @@ -61,11 +62,11 @@ public class TemplatesEndpointMerger implements EndpointResponseMerger { // Find the templates that all nodes know about. We do this by mapping Template ID to Template and // then for each node, removing any template whose ID is not known to that node. After iterating over // all of the nodes, we are left with a Map whose contents are those Templates known by all nodes. - Map templatesById = null; + Map templatesById = null; for (final NodeResponse nodeResponse : successfulResponses) { final TemplatesEntity entity = nodeResponse == clientResponse ? responseEntity : nodeResponse.getClientResponse().getEntity(TemplatesEntity.class); - final Set templateDtos = entity.getTemplates(); - final Map nodeTemplatesById = templateDtos.stream().collect(Collectors.toMap(dto -> dto.getId(), dto -> dto)); + final Set templateEntities = entity.getTemplates(); + final Map nodeTemplatesById = templateEntities.stream().collect(Collectors.toMap(ent -> ent.getId(), ent -> ent)); if (templatesById == null) { // Create new HashMap so that the map that we have is modifiable.