use of org.opennms.netmgt.config.notifications.Notification in project opennms by OpenNMS.
the class ChooseUeisController method handleRequestInternal.
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
// Pull the notice from the session
HttpSession session = request.getSession(true);
Notification newNotice = (Notification) session.getAttribute("newNotice");
// If the notice is not present in the session, redirect to the first page of the wizard
if (newNotice == null) {
return new ModelAndView(new RedirectView(NotificationWizardServlet.SOURCE_PAGE_NOTICES));
}
return new ModelAndView("/admin/notification/noticeWizard/chooseUeis", "model", createModel(newNotice));
}
use of org.opennms.netmgt.config.notifications.Notification in project opennms by OpenNMS.
the class NotificationWizardServlet method processUeis.
private String processUeis(final HttpServletRequest request, final HttpSession user) {
final Notification newNotice = (Notification) user.getAttribute("newNotice");
newNotice.setUei(request.getParameter("uei"));
final Map<String, Object> params = new HashMap<String, Object>();
params.put("newRule", toSingleQuote(newNotice.getRule()));
return SOURCE_PAGE_RULE + makeQueryString(params);
}
use of org.opennms.netmgt.config.notifications.Notification in project opennms by OpenNMS.
the class NotificationWizardServlet method processPath.
private String processPath(final HttpServletRequest request, final HttpSession user) throws ServletException {
final Notification newNotice = (Notification) user.getAttribute("newNotice");
newNotice.setDestinationPath(request.getParameter("path"));
final String description = request.getParameter("description");
if (description != null && !description.trim().equals("")) {
newNotice.setDescription(description);
} else {
newNotice.setDescription(null);
}
newNotice.setTextMessage(request.getParameter("textMsg"));
final String subject = request.getParameter("subject");
if (subject != null && !subject.trim().equals("")) {
newNotice.setSubject(subject);
} else {
newNotice.setSubject(null);
}
final String numMessage = request.getParameter("numMsg");
if (numMessage != null && !numMessage.trim().equals("")) {
newNotice.setNumericMessage(numMessage);
} else {
newNotice.setNumericMessage(null);
}
final String oldName = newNotice.getName();
newNotice.setName(request.getParameter("name"));
final String varbindName = request.getParameter("varbindName");
final String varbindValue = request.getParameter("varbindValue");
Varbind varbind = newNotice.getVarbind();
if (varbindName != null && !varbindName.trim().equals("") && varbindValue != null && !varbindValue.trim().equals("")) {
if (varbind == null) {
varbind = new Varbind();
newNotice.setVarbind(varbind);
}
varbind.setVbname(varbindName);
varbind.setVbvalue(varbindValue);
} else {
// Must do this to allow clearing out varbind definitions
newNotice.setVarbind(null);
}
try {
// replacing a path with a new name.
getNotificationFactory().replaceNotification(oldName, newNotice);
} catch (final Throwable t) {
throw new ServletException("Couldn't save/reload notification configuration file.", t);
}
final String suppliedReturnPage = (String) user.getAttribute("noticeWizardReturnPage");
if (suppliedReturnPage != null && !"".equals(suppliedReturnPage)) {
// Remove this attribute once we have consumed it, else the user may later
// get returned to a potentially unexpected page here
user.removeAttribute("noticeWizardReturnPage");
return suppliedReturnPage;
} else {
return SOURCE_PAGE_NOTICES;
}
}
use of org.opennms.netmgt.config.notifications.Notification in project opennms by OpenNMS.
the class NotificationWizardServlet method buildNewNotification.
private Notification buildNewNotification(final String status) {
final Notification notice = new Notification();
notice.setRule("IPADDR IPLIKE *.*.*.*");
notice.setNumericMessage("111-%noticeid%");
notice.setSubject("Notice #%noticeid%");
notice.setStatus(status);
return notice;
}
use of org.opennms.netmgt.config.notifications.Notification in project opennms by OpenNMS.
the class NotificationManagerIT method doTestNodeInterfaceServiceWithRule.
private void doTestNodeInterfaceServiceWithRule(String description, int nodeId, String intf, String svc, String rule, boolean matches) {
Notification notif = new Notification();
notif.setName("a notification");
notif.setRule(rule);
EventBuilder builder = new EventBuilder("uei.opennms.org/doNotCareAboutTheUei", "Test.Event");
builder.setNodeid(nodeId);
builder.setInterface(addr(intf));
builder.setService(svc);
assertEquals(description, matches, m_notificationManager.nodeInterfaceServiceValid(notif, builder.getEvent()));
}
Aggregations