mirror of https://github.com/apache/nifi.git
NIFI-1413: Rebased against master and updated templates endpoint merge to use template entities instead of template dto's
This closes #649
This commit is contained in:
parent
329192a7d3
commit
f6136b69e5
|
@ -28,6 +28,7 @@ import java.util.stream.Collectors;
|
||||||
import org.apache.nifi.cluster.coordination.http.EndpointResponseMerger;
|
import org.apache.nifi.cluster.coordination.http.EndpointResponseMerger;
|
||||||
import org.apache.nifi.cluster.manager.NodeResponse;
|
import org.apache.nifi.cluster.manager.NodeResponse;
|
||||||
import org.apache.nifi.web.api.dto.TemplateDTO;
|
import org.apache.nifi.web.api.dto.TemplateDTO;
|
||||||
|
import org.apache.nifi.web.api.entity.TemplateEntity;
|
||||||
import org.apache.nifi.web.api.entity.TemplatesEntity;
|
import org.apache.nifi.web.api.entity.TemplatesEntity;
|
||||||
|
|
||||||
public class TemplatesEndpointMerger implements EndpointResponseMerger {
|
public class TemplatesEndpointMerger implements EndpointResponseMerger {
|
||||||
|
@ -42,7 +43,7 @@ public class TemplatesEndpointMerger implements EndpointResponseMerger {
|
||||||
return TemplatesEntity.class;
|
return TemplatesEntity.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Set<TemplateDTO> getDtos(final TemplatesEntity entity) {
|
protected Set<TemplateEntity> getDtos(final TemplatesEntity entity) {
|
||||||
return entity.getTemplates();
|
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
|
// 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
|
// 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.
|
// all of the nodes, we are left with a Map whose contents are those Templates known by all nodes.
|
||||||
Map<String, TemplateDTO> templatesById = null;
|
Map<String, TemplateEntity> templatesById = null;
|
||||||
for (final NodeResponse nodeResponse : successfulResponses) {
|
for (final NodeResponse nodeResponse : successfulResponses) {
|
||||||
final TemplatesEntity entity = nodeResponse == clientResponse ? responseEntity : nodeResponse.getClientResponse().getEntity(TemplatesEntity.class);
|
final TemplatesEntity entity = nodeResponse == clientResponse ? responseEntity : nodeResponse.getClientResponse().getEntity(TemplatesEntity.class);
|
||||||
final Set<TemplateDTO> templateDtos = entity.getTemplates();
|
final Set<TemplateEntity> templateEntities = entity.getTemplates();
|
||||||
final Map<String, TemplateDTO> nodeTemplatesById = templateDtos.stream().collect(Collectors.toMap(dto -> dto.getId(), dto -> dto));
|
final Map<String, TemplateEntity> nodeTemplatesById = templateEntities.stream().collect(Collectors.toMap(ent -> ent.getId(), ent -> ent));
|
||||||
|
|
||||||
if (templatesById == null) {
|
if (templatesById == null) {
|
||||||
// Create new HashMap so that the map that we have is modifiable.
|
// Create new HashMap so that the map that we have is modifiable.
|
||||||
|
|
Loading…
Reference in New Issue