use of org.apache.nifi.web.api.entity.ReportingTasksEntity in project nifi by apache.
the class ReportingTasksEndpointMerger 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 ReportingTasksEntity responseEntity = clientResponse.getClientResponse().readEntity(ReportingTasksEntity.class);
final Set<ReportingTaskEntity> reportingTasksEntities = responseEntity.getReportingTasks();
final Map<String, Map<NodeIdentifier, ReportingTaskEntity>> entityMap = new HashMap<>();
for (final NodeResponse nodeResponse : successfulResponses) {
final ReportingTasksEntity nodeResponseEntity = nodeResponse == clientResponse ? responseEntity : nodeResponse.getClientResponse().readEntity(ReportingTasksEntity.class);
final Set<ReportingTaskEntity> nodeReportingTaskEntities = nodeResponseEntity.getReportingTasks();
for (final ReportingTaskEntity nodeReportingTaskEntity : nodeReportingTaskEntities) {
final NodeIdentifier nodeId = nodeResponse.getNodeId();
Map<NodeIdentifier, ReportingTaskEntity> innerMap = entityMap.get(nodeId);
if (innerMap == null) {
innerMap = new HashMap<>();
entityMap.put(nodeReportingTaskEntity.getId(), innerMap);
}
innerMap.put(nodeResponse.getNodeId(), nodeReportingTaskEntity);
}
}
ReportingTasksEntityMerger.mergeReportingTasks(reportingTasksEntities, entityMap);
// create a new client response
return new NodeResponse(clientResponse, responseEntity);
}
use of org.apache.nifi.web.api.entity.ReportingTasksEntity in project nifi by apache.
the class FlowResource method getReportingTasks.
// ---------------
// reporting-tasks
// ---------------
/**
* Retrieves all the of reporting tasks in this NiFi.
*
* @return A reportingTasksEntity.
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("reporting-tasks")
@ApiOperation(value = "Gets all reporting tasks", response = ReportingTasksEntity.class, authorizations = { @Authorization(value = "Read - /flow") })
@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 = 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 getReportingTasks() {
authorizeFlow();
if (isReplicateRequest()) {
return replicate(HttpMethod.GET);
}
// get all the reporting tasks
final Set<ReportingTaskEntity> reportingTasks = serviceFacade.getReportingTasks();
reportingTaskResource.populateRemainingReportingTaskEntitiesContent(reportingTasks);
// create the response entity
final ReportingTasksEntity entity = new ReportingTasksEntity();
entity.setReportingTasks(reportingTasks);
// generate the response
return generateOkResponse(entity).build();
}
Aggregations