Search in sources :

Example 1 with Parameter

use of org.opennms.netmgt.config.notifications.Parameter in project opennms by OpenNMS.

the class NotificationManager method replaceNotification.

/**
     * <p>replaceNotification</p>
     *
     * @param oldName a {@link java.lang.String} object.
     * @param newNotice a {@link org.opennms.netmgt.config.notifications.Notification} object.
     * @throws java.io.IOException if any.
     * @throws java.lang.ClassNotFoundException if any.
     */
public synchronized void replaceNotification(final String oldName, final Notification newNotice) throws IOException, ClassNotFoundException {
    //   In order to preserve the order of the notices, we have to replace "in place".
    Notification notice = getNotification(oldName);
    if (notice != null) {
        notice.setWriteable(newNotice.getWriteable());
        notice.setName(newNotice.getName());
        notice.setDescription(newNotice.getDescription().orElse(null));
        notice.setUei(newNotice.getUei());
        notice.setRule(newNotice.getRule());
        notice.setDestinationPath(newNotice.getDestinationPath());
        notice.setNoticeQueue(newNotice.getNoticeQueue().orElse(null));
        notice.setTextMessage(newNotice.getTextMessage());
        notice.setSubject(newNotice.getSubject().orElse(null));
        notice.setNumericMessage(newNotice.getNumericMessage().orElse(null));
        notice.setStatus(newNotice.getStatus());
        notice.setVarbind(newNotice.getVarbind());
        // Required to avoid NMS-5948
        notice.getParameters().clear();
        for (Parameter parameter : newNotice.getParameters()) {
            Parameter newParam = new Parameter();
            newParam.setName(parameter.getName());
            newParam.setValue(parameter.getValue());
            notice.addParameter(newParam);
        }
        saveCurrent();
    } else
        addNotification(newNotice);
}
Also used : Parameter(org.opennms.netmgt.config.notifications.Parameter) Notification(org.opennms.netmgt.config.notifications.Notification)

Example 2 with Parameter

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

Aggregations

Notification (org.opennms.netmgt.config.notifications.Notification)2 Parameter (org.opennms.netmgt.config.notifications.Parameter)2