use of org.opennms.javamail.JavaMailer in project opennms by OpenNMS.
the class JavaMailNotificationStrategy method buildMessage.
/**
* This method extracts the to, subject, and message text from the
* parameters passed in the notification.
*
* @param arguments
* @throws JavaMailerException
*/
private JavaMailer buildMessage(List<Argument> arguments) throws JavaMailerException {
JavaMailer jm = new JavaMailer();
for (int i = 0; i < arguments.size(); i++) {
Argument arg = arguments.get(i);
LOG.debug("Current arg switch: {} of {} is: {}", i, arguments.size(), arg.getSwitch());
LOG.debug("Current arg value: {} of {} is: {}", i, arguments.size(), arg.getValue());
/*
* Note: The recipient gets set by whichever of the two switches:
* (PARAM_EMAIL or PARAM_PAGER_EMAIL) are specified last in the
* notificationCommands.xml file
*
* And the message body will get set to whichever is set last
* (PARAM_NUM_MSG or PARAM_TEXT_MSG)
*/
if (NotificationManager.PARAM_EMAIL.equals(arg.getSwitch())) {
LOG.debug("Found: PARAM_EMAIL");
jm.setTo(arg.getValue());
} else if (NotificationManager.PARAM_PAGER_EMAIL.equals(arg.getSwitch())) {
LOG.debug("Found: PARAM_PAGER_EMAIL");
jm.setTo(arg.getValue());
} else if (NotificationManager.PARAM_SUBJECT.equals(arg.getSwitch())) {
LOG.debug("Found: PARAM_SUBJECT");
jm.setSubject(arg.getValue());
} else if (NotificationManager.PARAM_NUM_MSG.equals(arg.getSwitch())) {
LOG.debug("Found: PARAM_NUM_MSG");
jm.setMessageText(arg.getValue());
} else if (NotificationManager.PARAM_TEXT_MSG.equals(arg.getSwitch())) {
LOG.debug("Found: PARAM_TEXT_MSG");
jm.setMessageText(arg.getValue());
}
}
return jm;
}
Aggregations