use of org.apache.nifi.web.api.entity.ReportingTaskEntity in project nifi by apache.
the class ReportingTaskEntityMerger method mergeComponents.
/**
* Merges the ReportingTaskEntity responses.
*
* @param clientEntity the entity being returned to the client
* @param entityMap all node responses
*/
public void mergeComponents(final ReportingTaskEntity clientEntity, final Map<NodeIdentifier, ReportingTaskEntity> entityMap) {
final ReportingTaskDTO clientDto = clientEntity.getComponent();
final Map<NodeIdentifier, ReportingTaskDTO> dtoMap = new HashMap<>();
for (final Map.Entry<NodeIdentifier, ReportingTaskEntity> entry : entityMap.entrySet()) {
final ReportingTaskEntity nodeReportingTaskEntity = entry.getValue();
final ReportingTaskDTO nodeReportingTaskDto = nodeReportingTaskEntity.getComponent();
dtoMap.put(entry.getKey(), nodeReportingTaskDto);
}
mergeDtos(clientDto, dtoMap);
}
use of org.apache.nifi.web.api.entity.ReportingTaskEntity 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.ReportingTaskEntity in project kylo by Teradata.
the class NiFiReportingTaskRestClientV1 method toReportingTaskEntity.
private ReportingTaskEntity toReportingTaskEntity(ReportingTaskDTO reportingTask, Long versionId) {
ReportingTaskEntity entity = new ReportingTaskEntity();
entity.setComponent(reportingTask);
final RevisionDTO revision = new RevisionDTO();
revision.setVersion(versionId);
entity.setRevision(revision);
return entity;
}
use of org.apache.nifi.web.api.entity.ReportingTaskEntity in project nifi by apache.
the class StandardNiFiServiceFacade method createReportingTask.
@Override
public ReportingTaskEntity createReportingTask(final Revision revision, final ReportingTaskDTO reportingTaskDTO) {
final NiFiUser user = NiFiUserUtils.getNiFiUser();
// request claim for component to be created... revision already verified (version == 0)
final RevisionClaim claim = new StandardRevisionClaim(revision);
// update revision through revision manager
final RevisionUpdate<ReportingTaskDTO> snapshot = revisionManager.updateRevision(claim, user, () -> {
// create the reporting task
final ReportingTaskNode reportingTask = reportingTaskDAO.createReportingTask(reportingTaskDTO);
// save the update
controllerFacade.save();
final ReportingTaskDTO dto = dtoFactory.createReportingTaskDto(reportingTask);
final FlowModification lastMod = new FlowModification(revision.incrementRevision(revision.getClientId()), user.getIdentity());
return new StandardRevisionUpdate<>(dto, lastMod);
});
final ReportingTaskNode reportingTask = reportingTaskDAO.getReportingTask(reportingTaskDTO.getId());
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(reportingTask);
final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(reportingTask.getIdentifier()));
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);
}
use of org.apache.nifi.web.api.entity.ReportingTaskEntity 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