});
if (subscriptions.size() != 1) {
return Response.status(Response.Status.NOT_FOUND).build();
}
check.setState(AlertType.ERROR);
Subscription subscription = subscriptions.iterator().next();
List<Alert> interestingAlerts = new ArrayList<Alert>();
Alert alert = new Alert()
.withTarget(check.getTarget())
.withValue(BigDecimal.valueOf(0.0))
.withWarn(check.getWarn())
.withError(check.getError())
.withFromType(AlertType.OK)
.withToType(AlertType.ERROR)
.withTimestamp(new DateTime());
interestingAlerts.add(alert);
for (NotificationService notificationService : notificationServices) {
if (notificationService.canHandle(subscription.getType())) {
try {
notificationService.sendNotification(check, subscription, interestingAlerts);
} catch (Exception e) {
LOGGER.warn("Notifying {} by {} failed.", subscription.getTarget(), subscription.getType(), e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
.entity(String.format("Notifying failed '%s'", e.getMessage())).type(MediaType.TEXT_PLAIN).build();
}
}
}