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.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 Notifications
m_notifications
Object containing all Notification objects parsed from the xml filestatic java.lang.String
PARAM_DESTINATION
ConstantPARAM_DESTINATION="-d"
static java.lang.String
PARAM_EMAIL
ConstantPARAM_EMAIL="-email"
static java.lang.String
PARAM_HOME_PHONE
ConstantPARAM_HOME_PHONE="-hphone"
static java.lang.String
PARAM_INTERFACE
ConstantPARAM_INTERFACE="-interface"
static java.lang.String
PARAM_MICROBLOG_USERNAME
ConstantPARAM_MICROBLOG_USERNAME="-ublog"
static java.lang.String
PARAM_MOBILE_PHONE
ConstantPARAM_MOBILE_PHONE="-mphone"
static java.lang.String
PARAM_NODE
ConstantPARAM_NODE="-nodeid"
static java.lang.String
PARAM_NUM_MSG
ConstantPARAM_NUM_MSG="-nm"
static java.lang.String
PARAM_NUM_PAGER_PIN
ConstantPARAM_NUM_PAGER_PIN="-np"
static java.lang.String
PARAM_PAGER_EMAIL
ConstantPARAM_PAGER_EMAIL="-pemail"
static java.lang.String
PARAM_RESPONSE
ConstantPARAM_RESPONSE="-r"
static java.lang.String
PARAM_SERVICE
ConstantPARAM_SERVICE="-service"
static java.lang.String
PARAM_SUBJECT
ConstantPARAM_SUBJECT="-subject"
static java.lang.String
PARAM_TEXT_MSG
ConstantPARAM_TEXT_MSG="-tm"
static java.lang.String
PARAM_TEXT_PAGER_PIN
ConstantPARAM_TEXT_PAGER_PIN="-tp"
static java.lang.String
PARAM_TUI_PIN
ConstantPARAM_TUI_PIN="-tuipin"
static java.lang.String
PARAM_TYPE
ConstantPARAM_TYPE="-t"
static java.lang.String
PARAM_WORK_PHONE
ConstantPARAM_WORK_PHONE="-wphone"
static java.lang.String
PARAM_XMPP_ADDRESS
ConstantPARAM_XMPP_ADDRESS="-xmpp"
-
Constructor Summary
Constructors Modifier Constructor Description protected
NotificationManager(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)
acknowledgeNoticeBasedOnAlarmsvoid
addNotification(Notification notice)
Handles adding a new Notification.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.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.void
forEachUserNotification(int notifId, RowProcessor rp)
forEachUserNotificationjava.util.List<java.lang.Integer>
getActiveNodes()
getActiveNodeslong
getBinaryNoticesAttempted()
long
getBinaryNoticesFailed()
long
getBinaryNoticesInterrupted()
long
getBinaryNoticesSucceeded()
protected NotifdConfigManager
getConfigManager()
getConfigManagerEvent
getEvent(int eventid)
In the absence of DAOs and ORMs this creates an Event object from the persisted record.long
getJavaNoticesAttempted()
long
getJavaNoticesFailed()
long
getJavaNoticesInterrupted()
long
getJavaNoticesSucceeded()
int
getNoticeId()
This method wraps the call to the database to get a sequence notice ID from the database.Notification[]
getNotifForEvent(Event event)
getNotifForEventNotification
getNotification(java.lang.String name)
getNotificationjava.util.List<java.lang.String>
getNotificationNames()
getNotificationNamesjava.util.Map<java.lang.String,Notification>
getNotifications()
getNotificationslong
getNotificationTasksQueued()
java.lang.String
getQueueForNotification(int notifId)
getQueueForNotificationjava.util.List<java.lang.String>
getServiceNames()
getServiceNamesjava.lang.String
getServiceNoticeStatus(java.lang.String nodeID, java.lang.String ipaddr, java.lang.String service)
getServiceNoticeStatuslong
getUnknownNoticesInterrupted()
int
getUserNotifId()
getUserNotifIdboolean
hasUei(java.lang.String uei)
hasUeivoid
incrementAttempted(boolean isBinary)
void
incrementFailed(boolean isBinary)
void
incrementInterrupted(boolean isBinary)
void
incrementSucceeded(boolean isBinary)
void
incrementTasksQueued()
void
incrementUnknownInterrupted()
void
insertNotice(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 boolean
nodeInterfaceServiceValid(Notification notif, Event event)
nodeInterfaceServiceValidboolean
noticeOutstanding(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.void
parseXML(java.io.InputStream stream)
parseXMLvoid
parseXML(java.io.Reader reader)
Deprecated.java.util.Map<java.lang.String,java.lang.String>
rebuildParameterMap(int notifId, java.lang.String resolutionPrefix, boolean skipNumericPrefix)
rebuildParameterMapvoid
removeNotification(java.lang.String name)
removeNotificationvoid
replaceNotification(java.lang.String oldName, Notification newNotice)
replaceNotificationvoid
saveCurrent()
saveCurrentprotected abstract void
saveXML(java.lang.String xmlString)
saveXMLabstract void
update()
updatevoid
updateNoticeWithUserInfo(java.lang.String userId, int noticeId, java.lang.String media, java.lang.String contactInfo, java.lang.String autoNotify)
updateNoticeWithUserInfovoid
updateStatus(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
- aNotifdConfigManager
object.dcf
- aDataSource
object.
-
-
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
String
object.
-
parseXML
@Deprecated public void parseXML(java.io.Reader reader)
Deprecated.parseXML
- Parameters:
reader
- aReader
object.
-
parseXML
public void parseXML(java.io.InputStream stream) throws java.io.IOException
parseXML
- Parameters:
stream
- aInputStream
object.- Throws:
java.io.IOException
-
hasUei
public boolean hasUei(java.lang.String uei) throws java.io.IOException
hasUei
- Parameters:
uei
- aString
object.- Returns:
- a boolean.
- Throws:
java.io.IOException
- if any.
-
getNotifForEvent
public Notification[] getNotifForEvent(Event event) throws java.io.IOException
getNotifForEvent
- Parameters:
event
- aEvent
object.- Returns:
- an array of
Notification
objects. - Throws:
java.io.IOException
- if any.
-
getConfigManager
protected NotifdConfigManager getConfigManager()
getConfigManager
- Returns:
- a
NotifdConfigManager
object.
-
nodeInterfaceServiceValid
protected boolean nodeInterfaceServiceValid(Notification notif, Event event)
nodeInterfaceServiceValid
- Parameters:
notif
- aNotification
object.event
- aEvent
object.- Returns:
- a boolean.
-
getNoticeId
public int getNoticeId() throws java.sql.SQLException, java.io.IOException
This 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.IOException
getUserNotifId
- Returns:
- a int.
- Throws:
java.sql.SQLException
- if any.java.io.IOException
- if any.
-
noticeOutstanding
public boolean noticeOutstanding(int noticeId) throws java.io.IOException
This 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
- aEvent
object.uei
- aString
object.matchList
- an array ofString
objects.- Returns:
- a
Collection
object. - 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
- aEvent
object.- Returns:
- a
Collection
object. - Throws:
java.sql.SQLException
- if any.java.io.IOException
- if any.
-
getActiveNodes
public java.util.List<java.lang.Integer> getActiveNodes() throws java.sql.SQLException
getActiveNodes
- Returns:
- a
List
object. - 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.SQLException
getServiceNoticeStatus
- Parameters:
nodeID
- aString
object.ipaddr
- aString
object.service
- aString
object.- Returns:
- a
String
object. - 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.IOException
updateNoticeWithUserInfo
- Parameters:
userId
- aString
object.noticeId
- a int.media
- aString
object.contactInfo
- aString
object.autoNotify
- aString
object.- 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.SQLException
This method inserts a row into the notifications table in the database. This row indicates that the page has been sent out.- Parameters:
queueID
- aString
object.notification
- TODOnotifyId
- a int.params
- aMap
object.- Throws:
java.sql.SQLException
- if any.
-
getNotifications
public java.util.Map<java.lang.String,Notification> getNotifications() throws java.io.IOException
getNotifications
- Returns:
- a
Map
object. - Throws:
java.io.IOException
- if any.
-
getServiceNames
public java.util.List<java.lang.String> getServiceNames() throws java.sql.SQLException
getServiceNames
- Returns:
- a
List
object. - Throws:
java.sql.SQLException
-
getNotification
public Notification getNotification(java.lang.String name) throws java.io.IOException
getNotification
- Parameters:
name
- aString
object.- Returns:
- a
Notification
object. - Throws:
java.io.IOException
- if any.
-
getNotificationNames
public java.util.List<java.lang.String> getNotificationNames() throws java.io.IOException
getNotificationNames
- Returns:
- a
List
object. - Throws:
java.io.IOException
- if any.
-
removeNotification
public void removeNotification(java.lang.String name) throws java.io.IOException, java.lang.ClassNotFoundException
removeNotification
- Parameters:
name
- aString
object.- 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.ClassNotFoundException
replaceNotification
- Parameters:
oldName
- aString
object.newNotice
- aNotification
object.- 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.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:
java.io.IOException
- if any.java.lang.ClassNotFoundException
- if any.
-
saveCurrent
public void saveCurrent() throws java.io.IOException, java.lang.ClassNotFoundException
saveCurrent
- Throws:
java.io.IOException
- if any.java.lang.ClassNotFoundException
- if any.
-
saveXML
protected abstract void saveXML(java.lang.String xmlString) throws java.io.IOException
saveXML
- Parameters:
xmlString
- aString
object.- Throws:
java.io.IOException
- if any.
-
update
public abstract void update() throws java.io.IOException
update
- 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.Exception
rebuildParameterMap
- Parameters:
notifId
- a int.resolutionPrefix
- aString
object.skipNumericPrefix
- a boolean.- Returns:
- a
Map
object. - 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
- aMap
object.notification
- aNotification
object.
-
forEachUserNotification
public void forEachUserNotification(int notifId, RowProcessor rp)
forEachUserNotification
- Parameters:
notifId
- a int.rp
- aRowProcessor
object.
-
getQueueForNotification
public java.lang.String getQueueForNotification(int notifId)
getQueueForNotification
- Parameters:
notifId
- a int.- Returns:
- a
String
object.
-
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()
-
-