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 Notifications
m_notifications
Object containing all Notification objects parsed from the xml filestatic String
PARAM_DESTINATION
ConstantPARAM_DESTINATION="-d"
static String
PARAM_EMAIL
ConstantPARAM_EMAIL="-email"
static String
PARAM_HOME_PHONE
ConstantPARAM_HOME_PHONE="-hphone"
static String
PARAM_INTERFACE
ConstantPARAM_INTERFACE="-interface"
static String
PARAM_MICROBLOG_USERNAME
ConstantPARAM_MICROBLOG_USERNAME="-ublog"
static String
PARAM_MOBILE_PHONE
ConstantPARAM_MOBILE_PHONE="-mphone"
static String
PARAM_NODE
ConstantPARAM_NODE="-nodeid"
static String
PARAM_NUM_MSG
ConstantPARAM_NUM_MSG="-nm"
static String
PARAM_NUM_PAGER_PIN
ConstantPARAM_NUM_PAGER_PIN="-np"
static String
PARAM_PAGER_EMAIL
ConstantPARAM_PAGER_EMAIL="-pemail"
static String
PARAM_RESPONSE
ConstantPARAM_RESPONSE="-r"
static String
PARAM_SERVICE
ConstantPARAM_SERVICE="-service"
static String
PARAM_SUBJECT
ConstantPARAM_SUBJECT="-subject"
static String
PARAM_TEXT_MSG
ConstantPARAM_TEXT_MSG="-tm"
static String
PARAM_TEXT_PAGER_PIN
ConstantPARAM_TEXT_PAGER_PIN="-tp"
static String
PARAM_TUI_PIN
ConstantPARAM_TUI_PIN="-tuipin"
static String
PARAM_TYPE
ConstantPARAM_TYPE="-t"
static String
PARAM_WORK_PHONE
ConstantPARAM_WORK_PHONE="-wphone"
static String
PARAM_XMPP_ADDRESS
ConstantPARAM_XMPP_ADDRESS="-xmpp"
-
Constructor Summary
Constructors Modifier Constructor Description protected
NotificationManager(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)
acknowledgeNoticeBasedOnAlarmsvoid
addNotification(Notification notice)
Handles adding a new Notification.static void
addNotificationParams(Map<String,String> paramMap, Notification notification)
Adds additional parameters defined by the user in the notification configuration XML.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.void
forEachUserNotification(int notifId, RowProcessor rp)
forEachUserNotificationList<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(String name)
getNotificationList<String>
getNotificationNames()
getNotificationNamesMap<String,Notification>
getNotifications()
getNotificationslong
getNotificationTasksQueued()
String
getQueueForNotification(int notifId)
getQueueForNotificationList<String>
getServiceNames()
getServiceNamesString
getServiceNoticeStatus(String nodeID, String ipaddr, String service)
getServiceNoticeStatuslong
getUnknownNoticesInterrupted()
int
getUserNotifId()
getUserNotifIdboolean
hasUei(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, Map<String,String> params, 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(InputStream stream)
parseXMLvoid
parseXML(Reader reader)
Deprecated.Map<String,String>
rebuildParameterMap(int notifId, String resolutionPrefix, boolean skipNumericPrefix)
rebuildParameterMapvoid
removeNotification(String name)
removeNotificationvoid
replaceNotification(String oldName, Notification newNotice)
replaceNotificationvoid
saveCurrent()
saveCurrentprotected abstract void
saveXML(String xmlString)
saveXMLabstract void
update()
updatevoid
updateNoticeWithUserInfo(String userId, int noticeId, String media, String contactInfo, String autoNotify)
updateNoticeWithUserInfovoid
updateStatus(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
- aNotifdConfigManager
object.dcf
- aDataSource
object.
-
-
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
String
object.
-
parseXML
@Deprecated public void parseXML(Reader reader)
Deprecated.parseXML
- Parameters:
reader
- aReader
object.
-
parseXML
public void parseXML(InputStream stream) throws IOException
parseXML
- Parameters:
stream
- aInputStream
object.- Throws:
IOException
-
hasUei
public boolean hasUei(String uei) throws IOException
hasUei
- Parameters:
uei
- aString
object.- Returns:
- a boolean.
- Throws:
IOException
- if any.
-
getNotifForEvent
public Notification[] getNotifForEvent(Event event) throws IOException
getNotifForEvent
- Parameters:
event
- aEvent
object.- Returns:
- an array of
Notification
objects. - Throws:
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 SQLException, 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:
SQLException
- if any.IOException
- if any.
-
getUserNotifId
public int getUserNotifId() throws SQLException, IOException
getUserNotifId
- Returns:
- a int.
- Throws:
SQLException
- if any.IOException
- if any.
-
noticeOutstanding
public boolean noticeOutstanding(int noticeId) throws 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:
IOException
- if any.
-
acknowledgeNotice
public Collection<Integer> acknowledgeNotice(Event event, String uei, String[] matchList) throws SQLException, IOException
acknowledgeNotice
- Parameters:
event
- aEvent
object.uei
- aString
object.matchList
- an array ofString
objects.- Returns:
- a
Collection
object. - Throws:
SQLException
- if any.IOException
- if any.
-
acknowledgeNoticeBasedOnAlarms
public Collection<Integer> acknowledgeNoticeBasedOnAlarms(Event event) throws SQLException, IOException
acknowledgeNoticeBasedOnAlarms
- Parameters:
event
- aEvent
object.- Returns:
- a
Collection
object. - Throws:
SQLException
- if any.IOException
- if any.
-
getActiveNodes
public List<Integer> getActiveNodes() throws SQLException
getActiveNodes
- Returns:
- a
List
object. - Throws:
SQLException
- if any.
-
getServiceNoticeStatus
public String getServiceNoticeStatus(String nodeID, String ipaddr, String service) throws SQLException
getServiceNoticeStatus
- Parameters:
nodeID
- aString
object.ipaddr
- aString
object.service
- aString
object.- Returns:
- a
String
object. - Throws:
SQLException
- if any.
-
updateNoticeWithUserInfo
public void updateNoticeWithUserInfo(String userId, int noticeId, String media, String contactInfo, String autoNotify) throws SQLException, IOException
updateNoticeWithUserInfo
- Parameters:
userId
- aString
object.noticeId
- a int.media
- aString
object.contactInfo
- aString
object.autoNotify
- aString
object.- Throws:
IOException
- if any.SQLException
- if any.
-
insertNotice
public void insertNotice(int notifyId, Map<String,String> params, String queueID, Notification notification) throws 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:
SQLException
- if any.
-
getNotifications
public Map<String,Notification> getNotifications() throws IOException
getNotifications
- Returns:
- a
Map
object. - Throws:
IOException
- if any.
-
getServiceNames
public List<String> getServiceNames() throws SQLException
getServiceNames
- Returns:
- a
List
object. - Throws:
SQLException
-
getNotification
public Notification getNotification(String name) throws IOException
getNotification
- Parameters:
name
- aString
object.- Returns:
- a
Notification
object. - Throws:
IOException
- if any.
-
getNotificationNames
public List<String> getNotificationNames() throws IOException
getNotificationNames
- Returns:
- a
List
object. - Throws:
IOException
- if any.
-
removeNotification
public void removeNotification(String name) throws IOException, ClassNotFoundException
removeNotification
- Parameters:
name
- aString
object.- 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
- aString
object.newNotice
- aNotification
object.- 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, ClassNotFoundException
saveCurrent
- Throws:
IOException
- if any.ClassNotFoundException
- if any.
-
saveXML
protected abstract void saveXML(String xmlString) throws IOException
saveXML
- Parameters:
xmlString
- aString
object.- Throws:
IOException
- if any.
-
update
public abstract void update() throws IOException
update
- 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
- aMap
object.notification
- aNotification
object.
-
forEachUserNotification
public void forEachUserNotification(int notifId, RowProcessor rp)
forEachUserNotification
- Parameters:
notifId
- a int.rp
- aRowProcessor
object.
-
getQueueForNotification
public 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()
-
-