/** * replaceNotification * * @param oldName a {@link java.lang.String} object. * @param newNotice a {@link org.opennms.netmgt.config.notifications.Notification} object. * @throws org.exolab.castor.xml.MarshalException if any. * @throws org.exolab.castor.xml.ValidationException if any. * @throws java.io.IOException if any. * @throws java.lang.ClassNotFoundException if any. */ public synchronized void replaceNotification(final String oldName, final Notification newNotice) throws MarshalException, ValidationException, 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()); notice.setUei(newNotice.getUei()); notice.setRule(newNotice.getRule()); notice.setDestinationPath(newNotice.getDestinationPath()); notice.setNoticeQueue(newNotice.getNoticeQueue()); notice.setTextMessage(newNotice.getTextMessage()); notice.setSubject(newNotice.getSubject()); notice.setNumericMessage(newNotice.getNumericMessage()); notice.setStatus(newNotice.getStatus()); notice.setVarbind(newNotice.getVarbind()); Parameter parameters[] = newNotice.getParameter(); for (int i = 0; i < parameters.length; i++) { Parameter newParam = new Parameter(); newParam.setName(parameters[i].getName()); newParam.setValue(parameters[i].getValue()); notice.addParameter(newParam); } saveCurrent(); } else addNotification(newNotice); }
/** * Adds additional parameters defined by the user in the notificaiton configuration XML. * * @param paramMap a {@link java.util.Map} object. * @param notification a {@link org.opennms.netmgt.config.notifications.Notification} object. */ public static void addNotificationParams( final Map<String, String> paramMap, final Notification notification) { Collection<Parameter> parameters = notification.getParameterCollection(); for (Parameter parameter : parameters) { paramMap.put(parameter.getName(), parameter.getValue()); } }