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 java.lang.ObjectAbstract 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 java.lang.StringPARAM_DESTINATIONConstantPARAM_DESTINATION="-d"static java.lang.StringPARAM_EMAILConstantPARAM_EMAIL="-email"static java.lang.StringPARAM_HOME_PHONEConstantPARAM_HOME_PHONE="-hphone"static java.lang.StringPARAM_INTERFACEConstantPARAM_INTERFACE="-interface"static java.lang.StringPARAM_MICROBLOG_USERNAMEConstantPARAM_MICROBLOG_USERNAME="-ublog"static java.lang.StringPARAM_MOBILE_PHONEConstantPARAM_MOBILE_PHONE="-mphone"static java.lang.StringPARAM_NODEConstantPARAM_NODE="-nodeid"static java.lang.StringPARAM_NUM_MSGConstantPARAM_NUM_MSG="-nm"static java.lang.StringPARAM_NUM_PAGER_PINConstantPARAM_NUM_PAGER_PIN="-np"static java.lang.StringPARAM_PAGER_EMAILConstantPARAM_PAGER_EMAIL="-pemail"static java.lang.StringPARAM_RESPONSEConstantPARAM_RESPONSE="-r"static java.lang.StringPARAM_SERVICEConstantPARAM_SERVICE="-service"static java.lang.StringPARAM_SUBJECTConstantPARAM_SUBJECT="-subject"static java.lang.StringPARAM_TEXT_MSGConstantPARAM_TEXT_MSG="-tm"static java.lang.StringPARAM_TEXT_PAGER_PINConstantPARAM_TEXT_PAGER_PIN="-tp"static java.lang.StringPARAM_TUI_PINConstantPARAM_TUI_PIN="-tuipin"static java.lang.StringPARAM_TYPEConstantPARAM_TYPE="-t"static java.lang.StringPARAM_WORK_PHONEConstantPARAM_WORK_PHONE="-wphone"static java.lang.StringPARAM_XMPP_ADDRESSConstantPARAM_XMPP_ADDRESS="-xmpp"
-
Constructor Summary
Constructors Modifier Constructor Description protectedNotificationManager(NotifdConfigManager configManager, javax.sql.DataSource dcf)Constructor for NotificationManager.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.util.Collection<java.lang.Integer>acknowledgeNotice(Event event, java.lang.String uei, java.lang.String[] matchList)acknowledgeNoticejava.util.Collection<java.lang.Integer>acknowledgeNoticeBasedOnAlarms(Event event)acknowledgeNoticeBasedOnAlarmsvoidaddNotification(Notification notice)Handles adding a new Notification.static voidaddNotificationParams(java.util.Map<java.lang.String,java.lang.String> paramMap, Notification notification)Adds additional parameters defined by the user in the notification configuration XML.static java.lang.StringexpandNotifParms(java.lang.String input, java.util.Map<java.lang.String,java.lang.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)forEachUserNotificationjava.util.List<java.lang.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(java.lang.String name)getNotificationjava.util.List<java.lang.String>getNotificationNames()getNotificationNamesjava.util.Map<java.lang.String,Notification>getNotifications()getNotificationslonggetNotificationTasksQueued()java.lang.StringgetQueueForNotification(int notifId)getQueueForNotificationjava.util.List<java.lang.String>getServiceNames()getServiceNamesjava.lang.StringgetServiceNoticeStatus(java.lang.String nodeID, java.lang.String ipaddr, java.lang.String service)getServiceNoticeStatuslonggetUnknownNoticesInterrupted()intgetUserNotifId()getUserNotifIdbooleanhasUei(java.lang.String uei)hasUeivoidincrementAttempted(boolean isBinary)voidincrementFailed(boolean isBinary)voidincrementInterrupted(boolean isBinary)voidincrementSucceeded(boolean isBinary)voidincrementTasksQueued()voidincrementUnknownInterrupted()voidinsertNotice(int notifyId, java.util.Map<java.lang.String,java.lang.String> params, java.lang.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(java.io.InputStream stream)parseXMLvoidparseXML(java.io.Reader reader)Deprecated.java.util.Map<java.lang.String,java.lang.String>rebuildParameterMap(int notifId, java.lang.String resolutionPrefix, boolean skipNumericPrefix)rebuildParameterMapvoidremoveNotification(java.lang.String name)removeNotificationvoidreplaceNotification(java.lang.String oldName, Notification newNotice)replaceNotificationvoidsaveCurrent()saveCurrentprotected abstract voidsaveXML(java.lang.String xmlString)saveXMLabstract voidupdate()updatevoidupdateNoticeWithUserInfo(java.lang.String userId, int noticeId, java.lang.String media, java.lang.String contactInfo, java.lang.String autoNotify)updateNoticeWithUserInfovoidupdateStatus(java.lang.String name, java.lang.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 java.lang.String PARAM_TYPE
ConstantPARAM_TYPE="-t"- See Also:
- Constant Field Values
-
PARAM_DESTINATION
public static final java.lang.String PARAM_DESTINATION
ConstantPARAM_DESTINATION="-d"- See Also:
- Constant Field Values
-
PARAM_TEXT_MSG
public static final java.lang.String PARAM_TEXT_MSG
ConstantPARAM_TEXT_MSG="-tm"- See Also:
- Constant Field Values
-
PARAM_NUM_MSG
public static final java.lang.String PARAM_NUM_MSG
ConstantPARAM_NUM_MSG="-nm"- See Also:
- Constant Field Values
-
PARAM_RESPONSE
public static final java.lang.String PARAM_RESPONSE
ConstantPARAM_RESPONSE="-r"- See Also:
- Constant Field Values
-
PARAM_NODE
public static final java.lang.String PARAM_NODE
ConstantPARAM_NODE="-nodeid"- See Also:
- Constant Field Values
-
PARAM_INTERFACE
public static final java.lang.String PARAM_INTERFACE
ConstantPARAM_INTERFACE="-interface"- See Also:
- Constant Field Values
-
PARAM_SERVICE
public static final java.lang.String PARAM_SERVICE
ConstantPARAM_SERVICE="-service"- See Also:
- Constant Field Values
-
PARAM_SUBJECT
public static final java.lang.String PARAM_SUBJECT
ConstantPARAM_SUBJECT="-subject"- See Also:
- Constant Field Values
-
PARAM_EMAIL
public static final java.lang.String PARAM_EMAIL
ConstantPARAM_EMAIL="-email"- See Also:
- Constant Field Values
-
PARAM_PAGER_EMAIL
public static final java.lang.String PARAM_PAGER_EMAIL
ConstantPARAM_PAGER_EMAIL="-pemail"- See Also:
- Constant Field Values
-
PARAM_XMPP_ADDRESS
public static final java.lang.String PARAM_XMPP_ADDRESS
ConstantPARAM_XMPP_ADDRESS="-xmpp"- See Also:
- Constant Field Values
-
PARAM_TEXT_PAGER_PIN
public static final java.lang.String PARAM_TEXT_PAGER_PIN
ConstantPARAM_TEXT_PAGER_PIN="-tp"- See Also:
- Constant Field Values
-
PARAM_NUM_PAGER_PIN
public static final java.lang.String PARAM_NUM_PAGER_PIN
ConstantPARAM_NUM_PAGER_PIN="-np"- See Also:
- Constant Field Values
-
PARAM_WORK_PHONE
public static final java.lang.String PARAM_WORK_PHONE
ConstantPARAM_WORK_PHONE="-wphone"- See Also:
- Constant Field Values
-
PARAM_HOME_PHONE
public static final java.lang.String PARAM_HOME_PHONE
ConstantPARAM_HOME_PHONE="-hphone"- See Also:
- Constant Field Values
-
PARAM_MOBILE_PHONE
public static final java.lang.String PARAM_MOBILE_PHONE
ConstantPARAM_MOBILE_PHONE="-mphone"- See Also:
- Constant Field Values
-
PARAM_TUI_PIN
public static final java.lang.String PARAM_TUI_PIN
ConstantPARAM_TUI_PIN="-tuipin"- See Also:
- Constant Field Values
-
PARAM_MICROBLOG_USERNAME
public static final java.lang.String PARAM_MICROBLOG_USERNAME
ConstantPARAM_MICROBLOG_USERNAME="-ublog"- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NotificationManager
protected NotificationManager(NotifdConfigManager configManager, javax.sql.DataSource dcf)
Constructor for NotificationManager.
- Parameters:
configManager- aNotifdConfigManagerobject.dcf- aDataSourceobject.
-
-
Method Detail
-
expandNotifParms
public static java.lang.String expandNotifParms(java.lang.String input, java.util.Map<java.lang.String,java.lang.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(java.io.Reader reader)
Deprecated.parseXML
- Parameters:
reader- aReaderobject.
-
parseXML
public void parseXML(java.io.InputStream stream) throws java.io.IOExceptionparseXML
- Parameters:
stream- aInputStreamobject.- Throws:
java.io.IOException
-
hasUei
public boolean hasUei(java.lang.String uei) throws java.io.IOExceptionhasUei
- Parameters:
uei- aStringobject.- Returns:
- a boolean.
- Throws:
java.io.IOException- if any.
-
getNotifForEvent
public Notification[] getNotifForEvent(Event event) throws java.io.IOException
getNotifForEvent
- Parameters:
event- aEventobject.- Returns:
- an array of
Notificationobjects. - Throws:
java.io.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 java.sql.SQLException, java.io.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:
java.sql.SQLException- if any.java.io.IOException- if any.
-
getUserNotifId
public int getUserNotifId() throws java.sql.SQLException, java.io.IOExceptiongetUserNotifId
- Returns:
- a int.
- Throws:
java.sql.SQLException- if any.java.io.IOException- if any.
-
noticeOutstanding
public boolean noticeOutstanding(int noticeId) throws java.io.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:
java.io.IOException- if any.
-
acknowledgeNotice
public java.util.Collection<java.lang.Integer> acknowledgeNotice(Event event, java.lang.String uei, java.lang.String[] matchList) throws java.sql.SQLException, java.io.IOException
acknowledgeNotice
- Parameters:
event- aEventobject.uei- aStringobject.matchList- an array ofStringobjects.- Returns:
- a
Collectionobject. - Throws:
java.sql.SQLException- if any.java.io.IOException- if any.
-
acknowledgeNoticeBasedOnAlarms
public java.util.Collection<java.lang.Integer> acknowledgeNoticeBasedOnAlarms(Event event) throws java.sql.SQLException, java.io.IOException
acknowledgeNoticeBasedOnAlarms
- Parameters:
event- aEventobject.- Returns:
- a
Collectionobject. - Throws:
java.sql.SQLException- if any.java.io.IOException- if any.
-
getActiveNodes
public java.util.List<java.lang.Integer> getActiveNodes() throws java.sql.SQLExceptiongetActiveNodes
- Returns:
- a
Listobject. - Throws:
java.sql.SQLException- if any.
-
getServiceNoticeStatus
public java.lang.String getServiceNoticeStatus(java.lang.String nodeID, java.lang.String ipaddr, java.lang.String service) throws java.sql.SQLExceptiongetServiceNoticeStatus
- Parameters:
nodeID- aStringobject.ipaddr- aStringobject.service- aStringobject.- Returns:
- a
Stringobject. - Throws:
java.sql.SQLException- if any.
-
updateNoticeWithUserInfo
public void updateNoticeWithUserInfo(java.lang.String userId, int noticeId, java.lang.String media, java.lang.String contactInfo, java.lang.String autoNotify) throws java.sql.SQLException, java.io.IOExceptionupdateNoticeWithUserInfo
- Parameters:
userId- aStringobject.noticeId- a int.media- aStringobject.contactInfo- aStringobject.autoNotify- aStringobject.- Throws:
java.io.IOException- if any.java.sql.SQLException- if any.
-
insertNotice
public void insertNotice(int notifyId, java.util.Map<java.lang.String,java.lang.String> params, java.lang.String queueID, Notification notification) throws java.sql.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:
java.sql.SQLException- if any.
-
getNotifications
public java.util.Map<java.lang.String,Notification> getNotifications() throws java.io.IOException
getNotifications
- Returns:
- a
Mapobject. - Throws:
java.io.IOException- if any.
-
getServiceNames
public java.util.List<java.lang.String> getServiceNames() throws java.sql.SQLExceptiongetServiceNames
- Returns:
- a
Listobject. - Throws:
java.sql.SQLException
-
getNotification
public Notification getNotification(java.lang.String name) throws java.io.IOException
getNotification
- Parameters:
name- aStringobject.- Returns:
- a
Notificationobject. - Throws:
java.io.IOException- if any.
-
getNotificationNames
public java.util.List<java.lang.String> getNotificationNames() throws java.io.IOExceptiongetNotificationNames
- Returns:
- a
Listobject. - Throws:
java.io.IOException- if any.
-
removeNotification
public void removeNotification(java.lang.String name) throws java.io.IOException, java.lang.ClassNotFoundExceptionremoveNotification
- Parameters:
name- aStringobject.- Throws:
java.io.IOException- if any.java.lang.ClassNotFoundException- if any.
-
addNotification
public void addNotification(Notification notice) throws java.io.IOException, java.lang.ClassNotFoundException
Handles adding a new Notification.- Parameters:
notice- The Notification to add.- Throws:
java.io.IOException- if any.java.lang.ClassNotFoundException- if any.
-
replaceNotification
public void replaceNotification(java.lang.String oldName, Notification newNotice) throws java.io.IOException, java.lang.ClassNotFoundExceptionreplaceNotification
- Parameters:
oldName- aStringobject.newNotice- aNotificationobject.- Throws:
java.io.IOException- if any.java.lang.ClassNotFoundException- if any.
-
updateStatus
public void updateStatus(java.lang.String name, java.lang.String status) throws java.io.IOException, java.lang.ClassNotFoundExceptionSets 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:
java.io.IOException- if any.java.lang.ClassNotFoundException- if any.
-
saveCurrent
public void saveCurrent() throws java.io.IOException, java.lang.ClassNotFoundExceptionsaveCurrent
- Throws:
java.io.IOException- if any.java.lang.ClassNotFoundException- if any.
-
saveXML
protected abstract void saveXML(java.lang.String xmlString) throws java.io.IOExceptionsaveXML
- Parameters:
xmlString- aStringobject.- Throws:
java.io.IOException- if any.
-
update
public abstract void update() throws java.io.IOExceptionupdate
- Throws:
java.io.IOException- if any.
-
rebuildParameterMap
public java.util.Map<java.lang.String,java.lang.String> rebuildParameterMap(int notifId, java.lang.String resolutionPrefix, boolean skipNumericPrefix) throws java.lang.ExceptionrebuildParameterMap
- Parameters:
notifId- a int.resolutionPrefix- aStringobject.skipNumericPrefix- a boolean.- Returns:
- a
Mapobject. - Throws:
java.lang.Exception- if any.
-
addNotificationParams
public static void addNotificationParams(java.util.Map<java.lang.String,java.lang.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 java.lang.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()
-
-