stream = streamService.load(streamid);
} catch (org.graylog2.database.NotFoundException e) {
throw new WebApplicationException(404);
}
final AlertCondition alertCondition;
try {
alertCondition = alertService.fromRequest(ccr, stream, getCurrentUser().getName());
} catch (AbstractAlertCondition.NoSuchAlertConditionTypeException e) {
LOG.error("Invalid alarm condition type.", e);
throw new WebApplicationException(e, Response.Status.BAD_REQUEST);
}
try {
streamService.addAlertCondition(stream, alertCondition);
} catch (ValidationException e) {
LOG.error("Validation error.", e);
throw new WebApplicationException(e, Response.Status.BAD_REQUEST);
}
Map<String, Object> result = Maps.newHashMap();
result.put("alert_condition_id", alertCondition.getId());
return Response.status(Response.Status.CREATED).entity(json(result)).build();
}