mirror of https://github.com/apache/nifi.git
NIFI-2488 Wrapping ActionDTO and BulletinDTO in entities to be able to provide readability permission to the client
This commit is contained in:
parent
d4bbd647c5
commit
08735a4f57
|
@ -23,6 +23,7 @@ import java.util.List;
|
|||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
import org.apache.nifi.web.api.dto.util.TimeAdapter;
|
||||
import org.apache.nifi.web.api.entity.BulletinEntity;
|
||||
|
||||
/**
|
||||
* The contents for the bulletin board including the bulletins and the timestamp when the board was generated.
|
||||
|
@ -30,7 +31,7 @@ import org.apache.nifi.web.api.dto.util.TimeAdapter;
|
|||
@XmlType(name = "bulletinBoard")
|
||||
public class BulletinBoardDTO {
|
||||
|
||||
private List<BulletinDTO> bulletins;
|
||||
private List<BulletinEntity> bulletins;
|
||||
private Date generated;
|
||||
|
||||
/**
|
||||
|
@ -39,11 +40,11 @@ public class BulletinBoardDTO {
|
|||
@ApiModelProperty(
|
||||
value = "The bulletins in the bulletin board, that matches the supplied request."
|
||||
)
|
||||
public List<BulletinDTO> getBulletins() {
|
||||
public List<BulletinEntity> getBulletins() {
|
||||
return bulletins;
|
||||
}
|
||||
|
||||
public void setBulletins(List<BulletinDTO> bulletins) {
|
||||
public void setBulletins(List<BulletinEntity> bulletins) {
|
||||
this.bulletins = bulletins;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,11 @@
|
|||
package org.apache.nifi.web.api.dto;
|
||||
|
||||
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||
import java.util.Date;
|
||||
import org.apache.nifi.web.api.dto.util.TimeAdapter;
|
||||
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
import org.apache.nifi.web.api.dto.util.TimeAdapter;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* A bulletin that represents a notification about a passing event including, the source component (if applicable), the timestamp, the message, and where the bulletin originated (if applicable).
|
||||
|
@ -56,7 +57,7 @@ public class BulletinDTO {
|
|||
* @return When clustered, the address of the node from which this bulletin originated
|
||||
*/
|
||||
@ApiModelProperty(
|
||||
value = "If clustered, the address of the node from whicih the bulletin originated."
|
||||
value = "If clustered, the address of the node from which the bulletin originated."
|
||||
)
|
||||
public String getNodeAddress() {
|
||||
return nodeAddress;
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.Date;
|
|||
import javax.xml.bind.annotation.XmlType;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
import org.apache.nifi.web.api.dto.util.TimeAdapter;
|
||||
import org.apache.nifi.web.api.entity.ActionEntity;
|
||||
|
||||
/**
|
||||
* NiFi action history.
|
||||
|
@ -31,7 +32,7 @@ public class HistoryDTO {
|
|||
|
||||
private Integer total;
|
||||
private Date lastRefreshed;
|
||||
private Collection<ActionDTO> actions;
|
||||
private Collection<ActionEntity> actions;
|
||||
|
||||
/**
|
||||
* @return total number of actions
|
||||
|
@ -68,11 +69,11 @@ public class HistoryDTO {
|
|||
@ApiModelProperty(
|
||||
value = "The actions."
|
||||
)
|
||||
public Collection<ActionDTO> getActions() {
|
||||
public Collection<ActionEntity> getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
public void setActions(Collection<ActionDTO> actions) {
|
||||
public void setActions(Collection<ActionEntity> actions) {
|
||||
this.actions = actions;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,13 +17,24 @@
|
|||
package org.apache.nifi.web.api.entity;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||
|
||||
import org.apache.nifi.web.api.dto.ReadablePermission;
|
||||
import org.apache.nifi.web.api.dto.action.ActionDTO;
|
||||
import org.apache.nifi.web.api.dto.util.DateTimeAdapter;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to an ActionDTO.
|
||||
*/
|
||||
@XmlRootElement(name = "actionEntity")
|
||||
public class ActionEntity extends Entity {
|
||||
public class ActionEntity extends Entity implements ReadablePermission {
|
||||
|
||||
private Integer id;
|
||||
private Date timestamp;
|
||||
private String sourceId;
|
||||
private Boolean canRead;
|
||||
|
||||
private ActionDTO action;
|
||||
|
||||
|
@ -40,4 +51,47 @@ public class ActionEntity extends Entity {
|
|||
this.action = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The action ID.
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The timestamp of the action.
|
||||
*/
|
||||
@XmlJavaTypeAdapter(DateTimeAdapter.class)
|
||||
public Date getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(Date timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The id of the source component.
|
||||
*/
|
||||
public String getSourceId() {
|
||||
return sourceId;
|
||||
}
|
||||
|
||||
public void setSourceId(String sourceId) {
|
||||
this.sourceId = sourceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getCanRead() {
|
||||
return canRead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCanRead(Boolean canRead) {
|
||||
this.canRead = canRead;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.nifi.web.api.entity;
|
||||
|
||||
import org.apache.nifi.web.api.dto.BulletinDTO;
|
||||
import org.apache.nifi.web.api.dto.ReadablePermission;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a BulletinDTO.
|
||||
*/
|
||||
public class BulletinEntity extends Entity implements ReadablePermission {
|
||||
|
||||
private Long id;
|
||||
private String groupId;
|
||||
private String sourceId;
|
||||
private Date timestamp;
|
||||
private String nodeAddress;
|
||||
private Boolean canRead;
|
||||
|
||||
private BulletinDTO bulletin;
|
||||
|
||||
/**
|
||||
* The BulletinDTO that is being serialized.
|
||||
*
|
||||
* @return The BulletinDTO object
|
||||
*/
|
||||
public BulletinDTO getBulletin() {
|
||||
return bulletin;
|
||||
}
|
||||
|
||||
public void setBulletin(BulletinDTO bulletin) {
|
||||
this.bulletin = bulletin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The id of the bulletin.
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The group id of the source component.
|
||||
*/
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The id of the source component.
|
||||
*/
|
||||
public String getSourceId() {
|
||||
return sourceId;
|
||||
}
|
||||
|
||||
public void setSourceId(String sourceId) {
|
||||
this.sourceId = sourceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return When this bulletin was generated.
|
||||
*/
|
||||
public Date getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(Date timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return If clustered, the address of the node from which the bulletin originated.
|
||||
*/
|
||||
public String getNodeAddress() {
|
||||
return nodeAddress;
|
||||
}
|
||||
|
||||
public void setNodeAddress(String nodeAddress) {
|
||||
this.nodeAddress = nodeAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getCanRead() {
|
||||
return canRead;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCanRead(Boolean canRead) {
|
||||
this.canRead = canRead;
|
||||
}
|
||||
}
|
|
@ -17,7 +17,6 @@
|
|||
package org.apache.nifi.web.api.entity;
|
||||
|
||||
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||
import org.apache.nifi.web.api.dto.BulletinDTO;
|
||||
import org.apache.nifi.web.api.dto.PermissionsDTO;
|
||||
import org.apache.nifi.web.api.dto.PositionDTO;
|
||||
import org.apache.nifi.web.api.dto.RevisionDTO;
|
||||
|
@ -37,7 +36,7 @@ public class ComponentEntity extends Entity {
|
|||
private String uri;
|
||||
private PositionDTO position;
|
||||
private PermissionsDTO permissions;
|
||||
private List<BulletinDTO> bulletins;
|
||||
private List<BulletinEntity> bulletins;
|
||||
|
||||
/**
|
||||
* @return revision for this request/response
|
||||
|
@ -125,11 +124,11 @@ public class ComponentEntity extends Entity {
|
|||
@ApiModelProperty(
|
||||
value = "The bulletins for this component."
|
||||
)
|
||||
public List<BulletinDTO> getBulletins() {
|
||||
public List<BulletinEntity> getBulletins() {
|
||||
return bulletins;
|
||||
}
|
||||
|
||||
public void setBulletins(List<BulletinDTO> bulletins) {
|
||||
public void setBulletins(List<BulletinEntity> bulletins) {
|
||||
this.bulletins = bulletins;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.apache.nifi.web.api.entity;
|
||||
|
||||
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||
import org.apache.nifi.web.api.dto.BulletinDTO;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.ArrayList;
|
||||
|
@ -29,19 +28,19 @@ import java.util.List;
|
|||
@XmlRootElement(name = "controllerConfigurationEntity")
|
||||
public class ControllerBulletinsEntity extends Entity {
|
||||
|
||||
private List<BulletinDTO> bulletins;
|
||||
private List<BulletinDTO> controllerServiceBulletins;
|
||||
private List<BulletinDTO> reportingTaskBulletins;
|
||||
private List<BulletinEntity> bulletins;
|
||||
private List<BulletinEntity> controllerServiceBulletins;
|
||||
private List<BulletinEntity> reportingTaskBulletins;
|
||||
|
||||
/**
|
||||
* @return System bulletins to be reported to the user
|
||||
*/
|
||||
@ApiModelProperty("System level bulletins to be reported to the user.")
|
||||
public List<BulletinDTO> getBulletins() {
|
||||
public List<BulletinEntity> getBulletins() {
|
||||
return bulletins;
|
||||
}
|
||||
|
||||
public void setBulletins(List<BulletinDTO> bulletins) {
|
||||
public void setBulletins(List<BulletinEntity> bulletins) {
|
||||
this.bulletins = bulletins;
|
||||
}
|
||||
|
||||
|
@ -49,11 +48,11 @@ public class ControllerBulletinsEntity extends Entity {
|
|||
* @return Controller service bulletins to be reported to the user
|
||||
*/
|
||||
@ApiModelProperty("Controller service bulletins to be reported to the user.")
|
||||
public List<BulletinDTO> getControllerServiceBulletins() {
|
||||
public List<BulletinEntity> getControllerServiceBulletins() {
|
||||
return controllerServiceBulletins;
|
||||
}
|
||||
|
||||
public void setControllerServiceBulletins(List<BulletinDTO> controllerServiceBulletins) {
|
||||
public void setControllerServiceBulletins(List<BulletinEntity> controllerServiceBulletins) {
|
||||
this.controllerServiceBulletins = controllerServiceBulletins;
|
||||
}
|
||||
|
||||
|
@ -61,11 +60,11 @@ public class ControllerBulletinsEntity extends Entity {
|
|||
* @return Reporting task bulletins to be reported to the user
|
||||
*/
|
||||
@ApiModelProperty("Reporting task bulletins to be reported to the user.")
|
||||
public List<BulletinDTO> getReportingTaskBulletins() {
|
||||
public List<BulletinEntity> getReportingTaskBulletins() {
|
||||
return reportingTaskBulletins;
|
||||
}
|
||||
|
||||
public void setReportingTaskBulletins(List<BulletinDTO> reportingTaskBulletins) {
|
||||
public void setReportingTaskBulletins(List<BulletinEntity> reportingTaskBulletins) {
|
||||
this.reportingTaskBulletins = reportingTaskBulletins;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ import org.apache.nifi.cluster.manager.BulletinMerger;
|
|||
import org.apache.nifi.cluster.manager.NodeResponse;
|
||||
import org.apache.nifi.cluster.protocol.NodeIdentifier;
|
||||
import org.apache.nifi.web.api.dto.BulletinBoardDTO;
|
||||
import org.apache.nifi.web.api.dto.BulletinDTO;
|
||||
import org.apache.nifi.web.api.entity.BulletinBoardEntity;
|
||||
import org.apache.nifi.web.api.entity.BulletinEntity;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
|
@ -52,16 +52,16 @@ public class BulletinBoardEndpointMerger extends AbstractSingleDTOEndpoint<Bulle
|
|||
|
||||
@Override
|
||||
protected void mergeResponses(BulletinBoardDTO clientDto, Map<NodeIdentifier, BulletinBoardDTO> dtoMap, Set<NodeResponse> successfulResponses, Set<NodeResponse> problematicResponses) {
|
||||
final Map<NodeIdentifier, List<BulletinDTO>> bulletinDtos = new HashMap<>();
|
||||
final Map<NodeIdentifier, List<BulletinEntity>> bulletinEntities = new HashMap<>();
|
||||
for (final Map.Entry<NodeIdentifier, BulletinBoardDTO> entry : dtoMap.entrySet()) {
|
||||
final NodeIdentifier nodeIdentifier = entry.getKey();
|
||||
final BulletinBoardDTO boardDto = entry.getValue();
|
||||
boardDto.getBulletins().forEach(bulletin -> {
|
||||
bulletinDtos.computeIfAbsent(nodeIdentifier, nodeId -> new ArrayList<>()).add(bulletin);
|
||||
bulletinEntities.computeIfAbsent(nodeIdentifier, nodeId -> new ArrayList<>()).add(bulletin);
|
||||
});
|
||||
}
|
||||
|
||||
clientDto.setBulletins(BulletinMerger.mergeBulletins(bulletinDtos));
|
||||
clientDto.setBulletins(BulletinMerger.mergeBulletins(bulletinEntities));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.apache.nifi.cluster.coordination.http.EndpointResponseMerger;
|
|||
import org.apache.nifi.cluster.manager.BulletinMerger;
|
||||
import org.apache.nifi.cluster.manager.NodeResponse;
|
||||
import org.apache.nifi.cluster.protocol.NodeIdentifier;
|
||||
import org.apache.nifi.web.api.dto.BulletinDTO;
|
||||
import org.apache.nifi.web.api.entity.BulletinEntity;
|
||||
import org.apache.nifi.web.api.entity.ControllerBulletinsEntity;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -54,9 +54,9 @@ public class ControllerBulletinsEndpointMerger extends AbstractSingleEntityEndpo
|
|||
protected void mergeResponses(ControllerBulletinsEntity clientEntity, Map<NodeIdentifier, ControllerBulletinsEntity> entityMap,
|
||||
Set<NodeResponse> successfulResponses, Set<NodeResponse> problematicResponses) {
|
||||
|
||||
final Map<NodeIdentifier, List<BulletinDTO>> bulletinDtos = new HashMap<>();
|
||||
final Map<NodeIdentifier, List<BulletinDTO>> controllerServiceBulletinDtos = new HashMap<>();
|
||||
final Map<NodeIdentifier, List<BulletinDTO>> reportingTaskBulletinDtos = new HashMap<>();
|
||||
final Map<NodeIdentifier, List<BulletinEntity>> bulletinDtos = new HashMap<>();
|
||||
final Map<NodeIdentifier, List<BulletinEntity>> controllerServiceBulletinDtos = new HashMap<>();
|
||||
final Map<NodeIdentifier, List<BulletinEntity>> reportingTaskBulletinDtos = new HashMap<>();
|
||||
for (final Map.Entry<NodeIdentifier, ControllerBulletinsEntity> entry : entityMap.entrySet()) {
|
||||
final NodeIdentifier nodeIdentifier = entry.getKey();
|
||||
final ControllerBulletinsEntity entity = entry.getValue();
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.nifi.cluster.manager;
|
||||
|
||||
import org.apache.nifi.cluster.protocol.NodeIdentifier;
|
||||
import org.apache.nifi.web.api.dto.BulletinDTO;
|
||||
import org.apache.nifi.web.api.entity.BulletinEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -31,9 +31,9 @@ public final class BulletinMerger {
|
|||
|
||||
private BulletinMerger() {}
|
||||
|
||||
public static Comparator<BulletinDTO> BULLETIN_COMPARATOR = new Comparator<BulletinDTO>() {
|
||||
public static Comparator<BulletinEntity> BULLETIN_COMPARATOR = new Comparator<BulletinEntity>() {
|
||||
@Override
|
||||
public int compare(BulletinDTO o1, BulletinDTO o2) {
|
||||
public int compare(BulletinEntity o1, BulletinEntity o2) {
|
||||
if (o1 == null && o2 == null) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -49,19 +49,19 @@ public final class BulletinMerger {
|
|||
};
|
||||
|
||||
/**
|
||||
* Merges the validation errors.
|
||||
* Merges the bulletins.
|
||||
*
|
||||
* @param bulletins bulletins
|
||||
*/
|
||||
public static List<BulletinDTO> mergeBulletins(final Map<NodeIdentifier, List<BulletinDTO>> bulletins) {
|
||||
final List<BulletinDTO> bulletinDtos = new ArrayList<>();
|
||||
public static List<BulletinEntity> mergeBulletins(final Map<NodeIdentifier, List<BulletinEntity>> bulletins) {
|
||||
final List<BulletinEntity> bulletinDtos = new ArrayList<>();
|
||||
|
||||
for (final Map.Entry<NodeIdentifier, List<BulletinDTO>> entry : bulletins.entrySet()) {
|
||||
for (final Map.Entry<NodeIdentifier, List<BulletinEntity>> entry : bulletins.entrySet()) {
|
||||
final NodeIdentifier nodeId = entry.getKey();
|
||||
final List<BulletinDTO> nodeBulletins = entry.getValue();
|
||||
final List<BulletinEntity> nodeBulletins = entry.getValue();
|
||||
final String nodeAddress = nodeId.getApiAddress() + ":" + nodeId.getApiPort();
|
||||
|
||||
for (final BulletinDTO bulletin : nodeBulletins) {
|
||||
for (final BulletinEntity bulletin : nodeBulletins) {
|
||||
if (bulletin.getNodeAddress() == null) {
|
||||
bulletin.setNodeAddress(nodeAddress);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public final class BulletinMerger {
|
|||
}
|
||||
}
|
||||
|
||||
Collections.sort(bulletinDtos, (BulletinDTO o1, BulletinDTO o2) -> {
|
||||
Collections.sort(bulletinDtos, (BulletinEntity o1, BulletinEntity o2) -> {
|
||||
final int timeComparison = o1.getTimestamp().compareTo(o2.getTimestamp());
|
||||
if (timeComparison != 0) {
|
||||
return timeComparison;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.apache.nifi.cluster.manager;
|
||||
|
||||
import org.apache.nifi.cluster.protocol.NodeIdentifier;
|
||||
import org.apache.nifi.web.api.dto.BulletinDTO;
|
||||
import org.apache.nifi.web.api.entity.BulletinEntity;
|
||||
import org.apache.nifi.web.api.entity.ComponentEntity;
|
||||
import org.apache.nifi.web.api.entity.Permissible;
|
||||
|
||||
|
@ -47,7 +47,7 @@ public interface ComponentEntityMerger<EntityType extends ComponentEntity & Perm
|
|||
}
|
||||
|
||||
if (clientEntity.getPermissions().getCanRead()) {
|
||||
final Map<NodeIdentifier, List<BulletinDTO>> bulletinDtos = new HashMap<>();
|
||||
final Map<NodeIdentifier, List<BulletinEntity>> bulletinEntities = new HashMap<>();
|
||||
for (final Map.Entry<NodeIdentifier, ? extends ComponentEntity> entry : entityMap.entrySet()) {
|
||||
final NodeIdentifier nodeIdentifier = entry.getKey();
|
||||
final ComponentEntity entity = entry.getValue();
|
||||
|
@ -55,11 +55,11 @@ public interface ComponentEntityMerger<EntityType extends ComponentEntity & Perm
|
|||
// consider the bulletins if present and authorized
|
||||
if (entity.getBulletins() != null) {
|
||||
entity.getBulletins().forEach(bulletin -> {
|
||||
bulletinDtos.computeIfAbsent(nodeIdentifier, nodeId -> new ArrayList<>()).add(bulletin);
|
||||
bulletinEntities.computeIfAbsent(nodeIdentifier, nodeId -> new ArrayList<>()).add(bulletin);
|
||||
});
|
||||
}
|
||||
}
|
||||
clientEntity.setBulletins(BulletinMerger.mergeBulletins(bulletinDtos));
|
||||
clientEntity.setBulletins(BulletinMerger.mergeBulletins(bulletinEntities));
|
||||
|
||||
// sort the results
|
||||
Collections.sort(clientEntity.getBulletins(), BULLETIN_COMPARATOR);
|
||||
|
|
|
@ -55,7 +55,6 @@ import org.apache.nifi.web.api.dto.SystemDiagnosticsDTO;
|
|||
import org.apache.nifi.web.api.dto.TemplateDTO;
|
||||
import org.apache.nifi.web.api.dto.UserDTO;
|
||||
import org.apache.nifi.web.api.dto.UserGroupDTO;
|
||||
import org.apache.nifi.web.api.dto.action.ActionDTO;
|
||||
import org.apache.nifi.web.api.dto.action.HistoryDTO;
|
||||
import org.apache.nifi.web.api.dto.action.HistoryQueryDTO;
|
||||
import org.apache.nifi.web.api.dto.provenance.ProvenanceDTO;
|
||||
|
@ -65,6 +64,7 @@ import org.apache.nifi.web.api.dto.provenance.lineage.LineageDTO;
|
|||
import org.apache.nifi.web.api.dto.search.SearchResultsDTO;
|
||||
import org.apache.nifi.web.api.dto.status.ControllerStatusDTO;
|
||||
import org.apache.nifi.web.api.entity.AccessPolicyEntity;
|
||||
import org.apache.nifi.web.api.entity.ActionEntity;
|
||||
import org.apache.nifi.web.api.entity.ConnectionEntity;
|
||||
import org.apache.nifi.web.api.entity.ConnectionStatusEntity;
|
||||
import org.apache.nifi.web.api.entity.ControllerBulletinsEntity;
|
||||
|
@ -1492,7 +1492,7 @@ public interface NiFiServiceFacade {
|
|||
* @param actionId id
|
||||
* @return action
|
||||
*/
|
||||
ActionDTO getAction(Integer actionId);
|
||||
ActionEntity getAction(Integer actionId);
|
||||
|
||||
/**
|
||||
* Purges all actions up to the specified end date.
|
||||
|
|
|
@ -130,7 +130,6 @@ import org.apache.nifi.web.api.dto.SystemDiagnosticsDTO;
|
|||
import org.apache.nifi.web.api.dto.TemplateDTO;
|
||||
import org.apache.nifi.web.api.dto.UserDTO;
|
||||
import org.apache.nifi.web.api.dto.UserGroupDTO;
|
||||
import org.apache.nifi.web.api.dto.action.ActionDTO;
|
||||
import org.apache.nifi.web.api.dto.action.HistoryDTO;
|
||||
import org.apache.nifi.web.api.dto.action.HistoryQueryDTO;
|
||||
import org.apache.nifi.web.api.dto.flow.FlowDTO;
|
||||
|
@ -150,6 +149,8 @@ import org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO;
|
|||
import org.apache.nifi.web.api.dto.status.StatusHistoryDTO;
|
||||
import org.apache.nifi.web.api.entity.AccessPolicyEntity;
|
||||
import org.apache.nifi.web.api.entity.AccessPolicySummaryEntity;
|
||||
import org.apache.nifi.web.api.entity.ActionEntity;
|
||||
import org.apache.nifi.web.api.entity.BulletinEntity;
|
||||
import org.apache.nifi.web.api.entity.ConnectionEntity;
|
||||
import org.apache.nifi.web.api.entity.ConnectionStatusEntity;
|
||||
import org.apache.nifi.web.api.entity.ControllerBulletinsEntity;
|
||||
|
@ -545,7 +546,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processorNode);
|
||||
final ProcessorStatusDTO status = dtoFactory.createProcessorStatusDto(controllerFacade.getProcessorStatus(processorNode.getIdentifier()));
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(processorNode.getIdentifier()));
|
||||
return entityFactory.createProcessorEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createProcessorEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletinEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -667,7 +669,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(inputPortNode);
|
||||
final PortStatusDTO status = dtoFactory.createPortStatusDto(controllerFacade.getInputPortStatus(inputPortNode.getIdentifier()));
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(inputPortNode.getIdentifier()));
|
||||
return entityFactory.createPortEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createPortEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletinEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -681,7 +684,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(outputPortNode);
|
||||
final PortStatusDTO status = dtoFactory.createPortStatusDto(controllerFacade.getOutputPortStatus(outputPortNode.getIdentifier()));
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(outputPortNode.getIdentifier()));
|
||||
return entityFactory.createPortEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createPortEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletinEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -697,7 +701,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final RevisionDTO updateRevision = dtoFactory.createRevisionDTO(snapshot.getLastModification());
|
||||
final RemoteProcessGroupStatusDTO status = dtoFactory.createRemoteProcessGroupStatusDto(controllerFacade.getRemoteProcessGroupStatus(remoteProcessGroupNode.getIdentifier()));
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(remoteProcessGroupNode.getIdentifier()));
|
||||
return entityFactory.createRemoteProcessGroupEntity(snapshot.getComponent(), updateRevision, permissions, status, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createRemoteProcessGroupEntity(snapshot.getComponent(), updateRevision, permissions, status, bulletinEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -744,7 +749,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final RevisionDTO updatedRevision = dtoFactory.createRevisionDTO(snapshot.getLastModification());
|
||||
final ProcessGroupStatusDTO status = dtoFactory.createConciseProcessGroupStatusDto(controllerFacade.getProcessGroupStatus(processGroupNode.getIdentifier()));
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(processGroupNode.getIdentifier()));
|
||||
return entityFactory.createProcessGroupEntity(snapshot.getComponent(), updatedRevision, permissions, status, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createProcessGroupEntity(snapshot.getComponent(), updatedRevision, permissions, status, bulletinEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1272,7 +1278,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processor);
|
||||
final ProcessorStatusDTO status = dtoFactory.createProcessorStatusDto(controllerFacade.getProcessorStatus(processorDTO.getId()));
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(processorDTO.getId()));
|
||||
return entityFactory.createProcessorEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createProcessorEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletinEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1489,7 +1496,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(port);
|
||||
final PortStatusDTO status = dtoFactory.createPortStatusDto(controllerFacade.getInputPortStatus(port.getIdentifier()));
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(port.getIdentifier()));
|
||||
return entityFactory.createPortEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createPortEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletinEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1504,7 +1512,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(port);
|
||||
final PortStatusDTO status = dtoFactory.createPortStatusDto(controllerFacade.getOutputPortStatus(port.getIdentifier()));
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(port.getIdentifier()));
|
||||
return entityFactory.createPortEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createPortEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletinEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1519,7 +1528,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processGroup);
|
||||
final ProcessGroupStatusDTO status = dtoFactory.createConciseProcessGroupStatusDto(controllerFacade.getProcessGroupStatus(processGroup.getIdentifier()));
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(processGroup.getIdentifier()));
|
||||
return entityFactory.createProcessGroupEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createProcessGroupEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletinEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1534,7 +1544,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(remoteProcessGroup);
|
||||
final RemoteProcessGroupStatusDTO status = dtoFactory.createRemoteProcessGroupStatusDto(controllerFacade.getRemoteProcessGroupStatus(remoteProcessGroup.getIdentifier()));
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(remoteProcessGroup.getIdentifier()));
|
||||
return entityFactory.createRemoteProcessGroupEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createRemoteProcessGroupEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletinEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1689,7 +1700,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final ControllerServiceNode controllerService = controllerServiceDAO.getControllerService(controllerServiceDTO.getId());
|
||||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(controllerService);
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(controllerServiceDTO.getId()));
|
||||
return entityFactory.createControllerServiceEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createControllerServiceEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, bulletinEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1710,7 +1722,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
|
||||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(controllerService);
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(controllerServiceDTO.getId()));
|
||||
return entityFactory.createControllerServiceEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createControllerServiceEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, bulletinEntities);
|
||||
}
|
||||
|
||||
private Set<ConfiguredComponent> findAllReferencingComponents(final ControllerServiceReference reference) {
|
||||
|
@ -1904,7 +1917,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final ReportingTaskNode reportingTask = reportingTaskDAO.getReportingTask(reportingTaskDTO.getId());
|
||||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(reportingTask);
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(reportingTask.getIdentifier()));
|
||||
return entityFactory.createReportingTaskEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createReportingTaskEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, bulletinEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1918,7 +1932,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
|
||||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(reportingTask);
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(reportingTask.getIdentifier()));
|
||||
return entityFactory.createReportingTaskEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createReportingTaskEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, bulletinEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2171,10 +2186,11 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
|
||||
private ProcessorEntity createProcessorEntity(final ProcessorNode processor) {
|
||||
final RevisionDTO revision = dtoFactory.createRevisionDTO(revisionManager.getRevision(processor.getIdentifier()));
|
||||
final PermissionsDTO accessPolicy = dtoFactory.createPermissionsDto(processor);
|
||||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processor);
|
||||
final ProcessorStatusDTO status = dtoFactory.createProcessorStatusDto(controllerFacade.getProcessorStatus(processor.getIdentifier()));
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(processor.getIdentifier()));
|
||||
return entityFactory.createProcessorEntity(dtoFactory.createProcessorDto(processor), revision, accessPolicy, status, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createProcessorEntity(dtoFactory.createProcessorDto(processor), revision, permissions, status, bulletinEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2328,25 +2344,15 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
// perform the query and generate the results - iterating in reverse order since we are
|
||||
// getting the most recent results by ordering by timestamp desc above. this gets the
|
||||
// exact results we want but in reverse order
|
||||
final List<BulletinDTO> bulletins = new ArrayList<>();
|
||||
final List<BulletinEntity> bulletinEntities = new ArrayList<>();
|
||||
for (final ListIterator<Bulletin> bulletinIter = results.listIterator(results.size()); bulletinIter.hasPrevious(); ) {
|
||||
final Bulletin bulletin = bulletinIter.previous();
|
||||
|
||||
if (authorizeBulletin(bulletin)) {
|
||||
bulletins.add(dtoFactory.createBulletinDto(bulletin));
|
||||
} else {
|
||||
final BulletinDTO bulletinDTO = new BulletinDTO();
|
||||
bulletinDTO.setTimestamp(bulletin.getTimestamp());
|
||||
bulletinDTO.setId(bulletin.getId());
|
||||
bulletinDTO.setSourceId(bulletin.getSourceId());
|
||||
bulletinDTO.setGroupId(bulletin.getGroupId());
|
||||
bulletins.add(bulletinDTO);
|
||||
}
|
||||
bulletinEntities.add(entityFactory.createBulletinEntity(dtoFactory.createBulletinDto(bulletin), authorizeBulletin(bulletin)));
|
||||
}
|
||||
|
||||
// create the bulletin board
|
||||
final BulletinBoardDTO bulletinBoard = new BulletinBoardDTO();
|
||||
bulletinBoard.setBulletins(bulletins);
|
||||
bulletinBoard.setBulletins(bulletinEntities);
|
||||
bulletinBoard.setGenerated(new Date());
|
||||
return bulletinBoard;
|
||||
}
|
||||
|
@ -2458,41 +2464,46 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final ControllerBulletinsEntity controllerBulletinsEntity = new ControllerBulletinsEntity();
|
||||
|
||||
final Authorizable controllerAuthorizable = authorizableLookup.getController();
|
||||
if (controllerAuthorizable.isAuthorized(authorizer, RequestAction.READ, user)) {
|
||||
controllerBulletinsEntity.setBulletins(dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForController()));
|
||||
final boolean authorized = controllerAuthorizable.isAuthorized(authorizer, RequestAction.READ, user);
|
||||
if (authorized) {
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForController());
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, authorized)).collect(Collectors.toList());
|
||||
controllerBulletinsEntity.setBulletins(bulletinEntities);
|
||||
}
|
||||
|
||||
// get the controller service bulletins
|
||||
final BulletinQuery controllerServiceQuery = new BulletinQuery.Builder().sourceType(ComponentType.CONTROLLER_SERVICE).build();
|
||||
final List<Bulletin> allControllerServiceBulletins = bulletinRepository.findBulletins(controllerServiceQuery);
|
||||
final List<Bulletin> authorizedControllerServiceBulletins = new ArrayList<>();
|
||||
final List<BulletinEntity> authorizedControllerServiceBulletinEntities = new ArrayList<>();
|
||||
for (final Bulletin bulletin : allControllerServiceBulletins) {
|
||||
try {
|
||||
final Authorizable controllerServiceAuthorizable = authorizableLookup.getControllerService(bulletin.getSourceId()).getAuthorizable();
|
||||
if (controllerServiceAuthorizable.isAuthorized(authorizer, RequestAction.READ, user)) {
|
||||
authorizedControllerServiceBulletins.add(bulletin);
|
||||
final boolean controllerServiceAuthorized = controllerServiceAuthorizable.isAuthorized(authorizer, RequestAction.READ, user);
|
||||
if (controllerServiceAuthorized) {
|
||||
authorizedControllerServiceBulletinEntities.add(entityFactory.createBulletinEntity(dtoFactory.createBulletinDto(bulletin), controllerServiceAuthorized));
|
||||
}
|
||||
} catch (final ResourceNotFoundException e) {
|
||||
// controller service missing.. skip
|
||||
}
|
||||
}
|
||||
controllerBulletinsEntity.setControllerServiceBulletins(dtoFactory.createBulletinDtos(authorizedControllerServiceBulletins));
|
||||
controllerBulletinsEntity.setControllerServiceBulletins(authorizedControllerServiceBulletinEntities);
|
||||
|
||||
// get the reporting task bulletins
|
||||
final BulletinQuery reportingTaskQuery = new BulletinQuery.Builder().sourceType(ComponentType.REPORTING_TASK).build();
|
||||
final List<Bulletin> allReportingTaskBulletins = bulletinRepository.findBulletins(reportingTaskQuery);
|
||||
final List<Bulletin> authorizedReportingTaskBulletins = new ArrayList<>();
|
||||
final List<BulletinEntity> authorizedReportingTaskBulletinEntities = new ArrayList<>();
|
||||
for (final Bulletin bulletin : allReportingTaskBulletins) {
|
||||
try {
|
||||
final Authorizable reportingTaskAuthorizable = authorizableLookup.getReportingTask(bulletin.getSourceId()).getAuthorizable();
|
||||
if (reportingTaskAuthorizable.isAuthorized(authorizer, RequestAction.READ, user)) {
|
||||
authorizedReportingTaskBulletins.add(bulletin);
|
||||
final boolean reportingTaskAuthorizableAuthorized = reportingTaskAuthorizable.isAuthorized(authorizer, RequestAction.READ, user);
|
||||
if (reportingTaskAuthorizableAuthorized) {
|
||||
authorizedReportingTaskBulletinEntities.add(entityFactory.createBulletinEntity(dtoFactory.createBulletinDto(bulletin), reportingTaskAuthorizableAuthorized));
|
||||
}
|
||||
} catch (final ResourceNotFoundException e) {
|
||||
// reporting task missing.. skip
|
||||
}
|
||||
}
|
||||
controllerBulletinsEntity.setReportingTaskBulletins(dtoFactory.createBulletinDtos(authorizedReportingTaskBulletins));
|
||||
controllerBulletinsEntity.setReportingTaskBulletins(authorizedReportingTaskBulletinEntities);
|
||||
|
||||
return controllerBulletinsEntity;
|
||||
}
|
||||
|
@ -2646,7 +2657,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(port);
|
||||
final PortStatusDTO status = dtoFactory.createPortStatusDto(controllerFacade.getInputPortStatus(port.getIdentifier()));
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(port.getIdentifier()));
|
||||
return entityFactory.createPortEntity(dtoFactory.createPortDto(port), revision, permissions, status, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createPortEntity(dtoFactory.createPortDto(port), revision, permissions, status, bulletinEntities);
|
||||
}
|
||||
|
||||
private PortEntity createOutputPortEntity(final Port port) {
|
||||
|
@ -2654,7 +2666,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(port);
|
||||
final PortStatusDTO status = dtoFactory.createPortStatusDto(controllerFacade.getOutputPortStatus(port.getIdentifier()));
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(port.getIdentifier()));
|
||||
return entityFactory.createPortEntity(dtoFactory.createPortDto(port), revision, permissions, status, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createPortEntity(dtoFactory.createPortDto(port), revision, permissions, status, bulletinEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2677,35 +2690,26 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final RevisionDTO revision = dtoFactory.createRevisionDTO(revisionManager.getRevision(group.getIdentifier()));
|
||||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(group);
|
||||
final ProcessGroupStatusDTO status = dtoFactory.createConciseProcessGroupStatusDto(controllerFacade.getProcessGroupStatus(group.getIdentifier()));
|
||||
final List<BulletinDTO> bulletins = getProcessGroupBulletins(group);
|
||||
final List<BulletinEntity> bulletins = getProcessGroupBulletins(group);
|
||||
return entityFactory.createProcessGroupEntity(dtoFactory.createProcessGroupDto(group), revision, permissions, status, bulletins);
|
||||
}
|
||||
|
||||
private List<BulletinDTO> getProcessGroupBulletins(final ProcessGroup group) {
|
||||
private List<BulletinEntity> getProcessGroupBulletins(final ProcessGroup group) {
|
||||
final List<Bulletin> bulletins = new ArrayList<>(bulletinRepository.findBulletinsForGroupBySource(group.getIdentifier()));
|
||||
|
||||
for (final ProcessGroup descendantGroup : group.findAllProcessGroups()) {
|
||||
bulletins.addAll(bulletinRepository.findBulletinsForGroupBySource(descendantGroup.getIdentifier()));
|
||||
}
|
||||
|
||||
List<BulletinDTO> dtos = new ArrayList<>();
|
||||
List<BulletinEntity> bulletinEntities = new ArrayList<>();
|
||||
for (final Bulletin bulletin : bulletins) {
|
||||
if (authorizeBulletin(bulletin)) {
|
||||
dtos.add(dtoFactory.createBulletinDto(bulletin));
|
||||
} else {
|
||||
final BulletinDTO bulletinDTO = new BulletinDTO();
|
||||
bulletinDTO.setTimestamp(bulletin.getTimestamp());
|
||||
bulletinDTO.setId(bulletin.getId());
|
||||
bulletinDTO.setSourceId(bulletin.getSourceId());
|
||||
bulletinDTO.setGroupId(bulletin.getGroupId());
|
||||
dtos.add(bulletinDTO);
|
||||
}
|
||||
bulletinEntities.add(entityFactory.createBulletinEntity(dtoFactory.createBulletinDto(bulletin), authorizeBulletin(bulletin)));
|
||||
}
|
||||
|
||||
// sort the bulletins
|
||||
Collections.sort(dtos, new Comparator<BulletinDTO>() {
|
||||
Collections.sort(bulletinEntities, new Comparator<BulletinEntity>() {
|
||||
@Override
|
||||
public int compare(BulletinDTO o1, BulletinDTO o2) {
|
||||
public int compare(BulletinEntity o1, BulletinEntity o2) {
|
||||
if (o1 == null && o2 == null) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -2721,11 +2725,11 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
});
|
||||
|
||||
// prune the response to only include the max number of bulletins
|
||||
if (dtos.size() > BulletinRepository.MAX_BULLETINS_PER_COMPONENT) {
|
||||
dtos = dtos.subList(0, BulletinRepository.MAX_BULLETINS_PER_COMPONENT);
|
||||
if (bulletinEntities.size() > BulletinRepository.MAX_BULLETINS_PER_COMPONENT) {
|
||||
bulletinEntities = bulletinEntities.subList(0, BulletinRepository.MAX_BULLETINS_PER_COMPONENT);
|
||||
}
|
||||
|
||||
return dtos;
|
||||
return bulletinEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2741,7 +2745,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(rpg);
|
||||
final RemoteProcessGroupStatusDTO status = dtoFactory.createRemoteProcessGroupStatusDto(controllerFacade.getRemoteProcessGroupStatus(rpg.getIdentifier()));
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(rpg.getIdentifier()));
|
||||
return entityFactory.createRemoteProcessGroupEntity(dtoFactory.createRemoteProcessGroupDto(rpg), revision, permissions, status, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createRemoteProcessGroupEntity(dtoFactory.createRemoteProcessGroupDto(rpg), revision, permissions, status, bulletinEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2870,7 +2875,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final RevisionDTO revision = dtoFactory.createRevisionDTO(revisionManager.getRevision(serviceNode.getIdentifier()));
|
||||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(serviceNode);
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(serviceNode.getIdentifier()));
|
||||
return entityFactory.createControllerServiceEntity(dto, revision, permissions, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createControllerServiceEntity(dto, revision, permissions, bulletinEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2914,7 +2920,8 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
final RevisionDTO revision = dtoFactory.createRevisionDTO(revisionManager.getRevision(reportingTask.getIdentifier()));
|
||||
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(reportingTask);
|
||||
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(reportingTask.getIdentifier()));
|
||||
return entityFactory.createReportingTaskEntity(dtoFactory.createReportingTaskDto(reportingTask), revision, permissions, bulletins);
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
return entityFactory.createReportingTaskEntity(dtoFactory.createReportingTaskDto(reportingTask), revision, permissions, bulletinEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3028,19 +3035,11 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
// only retain authorized actions
|
||||
final HistoryDTO historyDto = dtoFactory.createHistoryDto(history);
|
||||
if (history.getActions() != null) {
|
||||
final List<ActionDTO> actionDtos = new ArrayList<>();
|
||||
final List<ActionEntity> actionEntities = new ArrayList<>();
|
||||
for (final Action action : history.getActions()) {
|
||||
if (authorizeAction(action)) {
|
||||
actionDtos.add(dtoFactory.createActionDto(action));
|
||||
} else {
|
||||
final ActionDTO actionDto = new ActionDTO();
|
||||
actionDto.setTimestamp(action.getTimestamp());
|
||||
actionDto.setId(action.getId());
|
||||
actionDto.setSourceId(action.getSourceId());
|
||||
actionDtos.add(actionDto);
|
||||
actionEntities.add(entityFactory.createActionEntity(dtoFactory.createActionDto(action), authorizeAction(action)));
|
||||
}
|
||||
}
|
||||
historyDto.setActions(actionDtos);
|
||||
historyDto.setActions(actionEntities);
|
||||
}
|
||||
|
||||
// create the response
|
||||
|
@ -3048,7 +3047,7 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionDTO getAction(final Integer actionId) {
|
||||
public ActionEntity getAction(final Integer actionId) {
|
||||
// get the action
|
||||
final Action action = auditService.getAction(actionId);
|
||||
|
||||
|
@ -3057,12 +3056,13 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade {
|
|||
throw new ResourceNotFoundException(String.format("Unable to find action with id '%s'.", actionId));
|
||||
}
|
||||
|
||||
if (!authorizeAction(action)) {
|
||||
final boolean authorized = authorizeAction(action);
|
||||
if (!authorized) {
|
||||
throw new AccessDeniedException("Access is denied.");
|
||||
}
|
||||
|
||||
// return the action
|
||||
return dtoFactory.createActionDto(action);
|
||||
return entityFactory.createActionEntity(dtoFactory.createActionDto(action), authorized);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -54,7 +54,6 @@ import org.apache.nifi.web.api.dto.ClusterSummaryDTO;
|
|||
import org.apache.nifi.web.api.dto.NodeDTO;
|
||||
import org.apache.nifi.web.api.dto.ProcessGroupDTO;
|
||||
import org.apache.nifi.web.api.dto.RevisionDTO;
|
||||
import org.apache.nifi.web.api.dto.action.ActionDTO;
|
||||
import org.apache.nifi.web.api.dto.action.HistoryDTO;
|
||||
import org.apache.nifi.web.api.dto.action.HistoryQueryDTO;
|
||||
import org.apache.nifi.web.api.dto.flow.FlowDTO;
|
||||
|
@ -2039,12 +2038,8 @@ public class FlowResource extends ApplicationResource {
|
|||
|
||||
// Note: History requests are not replicated throughout the cluster and are instead handled by the nodes independently
|
||||
|
||||
// get the specified action
|
||||
final ActionDTO action = serviceFacade.getAction(id.getInteger());
|
||||
|
||||
// create the response entity
|
||||
final ActionEntity entity = new ActionEntity();
|
||||
entity.setAction(action);
|
||||
// get the response entity for the specified action
|
||||
final ActionEntity entity = serviceFacade.getAction(id.getInteger());
|
||||
|
||||
// generate the response
|
||||
return generateOkResponse(entity).build();
|
||||
|
|
|
@ -141,6 +141,7 @@ import org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO;
|
|||
import org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusSnapshotDTO;
|
||||
import org.apache.nifi.web.api.entity.AccessPolicySummaryEntity;
|
||||
import org.apache.nifi.web.api.entity.AllowableValueEntity;
|
||||
import org.apache.nifi.web.api.entity.BulletinEntity;
|
||||
import org.apache.nifi.web.api.entity.ConnectionStatusSnapshotEntity;
|
||||
import org.apache.nifi.web.api.entity.FlowBreadcrumbEntity;
|
||||
import org.apache.nifi.web.api.entity.PortStatusSnapshotEntity;
|
||||
|
@ -175,6 +176,7 @@ import java.util.TreeSet;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class DtoFactory {
|
||||
|
||||
|
@ -1622,7 +1624,7 @@ public final class DtoFactory {
|
|||
}
|
||||
|
||||
public ProcessGroupFlowDTO createProcessGroupFlowDto(final ProcessGroup group, final ProcessGroupStatus groupStatus, final RevisionManager revisionManager,
|
||||
final Function<ProcessGroup, List<BulletinDTO>> getProcessGroupBulletins) {
|
||||
final Function<ProcessGroup, List<BulletinEntity>> getProcessGroupBulletins) {
|
||||
|
||||
final ProcessGroupFlowDTO dto = new ProcessGroupFlowDTO();
|
||||
dto.setId(group.getIdentifier());
|
||||
|
@ -1639,7 +1641,7 @@ public final class DtoFactory {
|
|||
}
|
||||
|
||||
public FlowDTO createFlowDto(final ProcessGroup group, final ProcessGroupStatus groupStatus, final FlowSnippetDTO snippet, final RevisionManager revisionManager,
|
||||
final Function<ProcessGroup, List<BulletinDTO>> getProcessGroupBulletins) {
|
||||
final Function<ProcessGroup, List<BulletinEntity>> getProcessGroupBulletins) {
|
||||
if (snippet == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -1676,13 +1678,14 @@ public final class DtoFactory {
|
|||
// marshal the actual port as the snippet is pruned
|
||||
final PortDTO dto = createPortDto(inputPort);
|
||||
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(inputPort.getIdentifier()));
|
||||
final PermissionsDTO accessPolicy = createPermissionsDto(inputPort);
|
||||
final PermissionsDTO permissions = createPermissionsDto(inputPort);
|
||||
final PortStatusDTO status = getComponentStatus(
|
||||
() -> groupStatus.getInputPortStatus().stream().filter(inputPortStatus -> inputPort.getIdentifier().equals(inputPortStatus.getId())).findFirst().orElse(null),
|
||||
inputPortStatus -> createPortStatusDto(inputPortStatus)
|
||||
);
|
||||
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(inputPort.getIdentifier()));
|
||||
flow.getInputPorts().add(entityFactory.createPortEntity(dto, revision, accessPolicy, status, bulletins));
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
flow.getInputPorts().add(entityFactory.createPortEntity(dto, revision, permissions, status, bulletinEntities));
|
||||
}
|
||||
|
||||
for (final PortDTO snippetOutputPort : snippet.getOutputPorts()) {
|
||||
|
@ -1691,13 +1694,14 @@ public final class DtoFactory {
|
|||
// marshal the actual port as the snippet is pruned
|
||||
final PortDTO dto = createPortDto(outputPort);
|
||||
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(outputPort.getIdentifier()));
|
||||
final PermissionsDTO accessPolicy = createPermissionsDto(outputPort);
|
||||
final PermissionsDTO permissions = createPermissionsDto(outputPort);
|
||||
final PortStatusDTO status = getComponentStatus(
|
||||
() -> groupStatus.getOutputPortStatus().stream().filter(outputPortStatus -> outputPort.getIdentifier().equals(outputPortStatus.getId())).findFirst().orElse(null),
|
||||
outputPortStatus -> createPortStatusDto(outputPortStatus)
|
||||
);
|
||||
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(outputPort.getIdentifier()));
|
||||
flow.getOutputPorts().add(entityFactory.createPortEntity(dto, revision, accessPolicy, status, bulletins));
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
flow.getOutputPorts().add(entityFactory.createPortEntity(dto, revision, permissions, status, bulletinEntities));
|
||||
}
|
||||
|
||||
for (final LabelDTO snippetLabel : snippet.getLabels()) {
|
||||
|
@ -1716,13 +1720,13 @@ public final class DtoFactory {
|
|||
// marshal the actual group as the snippet is pruned
|
||||
final ProcessGroupDTO dto = createProcessGroupDto(processGroup);
|
||||
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(processGroup.getIdentifier()));
|
||||
final PermissionsDTO accessPolicy = createPermissionsDto(processGroup);
|
||||
final PermissionsDTO permissions = createPermissionsDto(processGroup);
|
||||
final ProcessGroupStatusDTO status = getComponentStatus(
|
||||
() -> groupStatus.getProcessGroupStatus().stream().filter(processGroupStatus -> processGroup.getIdentifier().equals(processGroupStatus.getId())).findFirst().orElse(null),
|
||||
processGroupStatus -> createConciseProcessGroupStatusDto(processGroupStatus)
|
||||
);
|
||||
final List<BulletinDTO> bulletins = getProcessGroupBulletins.apply(processGroup);
|
||||
flow.getProcessGroups().add(entityFactory.createProcessGroupEntity(dto, revision, accessPolicy, status, bulletins));
|
||||
final List<BulletinEntity> bulletins = getProcessGroupBulletins.apply(processGroup);
|
||||
flow.getProcessGroups().add(entityFactory.createProcessGroupEntity(dto, revision, permissions, status, bulletins));
|
||||
}
|
||||
|
||||
for (final ProcessorDTO snippetProcessor : snippet.getProcessors()) {
|
||||
|
@ -1731,13 +1735,14 @@ public final class DtoFactory {
|
|||
// marshal the actual processor as the snippet is pruned
|
||||
final ProcessorDTO dto = createProcessorDto(processor);
|
||||
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(processor.getIdentifier()));
|
||||
final PermissionsDTO accessPolicy = createPermissionsDto(processor);
|
||||
final PermissionsDTO permissions = createPermissionsDto(processor);
|
||||
final ProcessorStatusDTO status = getComponentStatus(
|
||||
() -> groupStatus.getProcessorStatus().stream().filter(processorStatus -> processor.getIdentifier().equals(processorStatus.getId())).findFirst().orElse(null),
|
||||
processorStatus -> createProcessorStatusDto(processorStatus)
|
||||
);
|
||||
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(processor.getIdentifier()));
|
||||
flow.getProcessors().add(entityFactory.createProcessorEntity(dto, revision, accessPolicy, status, bulletins));
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
flow.getProcessors().add(entityFactory.createProcessorEntity(dto, revision, permissions, status, bulletinEntities));
|
||||
}
|
||||
|
||||
for (final RemoteProcessGroupDTO snippetRemoteProcessGroup : snippet.getRemoteProcessGroups()) {
|
||||
|
@ -1746,13 +1751,14 @@ public final class DtoFactory {
|
|||
// marshal the actual rpm as the snippet is pruned
|
||||
final RemoteProcessGroupDTO dto = createRemoteProcessGroupDto(remoteProcessGroup);
|
||||
final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(remoteProcessGroup.getIdentifier()));
|
||||
final PermissionsDTO accessPolicy = createPermissionsDto(remoteProcessGroup);
|
||||
final PermissionsDTO permissions = createPermissionsDto(remoteProcessGroup);
|
||||
final RemoteProcessGroupStatusDTO status = getComponentStatus(
|
||||
() -> groupStatus.getRemoteProcessGroupStatus().stream().filter(rpgStatus -> remoteProcessGroup.getIdentifier().equals(rpgStatus.getId())).findFirst().orElse(null),
|
||||
remoteProcessGroupStatus -> createRemoteProcessGroupStatusDto(remoteProcessGroupStatus)
|
||||
);
|
||||
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(remoteProcessGroup.getIdentifier()));
|
||||
flow.getRemoteProcessGroups().add(entityFactory.createRemoteProcessGroupEntity(dto, revision, accessPolicy, status, bulletins));
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
flow.getRemoteProcessGroups().add(entityFactory.createRemoteProcessGroupEntity(dto, revision, permissions, status, bulletinEntities));
|
||||
}
|
||||
|
||||
return flow;
|
||||
|
@ -1770,7 +1776,7 @@ public final class DtoFactory {
|
|||
}
|
||||
|
||||
public FlowDTO createFlowDto(final ProcessGroup group, final ProcessGroupStatus groupStatus, final RevisionManager revisionManager,
|
||||
final Function<ProcessGroup, List<BulletinDTO>> getProcessGroupBulletins) {
|
||||
final Function<ProcessGroup, List<BulletinEntity>> getProcessGroupBulletins) {
|
||||
final FlowDTO dto = new FlowDTO();
|
||||
|
||||
for (final ProcessorNode procNode : group.getProcessors()) {
|
||||
|
@ -1781,7 +1787,8 @@ public final class DtoFactory {
|
|||
processorStatus -> createProcessorStatusDto(processorStatus)
|
||||
);
|
||||
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(procNode.getIdentifier()));
|
||||
dto.getProcessors().add(entityFactory.createProcessorEntity(createProcessorDto(procNode), revision, permissions, status, bulletins));
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
dto.getProcessors().add(entityFactory.createProcessorEntity(createProcessorDto(procNode), revision, permissions, status, bulletinEntities));
|
||||
}
|
||||
|
||||
for (final Connection connNode : group.getConnections()) {
|
||||
|
@ -1813,7 +1820,7 @@ public final class DtoFactory {
|
|||
() -> groupStatus.getProcessGroupStatus().stream().filter(processGroupStatus -> childGroup.getIdentifier().equals(processGroupStatus.getId())).findFirst().orElse(null),
|
||||
processGroupStatus -> createConciseProcessGroupStatusDto(processGroupStatus)
|
||||
);
|
||||
final List<BulletinDTO> bulletins = getProcessGroupBulletins.apply(childGroup);
|
||||
final List<BulletinEntity> bulletins = getProcessGroupBulletins.apply(childGroup);
|
||||
dto.getProcessGroups().add(entityFactory.createProcessGroupEntity(createProcessGroupDto(childGroup), revision, permissions, status, bulletins));
|
||||
}
|
||||
|
||||
|
@ -1825,7 +1832,8 @@ public final class DtoFactory {
|
|||
remoteProcessGroupStatus -> createRemoteProcessGroupStatusDto(remoteProcessGroupStatus)
|
||||
);
|
||||
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(rpg.getIdentifier()));
|
||||
dto.getRemoteProcessGroups().add(entityFactory.createRemoteProcessGroupEntity(createRemoteProcessGroupDto(rpg), revision, permissions, status, bulletins));
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
dto.getRemoteProcessGroups().add(entityFactory.createRemoteProcessGroupEntity(createRemoteProcessGroupDto(rpg), revision, permissions, status, bulletinEntities));
|
||||
}
|
||||
|
||||
for (final Port inputPort : group.getInputPorts()) {
|
||||
|
@ -1836,7 +1844,8 @@ public final class DtoFactory {
|
|||
inputPortStatus -> createPortStatusDto(inputPortStatus)
|
||||
);
|
||||
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(inputPort.getIdentifier()));
|
||||
dto.getInputPorts().add(entityFactory.createPortEntity(createPortDto(inputPort), revision, permissions, status, bulletins));
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
dto.getInputPorts().add(entityFactory.createPortEntity(createPortDto(inputPort), revision, permissions, status, bulletinEntities));
|
||||
}
|
||||
|
||||
for (final Port outputPort : group.getOutputPorts()) {
|
||||
|
@ -1847,7 +1856,8 @@ public final class DtoFactory {
|
|||
outputPortStatus -> createPortStatusDto(outputPortStatus)
|
||||
);
|
||||
final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(outputPort.getIdentifier()));
|
||||
dto.getOutputPorts().add(entityFactory.createPortEntity(createPortDto(outputPort), revision, permissions, status, bulletins));
|
||||
final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
|
||||
dto.getOutputPorts().add(entityFactory.createPortEntity(createPortDto(outputPort), revision, permissions, status, bulletinEntities));
|
||||
}
|
||||
|
||||
return dto;
|
||||
|
@ -2069,11 +2079,11 @@ public final class DtoFactory {
|
|||
* @param bulletins bulletins
|
||||
* @return dto
|
||||
*/
|
||||
public BulletinBoardDTO createBulletinBoardDto(final List<BulletinDTO> bulletins) {
|
||||
public BulletinBoardDTO createBulletinBoardDto(final List<BulletinEntity> bulletins) {
|
||||
// sort the bulletins
|
||||
Collections.sort(bulletins, new Comparator<BulletinDTO>() {
|
||||
Collections.sort(bulletins, new Comparator<BulletinEntity>() {
|
||||
@Override
|
||||
public int compare(final BulletinDTO bulletin1, final BulletinDTO bulletin2) {
|
||||
public int compare(final BulletinEntity bulletin1, final BulletinEntity bulletin2) {
|
||||
if (bulletin1 == null && bulletin2 == null) {
|
||||
return 0;
|
||||
} else if (bulletin1 == null) {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.nifi.web.api.dto;
|
||||
|
||||
import org.apache.nifi.web.api.dto.action.ActionDTO;
|
||||
import org.apache.nifi.web.api.dto.flow.FlowBreadcrumbDTO;
|
||||
import org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO;
|
||||
import org.apache.nifi.web.api.dto.status.ConnectionStatusDTO;
|
||||
|
@ -31,7 +32,9 @@ import org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusSnapshotDTO;
|
|||
import org.apache.nifi.web.api.dto.status.StatusHistoryDTO;
|
||||
import org.apache.nifi.web.api.entity.AccessPolicyEntity;
|
||||
import org.apache.nifi.web.api.entity.AccessPolicySummaryEntity;
|
||||
import org.apache.nifi.web.api.entity.ActionEntity;
|
||||
import org.apache.nifi.web.api.entity.AllowableValueEntity;
|
||||
import org.apache.nifi.web.api.entity.BulletinEntity;
|
||||
import org.apache.nifi.web.api.entity.ConnectionEntity;
|
||||
import org.apache.nifi.web.api.entity.ConnectionStatusEntity;
|
||||
import org.apache.nifi.web.api.entity.ConnectionStatusSnapshotEntity;
|
||||
|
@ -169,7 +172,7 @@ public final class EntityFactory {
|
|||
}
|
||||
|
||||
public ProcessorEntity createProcessorEntity(final ProcessorDTO dto, final RevisionDTO revision, final PermissionsDTO permissions,
|
||||
final ProcessorStatusDTO status, final List<BulletinDTO> bulletins) {
|
||||
final ProcessorStatusDTO status, final List<BulletinEntity> bulletins) {
|
||||
|
||||
final ProcessorEntity entity = new ProcessorEntity();
|
||||
entity.setRevision(revision);
|
||||
|
@ -187,7 +190,7 @@ public final class EntityFactory {
|
|||
return entity;
|
||||
}
|
||||
|
||||
public PortEntity createPortEntity(final PortDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final PortStatusDTO status, final List<BulletinDTO> bulletins) {
|
||||
public PortEntity createPortEntity(final PortDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final PortStatusDTO status, final List<BulletinEntity> bulletins) {
|
||||
final PortEntity entity = new PortEntity();
|
||||
entity.setRevision(revision);
|
||||
if (dto != null) {
|
||||
|
@ -205,7 +208,7 @@ public final class EntityFactory {
|
|||
}
|
||||
|
||||
public ProcessGroupEntity createProcessGroupEntity(final ProcessGroupDTO dto, final RevisionDTO revision, final PermissionsDTO permissions,
|
||||
final ProcessGroupStatusDTO status, final List<BulletinDTO> bulletins) {
|
||||
final ProcessGroupStatusDTO status, final List<BulletinEntity> bulletins) {
|
||||
final ProcessGroupEntity entity = new ProcessGroupEntity();
|
||||
entity.setRevision(revision);
|
||||
if (dto != null) {
|
||||
|
@ -359,7 +362,7 @@ public final class EntityFactory {
|
|||
}
|
||||
|
||||
public RemoteProcessGroupEntity createRemoteProcessGroupEntity(final RemoteProcessGroupDTO dto, final RevisionDTO revision, final PermissionsDTO permissions,
|
||||
final RemoteProcessGroupStatusDTO status, final List<BulletinDTO> bulletins) {
|
||||
final RemoteProcessGroupStatusDTO status, final List<BulletinEntity> bulletins) {
|
||||
final RemoteProcessGroupEntity entity = new RemoteProcessGroupEntity();
|
||||
entity.setRevision(revision);
|
||||
if (dto != null) {
|
||||
|
@ -397,7 +400,7 @@ public final class EntityFactory {
|
|||
return entity;
|
||||
}
|
||||
|
||||
public ReportingTaskEntity createReportingTaskEntity(final ReportingTaskDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final List<BulletinDTO> bulletins) {
|
||||
public ReportingTaskEntity createReportingTaskEntity(final ReportingTaskDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final List<BulletinEntity> bulletins) {
|
||||
final ReportingTaskEntity entity = new ReportingTaskEntity();
|
||||
entity.setRevision(revision);
|
||||
if (dto != null) {
|
||||
|
@ -412,7 +415,7 @@ public final class EntityFactory {
|
|||
return entity;
|
||||
}
|
||||
|
||||
public ControllerServiceEntity createControllerServiceEntity(final ControllerServiceDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final List<BulletinDTO> bulletins) {
|
||||
public ControllerServiceEntity createControllerServiceEntity(final ControllerServiceDTO dto, final RevisionDTO revision, final PermissionsDTO permissions, final List<BulletinEntity> bulletins) {
|
||||
final ControllerServiceEntity entity = new ControllerServiceEntity();
|
||||
entity.setRevision(revision);
|
||||
if (dto != null) {
|
||||
|
@ -460,4 +463,34 @@ public final class EntityFactory {
|
|||
entity.setAllowableValue(dto);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public ActionEntity createActionEntity(final ActionDTO dto, final boolean canRead) {
|
||||
final ActionEntity entity = new ActionEntity();
|
||||
if (dto != null) {
|
||||
entity.setId(dto.getId());
|
||||
entity.setSourceId(dto.getSourceId());
|
||||
entity.setTimestamp(dto.getTimestamp());
|
||||
entity.setCanRead(canRead);
|
||||
if (canRead) {
|
||||
entity.setAction(dto);
|
||||
}
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
public BulletinEntity createBulletinEntity(final BulletinDTO dto, final boolean canRead) {
|
||||
final BulletinEntity entity = new BulletinEntity();
|
||||
if (dto != null) {
|
||||
entity.setId(dto.getId());
|
||||
entity.setSourceId(dto.getSourceId());
|
||||
entity.setGroupId(dto.getGroupId());
|
||||
entity.setTimestamp(dto.getTimestamp());
|
||||
entity.setNodeAddress(dto.getNodeAddress());
|
||||
entity.setCanRead(canRead);
|
||||
if (canRead) {
|
||||
entity.setBulletin(dto);
|
||||
}
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue