Package org.opennms.netmgt.config
Class NotificationManager
- java.lang.Object
-
- org.opennms.netmgt.config.NotificationManager
-
- Direct Known Subclasses:
MockNotificationManager,NotificationFactory
public abstract class NotificationManager extends Object
Abstract NotificationManager class.
- Version:
- $Id: $
- Author:
- David Hustace
This base class was refactored from NotificationFactory to support non-global references during JUnit testing and later to support distributed processes.
-
-
Field Summary
Fields Modifier and Type Field Description Notificationsm_notificationsObject containing all Notification objects parsed from the xml filestatic StringPARAM_DESTINATIONConstantPARAM_DESTINATION="-d"static StringPARAM_EMAILConstantPARAM_EMAIL="-email"static StringPARAM_HOME_PHONEConstantPARAM_HOME_PHONE="-hphone"static StringPARAM_INTERFACEConstantPARAM_INTERFACE="-interface"static StringPARAM_MICROBLOG_USERNAMEConstantPARAM_MICROBLOG_USERNAME="-ublog"static StringPARAM_MOBILE_PHONEConstantPARAM_MOBILE_PHONE="-mphone"static StringPARAM_NODEConstantPARAM_NODE="-nodeid"static StringPARAM_NUM_MSGConstantPARAM_NUM_MSG="-nm"static StringPARAM_NUM_PAGER_PINConstantPARAM_NUM_PAGER_PIN="-np"static StringPARAM_PAGER_EMAILConstantPARAM_PAGER_EMAIL="-pemail"static StringPARAM_RESPONSEConstantPARAM_RESPONSE="-r"static StringPARAM_SERVICEConstantPARAM_SERVICE="-service"static StringPARAM_SUBJECTConstantPARAM_SUBJECT="-subject"static StringPARAM_TEXT_MSGConstantPARAM_TEXT_MSG="-tm"static StringPARAM_TEXT_PAGER_PINConstantPARAM_TEXT_PAGER_PIN="-tp"static StringPARAM_TUI_PINConstantPARAM_TUI_PIN="-tuipin"static StringPARAM_TYPEConstantPARAM_TYPE="-t"static StringPARAM_WORK_PHONEConstantPARAM_WORK_PHONE="-wphone"static StringPARAM_XMPP_ADDRESSConstantPARAM_XMPP_ADDRESS="-xmpp"
-
Constructor Summary
Constructors Modifier Constructor Description protectedNotificationManager(NotifdConfigManager configManager, DataSource dcf)Constructor for NotificationManager.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Collection<Integer>acknowledgeNotice(Event event, String uei, String[] matchList)acknowledgeNoticeCollection<Integer>acknowledgeNoticeBasedOnAlarms(Event event)acknowledgeNoticeBasedOnAlarmsvoidaddNotification(Notification notice)Handles adding a new Notification.static voidaddNotificationParams(Map<String,String> paramMap, Notification notification)Adds additional parameters defined by the user in the notification configuration XML.static StringexpandNotifParms(String input, Map<String,String> paramMap)A parameter expansion algorithm, designed to replace strings delimited by percent signs '%' with a value supplied by a Map object.voidforEachUserNotification(int notifId, RowProcessor rp)forEachUserNotificationList<Integer>getActiveNodes()getActiveNodeslonggetBinaryNoticesAttempted()longgetBinaryNoticesFailed()longgetBinaryNoticesInterrupted()longgetBinaryNoticesSucceeded()protected NotifdConfigManagergetConfigManager()getConfigManagerEventgetEvent(int eventid)In the absence of DAOs and ORMs this creates an Event object from the persisted record.longgetJavaNoticesAttempted()longgetJavaNoticesFailed()longgetJavaNoticesInterrupted()longgetJavaNoticesSucceeded()intgetNoticeId()This method wraps the call to the database to get a sequence notice ID from the database.Notification[]getNotifForEvent(Event event)getNotifForEventNotificationgetNotification(String name)getNotificationList<String>getNotificationNames()getNotificationNamesMap<String,Notification>getNotifications()getNotificationslonggetNotificationTasksQueued()StringgetQueueForNotification(int notifId)getQueueForNotificationList<String>getServiceNames()getServiceNamesStringgetServiceNoticeStatus(String nodeID, String ipaddr, String service)getServiceNoticeStatuslonggetUnknownNoticesInterrupted()intgetUserNotifId()getUserNotifIdbooleanhasUei(String uei)hasUeivoidincrementAttempted(boolean isBinary)voidincrementFailed(boolean isBinary)voidincrementInterrupted(boolean isBinary)voidincrementSucceeded(boolean isBinary)voidincrementTasksQueued()voidincrementUnknownInterrupted()voidinsertNotice(int notifyId, Map<String,String> params, String queueID, Notification notification)This method inserts a row into the notifications table in the database.protected booleannodeInterfaceServiceValid(Notification notif, Event event)nodeInterfaceServiceValidbooleannoticeOutstanding(int noticeId)This method returns a boolean indicating if the page has been responded to by any member of the group the page was sent to.voidparseXML(InputStream stream)parseXMLvoidparseXML(Reader reader)Deprecated.Map<String,String>rebuildParameterMap(int notifId, String resolutionPrefix, boolean skipNumericPrefix)rebuildParameterMapvoidremoveNotification(String name)removeNotificationvoidreplaceNotification(String oldName, Notification newNotice)replaceNotificationvoidsaveCurrent()saveCurrentprotected abstract voidsaveXML(String xmlString)saveXMLabstract voidupdate()updatevoidupdateNoticeWithUserInfo(String userId, int noticeId, String media, String contactInfo, String autoNotify)updateNoticeWithUserInfovoidupdateStatus(String name, String status)Sets the status on an individual notification configuration and saves to xml.
-
-
-
Field Detail
-
m_notifications
public Notifications m_notifications
Object containing all Notification objects parsed from the xml file
-
PARAM_TYPE
public static final String PARAM_TYPE
ConstantPARAM_TYPE="-t"- See Also:
- Constant Field Values
-
PARAM_DESTINATION
public static final String PARAM_DESTINATION
ConstantPARAM_DESTINATION="-d"- See Also:
- Constant Field Values
-
PARAM_TEXT_MSG
public static final String PARAM_TEXT_MSG
ConstantPARAM_TEXT_MSG="-tm"- See Also:
- Constant Field Values
-
PARAM_NUM_MSG
public static final String PARAM_NUM_MSG
ConstantPARAM_NUM_MSG="-nm"- See Also:
- Constant Field Values
-
PARAM_RESPONSE
public static final String PARAM_RESPONSE
ConstantPARAM_RESPONSE="-r"- See Also:
- Constant Field Values
-
PARAM_NODE
public static final String PARAM_NODE
ConstantPARAM_NODE="-nodeid"- See Also:
- Constant Field Values
-
PARAM_INTERFACE
public static final String PARAM_INTERFACE
ConstantPARAM_INTERFACE="-interface"- See Also:
- Constant Field Values
-
PARAM_SERVICE
public static final String PARAM_SERVICE
ConstantPARAM_SERVICE="-service"- See Also:
- Constant Field Values
-
PARAM_SUBJECT
public static final String PARAM_SUBJECT
ConstantPARAM_SUBJECT="-subject"- See Also:
- Constant Field Values
-
PARAM_EMAIL
public static final String PARAM_EMAIL
ConstantPARAM_EMAIL="-email"- See Also:
- Constant Field Values
-
PARAM_PAGER_EMAIL
public static final String PARAM_PAGER_EMAIL
ConstantPARAM_PAGER_EMAIL="-pemail"- See Also:
- Constant Field Values
-
PARAM_XMPP_ADDRESS
public static final String PARAM_XMPP_ADDRESS
ConstantPARAM_XMPP_ADDRESS="-xmpp"- See Also:
- Constant Field Values
-
PARAM_TEXT_PAGER_PIN
public static final String PARAM_TEXT_PAGER_PIN
ConstantPARAM_TEXT_PAGER_PIN="-tp"- See Also:
- Constant Field Values
-
PARAM_NUM_PAGER_PIN
public static final String PARAM_NUM_PAGER_PIN
ConstantPARAM_NUM_PAGER_PIN="-np"- See Also:
- Constant Field Values
-
PARAM_WORK_PHONE
public static final String PARAM_WORK_PHONE
ConstantPARAM_WORK_PHONE="-wphone"- See Also:
- Constant Field Values
-
PARAM_HOME_PHONE
public static final String PARAM_HOME_PHONE
ConstantPARAM_HOME_PHONE="-hphone"- See Also:
- Constant Field Values
-
PARAM_MOBILE_PHONE
public static final String PARAM_MOBILE_PHONE
ConstantPARAM_MOBILE_PHONE="-mphone"- See Also:
- Constant Field Values
-
PARAM_TUI_PIN
public static final String PARAM_TUI_PIN
ConstantPARAM_TUI_PIN="-tuipin"- See Also:
- Constant Field Values
-
PARAM_MICROBLOG_USERNAME
public static final String PARAM_MICROBLOG_USERNAME
ConstantPARAM_MICROBLOG_USERNAME="-ublog"- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NotificationManager
protected NotificationManager(NotifdConfigManager configManager, DataSource dcf)
Constructor for NotificationManager.
- Parameters:
configManager- aNotifdConfigManagerobject.dcf- aDataSourceobject.
-
-
Method Detail
-
expandNotifParms
public static String expandNotifParms(String input, Map<String,String> paramMap)
A parameter expansion algorithm, designed to replace strings delimited by percent signs '%' with a value supplied by a Map object.NOTE: This function only replaces one particular parameter, the
%noticeid%parameter.- Parameters:
input- the input stringparamMap- a map that will supply the substitution values- Returns:
- a
Stringobject.
-
parseXML
@Deprecated public void parseXML(Reader reader)
Deprecated.parseXML
- Parameters:
reader- aReaderobject.
-
parseXML
public void parseXML(InputStream stream) throws IOException
parseXML
- Parameters:
stream- aInputStreamobject.- Throws:
IOException
-
hasUei
public boolean hasUei(String uei) throws IOException
hasUei
- Parameters:
uei- aStringobject.- Returns:
- a boolean.
- Throws:
IOException- if any.
-
getNotifForEvent
public Notification[] getNotifForEvent(Event event) throws IOException
getNotifForEvent
- Parameters:
event- aEventobject.- Returns:
- an array of
Notificationobjects. - Throws:
IOException- if any.
-
getConfigManager
protected NotifdConfigManager getConfigManager()
getConfigManager
- Returns:
- a
NotifdConfigManagerobject.
-
nodeInterfaceServiceValid
protected boolean nodeInterfaceServiceValid(Notification notif, Event event)
nodeInterfaceServiceValid
- Parameters:
notif- aNotificationobject.event- aEventobject.- Returns:
- a boolean.
-
getNoticeId
public int getNoticeId() throws SQLException, IOExceptionThis method wraps the call to the database to get a sequence notice ID from the database.- Returns:
- int, the sequence id from the database, 0 by default if there is database trouble
- Throws:
SQLException- if any.IOException- if any.
-
getUserNotifId
public int getUserNotifId() throws SQLException, IOExceptiongetUserNotifId
- Returns:
- a int.
- Throws:
SQLException- if any.IOException- if any.
-
noticeOutstanding
public boolean noticeOutstanding(int noticeId) throws IOExceptionThis method returns a boolean indicating if the page has been responded to by any member of the group the page was sent to.- Parameters:
noticeId- a int.- Returns:
- a boolean.
- Throws:
IOException- if any.
-
acknowledgeNotice
public Collection<Integer> acknowledgeNotice(Event event, String uei, String[] matchList) throws SQLException, IOException
acknowledgeNotice
- Parameters:
event- aEventobject.uei- aStringobject.matchList- an array ofStringobjects.- Returns:
- a
Collectionobject. - Throws:
SQLException- if any.IOException- if any.
-
acknowledgeNoticeBasedOnAlarms
public Collection<Integer> acknowledgeNoticeBasedOnAlarms(Event event) throws SQLException, IOException
acknowledgeNoticeBasedOnAlarms
- Parameters:
event- aEventobject.- Returns:
- a
Collectionobject. - Throws:
SQLException- if any.IOException- if any.
-
getActiveNodes
public List<Integer> getActiveNodes() throws SQLException
getActiveNodes
- Returns:
- a
Listobject. - Throws:
SQLException- if any.
-
getServiceNoticeStatus
public String getServiceNoticeStatus(String nodeID, String ipaddr, String service) throws SQLException
getServiceNoticeStatus
- Parameters:
nodeID- aStringobject.ipaddr- aStringobject.service- aStringobject.- Returns:
- a
Stringobject. - Throws:
SQLException- if any.
-
updateNoticeWithUserInfo
public void updateNoticeWithUserInfo(String userId, int noticeId, String media, String contactInfo, String autoNotify) throws SQLException, IOException
updateNoticeWithUserInfo
- Parameters:
userId- aStringobject.noticeId- a int.media- aStringobject.contactInfo- aStringobject.autoNotify- aStringobject.- Throws:
IOException- if any.SQLException- if any.
-
insertNotice
public void insertNotice(int notifyId, Map<String,String> params, String queueID, Notification notification) throws SQLExceptionThis method inserts a row into the notifications table in the database. This row indicates that the page has been sent out.- Parameters:
queueID- aStringobject.notification- TODOnotifyId- a int.params- aMapobject.- Throws:
SQLException- if any.
-
getNotifications
public Map<String,Notification> getNotifications() throws IOException
getNotifications
- Returns:
- a
Mapobject. - Throws:
IOException- if any.
-
getServiceNames
public List<String> getServiceNames() throws SQLException
getServiceNames
- Returns:
- a
Listobject. - Throws:
SQLException
-
getNotification
public Notification getNotification(String name) throws IOException
getNotification
- Parameters:
name- aStringobject.- Returns:
- a
Notificationobject. - Throws:
IOException- if any.
-
getNotificationNames
public List<String> getNotificationNames() throws IOException
getNotificationNames
- Returns:
- a
Listobject. - Throws:
IOException- if any.
-
removeNotification
public void removeNotification(String name) throws IOException, ClassNotFoundException
removeNotification
- Parameters:
name- aStringobject.- Throws:
IOException- if any.ClassNotFoundException- if any.
-
addNotification
public void addNotification(Notification notice) throws IOException, ClassNotFoundException
Handles adding a new Notification.- Parameters:
notice- The Notification to add.- Throws:
IOException- if any.ClassNotFoundException- if any.
-
replaceNotification
public void replaceNotification(String oldName, Notification newNotice) throws IOException, ClassNotFoundException
replaceNotification
- Parameters:
oldName- aStringobject.newNotice- aNotificationobject.- Throws:
IOException- if any.ClassNotFoundException- if any.
-
updateStatus
public void updateStatus(String name, String status) throws IOException, ClassNotFoundException
Sets the status on an individual notification configuration and saves to xml.- Parameters:
name- The name of the notification.status- The status (either "on" or "off").- Throws:
IOException- if any.ClassNotFoundException- if any.
-
saveCurrent
public void saveCurrent() throws IOException, ClassNotFoundExceptionsaveCurrent
- Throws:
IOException- if any.ClassNotFoundException- if any.
-
saveXML
protected abstract void saveXML(String xmlString) throws IOException
saveXML
- Parameters:
xmlString- aStringobject.- Throws:
IOException- if any.
-
update
public abstract void update() throws IOExceptionupdate
- Throws:
IOException- if any.
-
rebuildParameterMap
public Map<String,String> rebuildParameterMap(int notifId, String resolutionPrefix, boolean skipNumericPrefix) throws Exception
rebuildParameterMap
-
addNotificationParams
public static void addNotificationParams(Map<String,String> paramMap, Notification notification)
Adds additional parameters defined by the user in the notification configuration XML.- Parameters:
paramMap- aMapobject.notification- aNotificationobject.
-
forEachUserNotification
public void forEachUserNotification(int notifId, RowProcessor rp)forEachUserNotification
- Parameters:
notifId- a int.rp- aRowProcessorobject.
-
getQueueForNotification
public String getQueueForNotification(int notifId)
getQueueForNotification
- Parameters:
notifId- a int.- Returns:
- a
Stringobject.
-
getEvent
public Event getEvent(int eventid)
In the absence of DAOs and ORMs this creates an Event object from the persisted record.- Parameters:
eventid- a int.- Returns:
- a populated Event object
-
incrementTasksQueued
public void incrementTasksQueued()
-
incrementAttempted
public void incrementAttempted(boolean isBinary)
-
incrementSucceeded
public void incrementSucceeded(boolean isBinary)
-
incrementFailed
public void incrementFailed(boolean isBinary)
-
incrementInterrupted
public void incrementInterrupted(boolean isBinary)
-
incrementUnknownInterrupted
public void incrementUnknownInterrupted()
-
getNotificationTasksQueued
public long getNotificationTasksQueued()
-
getBinaryNoticesAttempted
public long getBinaryNoticesAttempted()
-
getJavaNoticesAttempted
public long getJavaNoticesAttempted()
-
getBinaryNoticesSucceeded
public long getBinaryNoticesSucceeded()
-
getJavaNoticesSucceeded
public long getJavaNoticesSucceeded()
-
getBinaryNoticesFailed
public long getBinaryNoticesFailed()
-
getJavaNoticesFailed
public long getJavaNoticesFailed()
-
getBinaryNoticesInterrupted
public long getBinaryNoticesInterrupted()
-
getJavaNoticesInterrupted
public long getJavaNoticesInterrupted()
-
getUnknownNoticesInterrupted
public long getUnknownNoticesInterrupted()
-
-