use of org.opennms.netmgt.config.notifications.Notification in project opennms by OpenNMS.
the class NotificationWizardServlet method copyNotice.
/**
*/
private Notification copyNotice(final Notification oldNotice) {
final Notification newNotice = new Notification();
newNotice.setName(oldNotice.getName());
newNotice.setWriteable(oldNotice.getWriteable());
newNotice.setDescription(oldNotice.getDescription().orElse(null));
newNotice.setUei(oldNotice.getUei());
newNotice.setRule(oldNotice.getRule());
newNotice.setDestinationPath(oldNotice.getDestinationPath());
newNotice.setNoticeQueue(oldNotice.getNoticeQueue().orElse(null));
newNotice.setTextMessage(oldNotice.getTextMessage());
newNotice.setSubject(oldNotice.getSubject().orElse(null));
newNotice.setNumericMessage(oldNotice.getNumericMessage().orElse(null));
newNotice.setStatus(oldNotice.getStatus());
newNotice.setVarbind(oldNotice.getVarbind());
for (final Parameter parameter : oldNotice.getParameters()) {
final Parameter newParam = new Parameter();
newParam.setName(parameter.getName());
newParam.setValue(parameter.getValue());
newNotice.addParameter(newParam);
}
return newNotice;
}
use of org.opennms.netmgt.config.notifications.Notification in project opennms by OpenNMS.
the class NotificationWizardServlet method edit.
/**
* Common code for two source pages that can't really be considered the same
*/
private String edit(final HttpServletRequest request, final HttpSession user) throws ServletException {
try {
final Notification oldNotice = getNotificationFactory().getNotification(request.getParameter("notice"));
user.setAttribute("newNotice", copyNotice(oldNotice));
return SOURCE_PAGE_UEIS;
} catch (final Throwable t) {
throw new ServletException("couldn't get a copy of the notification to edit.", t);
}
}
use of org.opennms.netmgt.config.notifications.Notification in project opennms by OpenNMS.
the class NotificationWizardServlet method processValidate.
private String processValidate(final HttpServletRequest request, final HttpSession user) {
final String userAction = request.getParameter("userAction");
if ("rebuild".equals(userAction)) {
final Map<String, Object> params = new HashMap<String, Object>();
params.put("newRule", request.getParameter("newRule"));
final String[] services = request.getParameterValues("services");
if (services != null) {
params.put("services", services);
}
params.put("mode", "rebuild");
return SOURCE_PAGE_RULE + makeQueryString(params);
} else {
final Notification newNotice = (Notification) user.getAttribute("newNotice");
newNotice.setRule(request.getParameter("newRule"));
return SOURCE_PAGE_PATH;
}
}
use of org.opennms.netmgt.config.notifications.Notification in project opennms by OpenNMS.
the class NotificationWizardServlet method newNotifWithUEI.
private String newNotifWithUEI(final HttpServletRequest request, final HttpSession user) {
final String uei = request.getParameter("uei");
final Notification newNotice = buildNewNotification("on");
newNotice.setUei(uei);
final Map<String, Object> params = new HashMap<String, Object>();
params.put("newRule", toSingleQuote(newNotice.getRule()));
user.setAttribute("newNotice", newNotice);
return SOURCE_PAGE_RULE + makeQueryString(params);
}
use of org.opennms.netmgt.config.notifications.Notification in project opennms by OpenNMS.
the class NotificationsConfigTest method testFormattedNotificationsXml.
@Test
public void testFormattedNotificationsXml() throws Exception {
MockUtil.println("################# Running Test ################");
MockLogAppender.setupLogging();
MockNotifdConfigManager notifdConfig = new MockNotifdConfigManager(ConfigurationTestUtils.getConfigForResourceWithReplacements(this, "notifd-configuration.xml"));
NotificationManager manager = new MockNotificationManager(notifdConfig, null, ConfigurationTestUtils.getConfigForResourceWithReplacements(this, "notifications-config-test.xml"));
Notification n = manager.getNotification("crazyTestNotification");
assertTrue(n.getTextMessage().contains("\n"));
}
Aggregations