use of org.apache.nifi.web.api.entity.ConnectionsEntity in project nifi by apache.
the class ProcessGroupResource method getConnections.
/**
* Gets all the connections.
*
* @return A connectionsEntity.
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/connections")
@ApiOperation(value = "Gets all connections", response = ConnectionsEntity.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 getConnections(@ApiParam(value = "The process group id.", required = true) @PathParam("id") 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());
});
// all of the relationships for the specified source processor
Set<ConnectionEntity> connections = serviceFacade.getConnections(groupId);
// create the client response entity
ConnectionsEntity entity = new ConnectionsEntity();
entity.setConnections(connectionResource.populateRemainingConnectionEntitiesContent(connections));
// generate the response
return generateOkResponse(entity).build();
}
use of org.apache.nifi.web.api.entity.ConnectionsEntity in project nifi by apache.
the class ConnectionsEndpointMerger 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 ConnectionsEntity responseEntity = clientResponse.getClientResponse().readEntity(ConnectionsEntity.class);
final Set<ConnectionEntity> connectionEntities = responseEntity.getConnections();
final Map<String, Map<NodeIdentifier, ConnectionEntity>> entityMap = new HashMap<>();
for (final NodeResponse nodeResponse : successfulResponses) {
final ConnectionsEntity nodeResponseEntity = nodeResponse == clientResponse ? responseEntity : nodeResponse.getClientResponse().readEntity(ConnectionsEntity.class);
final Set<ConnectionEntity> nodeConnectionEntities = nodeResponseEntity.getConnections();
for (final ConnectionEntity nodeConnectionEntity : nodeConnectionEntities) {
final String nodeConnectionEntityId = nodeConnectionEntity.getId();
Map<NodeIdentifier, ConnectionEntity> innerMap = entityMap.get(nodeConnectionEntityId);
if (innerMap == null) {
innerMap = new HashMap<>();
entityMap.put(nodeConnectionEntityId, innerMap);
}
innerMap.put(nodeResponse.getNodeId(), nodeConnectionEntity);
}
}
ConnectionsEntityMerger.mergeConnections(connectionEntities, entityMap);
// create a new client response
return new NodeResponse(clientResponse, responseEntity);
}
Aggregations