if (alertNotifications != null && alertNotifications.size() > 0) {
AlertSenderPluginManager alertSenderPluginManager = getAlertPluginManager();
for (AlertNotification alertNotification : alertNotifications) {
try {
AlertNotificationLog notificationLog = null;
String senderName = alertNotification.getSenderName();
if (alertSenderPluginManager == null) {
notificationLog = new AlertNotificationLog(alert, senderName, ResultState.FAILURE,
"Notification was not sent as alert sender plugins are not yet initialized ");
} else if (senderName == null) {
notificationLog = new AlertNotificationLog(alert, senderName, ResultState.FAILURE,
"Sender '" + senderName + "' is not defined");
} else {
AlertSender<?> notificationSender = alertSenderPluginManager
.getAlertSenderForNotification(alertNotification);
if (notificationSender == null) {
notificationLog = new AlertNotificationLog(alert, senderName, ResultState.FAILURE,
"Failed to obtain a sender with given name");
} else {
try {
SenderResult result = notificationSender.send(alert);
if (log.isDebugEnabled()) {
log.debug(result);
}
if (result == null) {
notificationLog = new AlertNotificationLog(alert, senderName,
ResultState.UNKNOWN, "Sender did not return any result");
} else {
notificationLog = new AlertNotificationLog(alert, senderName, result);
}
} catch (Throwable t) {
log.error("Notification processing terminated abruptly" + t.getMessage());
notificationLog = new AlertNotificationLog(alert, senderName, ResultState.FAILURE,
"Notification processing terminated abruptly, cause: " + t.getMessage());
}
}
}