use of org.apache.nifi.web.api.dto.BulletinBoardDTO in project nifi by apache.
the class StandardNiFiServiceFacade method getBulletinBoard.
@Override
public BulletinBoardDTO getBulletinBoard(final BulletinQueryDTO query) {
// build the query
final BulletinQuery.Builder queryBuilder = new BulletinQuery.Builder().groupIdMatches(query.getGroupId()).sourceIdMatches(query.getSourceId()).nameMatches(query.getName()).messageMatches(query.getMessage()).after(query.getAfter()).limit(query.getLimit());
// perform the query
final List<Bulletin> results = bulletinRepository.findBulletins(queryBuilder.build());
// perform the query and generate the results - iterating in reverse order since we are
// getting the most recent results by ordering by timestamp desc above. this gets the
// exact results we want but in reverse order
final List<BulletinEntity> bulletinEntities = new ArrayList<>();
for (final ListIterator<Bulletin> bulletinIter = results.listIterator(results.size()); bulletinIter.hasPrevious(); ) {
final Bulletin bulletin = bulletinIter.previous();
bulletinEntities.add(entityFactory.createBulletinEntity(dtoFactory.createBulletinDto(bulletin), authorizeBulletin(bulletin)));
}
// create the bulletin board
final BulletinBoardDTO bulletinBoard = new BulletinBoardDTO();
bulletinBoard.setBulletins(bulletinEntities);
bulletinBoard.setGenerated(new Date());
return bulletinBoard;
}
use of org.apache.nifi.web.api.dto.BulletinBoardDTO in project nifi by apache.
the class FlowResource method getBulletinBoard.
// --------------
// bulletin board
// --------------
/**
* Retrieves all the of bulletins in this NiFi.
*
* @param after Supporting querying for bulletins after a particular
* bulletin id.
* @param limit The max number of bulletins to return.
* @param sourceName Source name filter. Supports a regular expression.
* @param message Message filter. Supports a regular expression.
* @param sourceId Source id filter. Supports a regular expression.
* @param groupId Group id filter. Supports a regular expression.
* @return A bulletinBoardEntity.
* @throws InterruptedException if interrupted
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("bulletin-board")
@ApiOperation(value = "Gets current bulletins", response = BulletinBoardEntity.class, authorizations = { @Authorization(value = "Read - /flow"), @Authorization(value = "Read - /{component-type}/{uuid} - For component specific bulletins") })
@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 getBulletinBoard(@ApiParam(value = "Includes bulletins with an id after this value.", required = false) @QueryParam("after") LongParameter after, @ApiParam(value = "Includes bulletins originating from this sources whose name match this regular expression.", required = false) @QueryParam("sourceName") BulletinBoardPatternParameter sourceName, @ApiParam(value = "Includes bulletins whose message that match this regular expression.", required = false) @QueryParam("message") BulletinBoardPatternParameter message, @ApiParam(value = "Includes bulletins originating from this sources whose id match this regular expression.", required = false) @QueryParam("sourceId") BulletinBoardPatternParameter sourceId, @ApiParam(value = "Includes bulletins originating from this sources whose group id match this regular expression.", required = false) @QueryParam("groupId") BulletinBoardPatternParameter groupId, @ApiParam(value = "The number of bulletins to limit the response to.", required = false) @QueryParam("limit") IntegerParameter limit) throws InterruptedException {
authorizeFlow();
// replicate if cluster manager
if (isReplicateRequest()) {
return replicate(HttpMethod.GET);
}
// build the bulletin query
final BulletinQueryDTO query = new BulletinQueryDTO();
if (sourceId != null) {
query.setSourceId(sourceId.getRawPattern());
}
if (groupId != null) {
query.setGroupId(groupId.getRawPattern());
}
if (sourceName != null) {
query.setName(sourceName.getRawPattern());
}
if (message != null) {
query.setMessage(message.getRawPattern());
}
if (after != null) {
query.setAfter(after.getLong());
}
if (limit != null) {
query.setLimit(limit.getInteger());
}
// get the bulletin board
final BulletinBoardDTO bulletinBoard = serviceFacade.getBulletinBoard(query);
// create the response entity
BulletinBoardEntity entity = new BulletinBoardEntity();
entity.setBulletinBoard(bulletinBoard);
// generate the response
return generateOkResponse(entity).build();
}
use of org.apache.nifi.web.api.dto.BulletinBoardDTO in project nifi by apache.
the class BulletinBoardEndpointMerger method mergeResponses.
@Override
protected void mergeResponses(BulletinBoardDTO clientDto, Map<NodeIdentifier, BulletinBoardDTO> dtoMap, Set<NodeResponse> successfulResponses, Set<NodeResponse> problematicResponses) {
final Map<NodeIdentifier, List<BulletinEntity>> bulletinEntities = new HashMap<>();
for (final Map.Entry<NodeIdentifier, BulletinBoardDTO> entry : dtoMap.entrySet()) {
final NodeIdentifier nodeIdentifier = entry.getKey();
final BulletinBoardDTO boardDto = entry.getValue();
boardDto.getBulletins().forEach(bulletin -> {
bulletinEntities.computeIfAbsent(nodeIdentifier, nodeId -> new ArrayList<>()).add(bulletin);
});
}
clientDto.setBulletins(BulletinMerger.mergeBulletins(bulletinEntities, dtoMap.size()));
}
Aggregations