use of com.infiniteautomation.mango.rest.v2.exception.InvalidRQLRestException in project ma-modules-public by infiniteautomation.
the class EventsRestController method acknowledgeManyEvents.
@ApiOperation(value = "Acknowledge many existing events", notes = "")
@RequestMapping(method = RequestMethod.POST, consumes = { "application/json" }, produces = { "application/json" }, value = "/acknowledge")
public ResponseEntity<EventAcknowledgeQueryStream> acknowledgeManyEvents(@RequestBody(required = false) TranslatableMessageModel message, UriComponentsBuilder builder, HttpServletRequest request) {
RestProcessResult<EventAcknowledgeQueryStream> result = new RestProcessResult<EventAcknowledgeQueryStream>(HttpStatus.OK);
User user = this.checkUser(request, result);
if (result.isOk()) {
// Parse the RQL Query
ASTNode query;
try {
query = parseRQLtoAST(request.getQueryString());
query = addAndRestriction(query, new ASTNode("eq", "userId", user.getId()));
TranslatableMessage tlm = null;
if (message != null)
tlm = new TranslatableMessage(message.getKey(), message.getArgs().toArray());
// Perform the query and stream through acknowledger
EventAcknowledgeQueryStreamCallback callback = new EventAcknowledgeQueryStreamCallback(user, tlm);
EventAcknowledgeQueryStream stream = new EventAcknowledgeQueryStream(dao, this, query, callback);
// Ensure its ready
stream.setupQuery();
return result.createResponseEntity(stream);
} catch (InvalidRQLRestException e) {
LOG.error(e.getMessage(), e);
result.addRestMessage(getInternalServerErrorMessage(e.getMessage()));
return result.createResponseEntity();
}
}
// Not logged in
return result.createResponseEntity();
}
Aggregations