Search in sources :

Example 1 with Varbind

use of org.opennms.netmgt.config.notifications.Varbind 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;
    }
}
Also used : ServletException(javax.servlet.ServletException) Varbind(org.opennms.netmgt.config.notifications.Varbind) Notification(org.opennms.netmgt.config.notifications.Notification)

Aggregations

ServletException (javax.servlet.ServletException)1 Notification (org.opennms.netmgt.config.notifications.Notification)1 Varbind (org.opennms.netmgt.config.notifications.Varbind)1