use of org.graylog2.indexer.messages.DocumentNotFoundException in project graylog2-server by Graylog2.
the class MessageResource method search.
@GET
@Path("/{index}/{messageId}")
@Timed
@ApiOperation(value = "Get a single message.")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Specified index does not exist."), @ApiResponse(code = 404, message = "Message does not exist.") })
public ResultMessage search(@ApiParam(name = "index", value = "The index this message is stored in.", required = true) @PathParam("index") String index, @ApiParam(name = "messageId", required = true) @PathParam("messageId") String messageId) {
checkPermission(RestPermissions.MESSAGES_READ, messageId);
try {
final ResultMessage resultMessage = messages.get(messageId, index);
final Message message = resultMessage.getMessage();
checkMessageReadPermission(message);
return resultMessage;
} catch (IndexNotFoundException e) {
final String msg = "Index " + e.getIndex() + " does not exist.";
LOG.error(msg, e);
throw new NotFoundException(msg, e);
} catch (DocumentNotFoundException e) {
final String msg = "Message " + messageId + " does not exist in index " + index;
LOG.error(msg, e);
throw new NotFoundException(msg, e);
}
}
Aggregations