Search in sources :

Example 1 with HistoryQuery

use of org.apache.nifi.history.HistoryQuery in project nifi by apache.

the class StandardNiFiServiceFacade method getActions.

@Override
public HistoryDTO getActions(final HistoryQueryDTO historyQueryDto) {
    // extract the query criteria
    final HistoryQuery historyQuery = new HistoryQuery();
    historyQuery.setStartDate(historyQueryDto.getStartDate());
    historyQuery.setEndDate(historyQueryDto.getEndDate());
    historyQuery.setSourceId(historyQueryDto.getSourceId());
    historyQuery.setUserIdentity(historyQueryDto.getUserIdentity());
    historyQuery.setOffset(historyQueryDto.getOffset());
    historyQuery.setCount(historyQueryDto.getCount());
    historyQuery.setSortColumn(historyQueryDto.getSortColumn());
    historyQuery.setSortOrder(historyQueryDto.getSortOrder());
    // perform the query
    final History history = auditService.getActions(historyQuery);
    // only retain authorized actions
    final HistoryDTO historyDto = dtoFactory.createHistoryDto(history);
    if (history.getActions() != null) {
        final List<ActionEntity> actionEntities = new ArrayList<>();
        for (final Action action : history.getActions()) {
            final AuthorizationResult result = authorizeAction(action);
            actionEntities.add(entityFactory.createActionEntity(dtoFactory.createActionDto(action), Result.Approved.equals(result.getResult())));
        }
        historyDto.setActions(actionEntities);
    }
    // create the response
    return historyDto;
}
Also used : HistoryDTO(org.apache.nifi.web.api.dto.action.HistoryDTO) PropertyHistoryDTO(org.apache.nifi.web.api.dto.PropertyHistoryDTO) ComponentHistoryDTO(org.apache.nifi.web.api.dto.ComponentHistoryDTO) StatusHistoryDTO(org.apache.nifi.web.api.dto.status.StatusHistoryDTO) FlowChangeAction(org.apache.nifi.action.FlowChangeAction) RequestAction(org.apache.nifi.authorization.RequestAction) Action(org.apache.nifi.action.Action) HistoryQuery(org.apache.nifi.history.HistoryQuery) ArrayList(java.util.ArrayList) History(org.apache.nifi.history.History) AuthorizationResult(org.apache.nifi.authorization.AuthorizationResult) ActionEntity(org.apache.nifi.web.api.entity.ActionEntity)

Example 2 with HistoryQuery

use of org.apache.nifi.history.HistoryQuery in project nifi by apache.

the class StandardAuditService method getActions.

@Override
public History getActions(int firstActionId, int maxActions) {
    final HistoryQuery query = new HistoryQuery();
    query.setOffset(firstActionId);
    query.setCount(maxActions);
    query.setSortOrder("asc");
    query.setSortColumn("timestamp");
    return getActions(query);
}
Also used : HistoryQuery(org.apache.nifi.history.HistoryQuery)

Aggregations

HistoryQuery (org.apache.nifi.history.HistoryQuery)2 ArrayList (java.util.ArrayList)1 Action (org.apache.nifi.action.Action)1 FlowChangeAction (org.apache.nifi.action.FlowChangeAction)1 AuthorizationResult (org.apache.nifi.authorization.AuthorizationResult)1 RequestAction (org.apache.nifi.authorization.RequestAction)1 History (org.apache.nifi.history.History)1 ComponentHistoryDTO (org.apache.nifi.web.api.dto.ComponentHistoryDTO)1 PropertyHistoryDTO (org.apache.nifi.web.api.dto.PropertyHistoryDTO)1 HistoryDTO (org.apache.nifi.web.api.dto.action.HistoryDTO)1 StatusHistoryDTO (org.apache.nifi.web.api.dto.status.StatusHistoryDTO)1 ActionEntity (org.apache.nifi.web.api.entity.ActionEntity)1