use of org.apache.nifi.web.api.entity.InputPortsEntity in project nifi by apache.
the class InputPortsEndpointMerger method merge.
@Override
public final NodeResponse merge(final URI uri, final String method, final Set<NodeResponse> successfulResponses, final Set<NodeResponse> problematicResponses, final NodeResponse clientResponse) {
if (!canHandle(uri, method)) {
throw new IllegalArgumentException("Cannot use Endpoint Mapper of type " + getClass().getSimpleName() + " to map responses for URI " + uri + ", HTTP Method " + method);
}
final InputPortsEntity responseEntity = clientResponse.getClientResponse().readEntity(InputPortsEntity.class);
final Set<PortEntity> portEntities = responseEntity.getInputPorts();
final Map<String, Map<NodeIdentifier, PortEntity>> entityMap = new HashMap<>();
for (final NodeResponse nodeResponse : successfulResponses) {
final InputPortsEntity nodeResponseEntity = nodeResponse == clientResponse ? responseEntity : nodeResponse.getClientResponse().readEntity(InputPortsEntity.class);
final Set<PortEntity> nodePortEntities = nodeResponseEntity.getInputPorts();
for (final PortEntity nodePortEntity : nodePortEntities) {
final NodeIdentifier nodeId = nodeResponse.getNodeId();
Map<NodeIdentifier, PortEntity> innerMap = entityMap.get(nodeId);
if (innerMap == null) {
innerMap = new HashMap<>();
entityMap.put(nodePortEntity.getId(), innerMap);
}
innerMap.put(nodeResponse.getNodeId(), nodePortEntity);
}
}
PortsEntityMerger.mergePorts(portEntities, entityMap);
// create a new client response
return new NodeResponse(clientResponse, responseEntity);
}
use of org.apache.nifi.web.api.entity.InputPortsEntity in project nifi by apache.
the class ProcessGroupResource method getInputPorts.
/**
* Retrieves all the of input ports in this NiFi.
*
* @return A inputPortsEntity.
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/input-ports")
@ApiOperation(value = "Gets all input ports", response = InputPortsEntity.class, authorizations = { @Authorization(value = "Read - /process-groups/{uuid}") })
@ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") })
public Response getInputPorts(@ApiParam(value = "The process group id.", required = true) @PathParam("id") final String groupId) {
if (isReplicateRequest()) {
return replicate(HttpMethod.GET);
}
// authorize access
serviceFacade.authorizeAccess(lookup -> {
final Authorizable processGroup = lookup.getProcessGroup(groupId).getAuthorizable();
processGroup.authorize(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser());
});
// get all the input ports
final Set<PortEntity> inputPorts = serviceFacade.getInputPorts(groupId);
final InputPortsEntity entity = new InputPortsEntity();
entity.setInputPorts(inputPortResource.populateRemainingInputPortEntitiesContent(inputPorts));
// generate the response
return generateOkResponse(entity).build();
}
Aggregations