use of org.apache.nifi.web.api.entity.FunnelsEntity in project nifi by apache.
the class ProcessGroupResource method getFunnels.
/**
* Retrieves all the of funnels in this NiFi.
*
* @return A funnelsEntity.
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/funnels")
@ApiOperation(value = "Gets all funnels", response = FunnelsEntity.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 getFunnels(@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 funnels
final Set<FunnelEntity> funnels = serviceFacade.getFunnels(groupId);
// create the response entity
final FunnelsEntity entity = new FunnelsEntity();
entity.setFunnels(funnelResource.populateRemainingFunnelEntitiesContent(funnels));
// generate the response
return generateOkResponse(entity).build();
}
use of org.apache.nifi.web.api.entity.FunnelsEntity in project nifi by apache.
the class FunnelsEndpointMerger method merge.
@Override
public NodeResponse merge(URI uri, String method, Set<NodeResponse> successfulResponses, Set<NodeResponse> problematicResponses, 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 FunnelsEntity responseEntity = clientResponse.getClientResponse().readEntity(FunnelsEntity.class);
final Set<FunnelEntity> funnelEntities = responseEntity.getFunnels();
final Map<String, Map<NodeIdentifier, FunnelEntity>> entityMap = new HashMap<>();
for (final NodeResponse nodeResponse : successfulResponses) {
final FunnelsEntity nodeResponseEntity = nodeResponse == clientResponse ? responseEntity : nodeResponse.getClientResponse().readEntity(FunnelsEntity.class);
final Set<FunnelEntity> nodeFunnelEntities = nodeResponseEntity.getFunnels();
for (final FunnelEntity nodeFunnelEntity : nodeFunnelEntities) {
final String nodeFunnelEntityId = nodeFunnelEntity.getId();
Map<NodeIdentifier, FunnelEntity> innerMap = entityMap.get(nodeFunnelEntityId);
if (innerMap == null) {
innerMap = new HashMap<>();
entityMap.put(nodeFunnelEntityId, innerMap);
}
innerMap.put(nodeResponse.getNodeId(), nodeFunnelEntity);
}
}
FunnelsEntityMerger.mergeFunnels(funnelEntities, entityMap);
// create a new client response
return new NodeResponse(clientResponse, responseEntity);
}
Aggregations