expandNotifParms( resolutionPrefix, Collections.singletonMap("noticeid", String.valueOf(notifId)) parmMap.put( NotificationManager.PARAM_NUM_MSG, expandNotifParms( resolutionPrefix, Collections.singletonMap("noticeid", String.valueOf(notifId)) expandNotifParms( resolutionPrefix, Collections.singletonMap("noticeid", String.valueOf(notifId))
/** * */ protected Map<String, String> buildParameterMap(Notification notification, Event event, int noticeId) { Map<String, String> paramMap = new HashMap<String, String>(); NotificationManager.addNotificationParams(paramMap, notification); // expand the event parameters for the messages // call the notif expansion method before the event expansion because // event expansion will // throw away any expansion strings it doesn't recognize! paramMap.put("noticeid", Integer.toString(noticeId)); // Replace the %noticeid% param String textMessage = NotificationManager.expandNotifParms((nullSafeTextMsg(notification)), paramMap); String numericMessage = NotificationManager.expandNotifParms((nullSafeNumerMsg(notification, noticeId)), paramMap); String subjectLine = NotificationManager.expandNotifParms((nullSafeSubj(notification, noticeId)), paramMap); Map<String, Map<String, String>> decodeMap = getVarbindsDecodeMap(event.getUei()); nullSafeExpandedPut(NotificationManager.PARAM_TEXT_MSG, textMessage, event, paramMap, decodeMap); nullSafeExpandedPut(NotificationManager.PARAM_NUM_MSG, numericMessage, event, paramMap, decodeMap); nullSafeExpandedPut(NotificationManager.PARAM_SUBJECT, subjectLine, event, paramMap, decodeMap); paramMap.put(NotificationManager.PARAM_NODE, event.hasNodeid() ? String.valueOf(event.getNodeid()) : ""); paramMap.put(NotificationManager.PARAM_INTERFACE, event.getInterface()); paramMap.put(NotificationManager.PARAM_SERVICE, event.getService()); paramMap.put("eventID", String.valueOf(event.getDbid())); paramMap.put("eventUEI", event.getUei()); m_eventUtil.expandMapValues(paramMap, event); return Collections.unmodifiableMap(paramMap); }
String expandResult = NotificationManager.expandNotifParms("%foo%", new TreeMap<String,String>()); assertEquals("%foo%", expandResult); expandResult = NotificationManager.expandNotifParms("%foo%", Collections.singletonMap("foo", "bar")); assertEquals("%foo%", expandResult); expandResult = NotificationManager.expandNotifParms("Notice #%noticeid% RESOLVED: ", Collections.singletonMap("noticeid", "999")); assertEquals("Notice #999 RESOLVED: ", expandResult); expandResult = NotificationManager.expandNotifParms("RESOLVED: ", Collections.singletonMap("noticeid", "999")); assertEquals("RESOLVED: ", expandResult); expandResult = NotificationManager.expandNotifParms("Notice %noticeid%: Disk threshold exceeded on %nodelabel%: %parm[all]%.", new TreeMap<String,String>()); assertEquals("Notice %noticeid%: Disk threshold exceeded on %nodelabel%: %parm[all]%.", expandResult); expandResult = NotificationManager.expandNotifParms("Notice #%noticeid%: Disk threshold exceeded on %nodelabel%: %parm[all]%.", paramMap); assertEquals("Notice #9999: Disk threshold exceeded on %nodelabel%: %parm[all]%.", expandResult);