org.opennms.netmgt.config
Class NotificationManager

java.lang.Object
  extended by org.opennms.netmgt.config.NotificationManager
Direct Known Subclasses:
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
 Notifications m_notifications
          Object containing all Notification objects parsed from the xml file
static String PARAM_DESTINATION
          Constant PARAM_DESTINATION="-d"
static String PARAM_EMAIL
          Constant PARAM_EMAIL="-email"
static String PARAM_HOME_PHONE
          Constant PARAM_HOME_PHONE="-hphone"
static String PARAM_INTERFACE
          Constant PARAM_INTERFACE="-interface"
static String PARAM_MICROBLOG_USERNAME
          Constant PARAM_MICROBLOG_USERNAME="-ublog"
static String PARAM_MOBILE_PHONE
          Constant PARAM_MOBILE_PHONE="-mphone"
static String PARAM_NODE
          Constant PARAM_NODE="-nodeid"
static String PARAM_NUM_MSG
          Constant PARAM_NUM_MSG="-nm"
static String PARAM_NUM_PAGER_PIN
          Constant PARAM_NUM_PAGER_PIN="-np"
static String PARAM_PAGER_EMAIL
          Constant PARAM_PAGER_EMAIL="-pemail"
static String PARAM_RESPONSE
          Constant PARAM_RESPONSE="-r"
static String PARAM_SERVICE
          Constant PARAM_SERVICE="-service"
static String PARAM_SUBJECT
          Constant PARAM_SUBJECT="-subject"
static String PARAM_TEXT_MSG
          Constant PARAM_TEXT_MSG="-tm"
static String PARAM_TEXT_PAGER_PIN
          Constant PARAM_TEXT_PAGER_PIN="-tp"
static String PARAM_TUI_PIN
          Constant PARAM_TUI_PIN="-tuipin"
static String PARAM_TYPE
          Constant PARAM_TYPE="-t"
static String PARAM_WORK_PHONE
          Constant PARAM_WORK_PHONE="-wphone"
static String PARAM_XMPP_ADDRESS
          Constant PARAM_XMPP_ADDRESS="-xmpp"
 
Constructor Summary
protected NotificationManager(NotifdConfigManager configManager, DataSource dcf)
          Constructor for NotificationManager.
 
Method Summary
 Collection<Integer> acknowledgeNotice(Event event, String uei, String[] matchList)
          acknowledgeNotice
 void 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 notificaiton configuration XML.
static void expandMapValues(Map<String,String> map, Event event)
          expandMapValues
 void forEachUserNotification(int notifId, RowProcessor rp)
          forEachUserNotification
 List<Integer> getActiveNodes()
          getActiveNodes
protected  NotifdConfigManager getConfigManager()
          getConfigManager
 Event getEvent(int eventid)
          In the absence of DAOs and ORMs this creates an Event object from the persisted record.
 int getNoticeId()
          This method wraps the call to the database to get a sequence notice ID from the database.
 Notification[] getNotifForEvent(Event event)
          getNotifForEvent
 Notification getNotification(String name)
          getNotification
 List<String> getNotificationNames()
          getNotificationNames
 Map<String,Notification> getNotifications()
          getNotifications
 String getQueueForNotification(int notifId)
          getQueueForNotification
 List<String> getServiceNames()
          getServiceNames
 String getServiceNoticeStatus(String nodeID, String ipaddr, String service)
          getServiceNoticeStatus
 int getUserNotifId()
          getUserNotifId
 boolean hasUei(String uei)
          hasUei
 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)
          nodeInterfaceServiceValid
 boolean 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)
          parseXML
 void parseXML(Reader reader)
          Deprecated. 
 Map<String,String> rebuildParameterMap(int notifId, String resolutionPrefix, boolean skipNumericPrefix)
          rebuildParameterMap
 void removeNotification(String name)
          removeNotification
 void replaceNotification(String oldName, Notification newNotice)
          replaceNotification
 void saveCurrent()
          saveCurrent
protected abstract  void saveXML(String xmlString)
          saveXML
abstract  void update()
          update
 void updateNoticeWithUserInfo(String userId, int noticeId, String media, String contactInfo, String autoNotify)
          updateNoticeWithUserInfo
 void updateStatus(String name, String status)
          Sets the status on an individual notification configuration and saves to xml.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
Constant PARAM_TYPE="-t"

See Also:
Constant Field Values

PARAM_DESTINATION

public static final String PARAM_DESTINATION
Constant PARAM_DESTINATION="-d"

See Also:
Constant Field Values

PARAM_TEXT_MSG

public static final String PARAM_TEXT_MSG
Constant PARAM_TEXT_MSG="-tm"

See Also:
Constant Field Values

PARAM_NUM_MSG

public static final String PARAM_NUM_MSG
Constant PARAM_NUM_MSG="-nm"

See Also:
Constant Field Values

PARAM_RESPONSE

public static final String PARAM_RESPONSE
Constant PARAM_RESPONSE="-r"

See Also:
Constant Field Values

PARAM_NODE

public static final String PARAM_NODE
Constant PARAM_NODE="-nodeid"

See Also:
Constant Field Values

PARAM_INTERFACE

public static final String PARAM_INTERFACE
Constant PARAM_INTERFACE="-interface"

See Also:
Constant Field Values

PARAM_SERVICE

public static final String PARAM_SERVICE
Constant PARAM_SERVICE="-service"

See Also:
Constant Field Values

PARAM_SUBJECT

public static final String PARAM_SUBJECT
Constant PARAM_SUBJECT="-subject"

See Also:
Constant Field Values

PARAM_EMAIL

public static final String PARAM_EMAIL
Constant PARAM_EMAIL="-email"

See Also:
Constant Field Values

PARAM_PAGER_EMAIL

public static final String PARAM_PAGER_EMAIL
Constant PARAM_PAGER_EMAIL="-pemail"

See Also:
Constant Field Values

PARAM_XMPP_ADDRESS

public static final String PARAM_XMPP_ADDRESS
Constant PARAM_XMPP_ADDRESS="-xmpp"

See Also:
Constant Field Values

PARAM_TEXT_PAGER_PIN

public static final String PARAM_TEXT_PAGER_PIN
Constant PARAM_TEXT_PAGER_PIN="-tp"

See Also:
Constant Field Values

PARAM_NUM_PAGER_PIN

public static final String PARAM_NUM_PAGER_PIN
Constant PARAM_NUM_PAGER_PIN="-np"

See Also:
Constant Field Values

PARAM_WORK_PHONE

public static final String PARAM_WORK_PHONE
Constant PARAM_WORK_PHONE="-wphone"

See Also:
Constant Field Values

PARAM_HOME_PHONE

public static final String PARAM_HOME_PHONE
Constant PARAM_HOME_PHONE="-hphone"

See Also:
Constant Field Values

PARAM_MOBILE_PHONE

public static final String PARAM_MOBILE_PHONE
Constant PARAM_MOBILE_PHONE="-mphone"

See Also:
Constant Field Values

PARAM_TUI_PIN

public static final String PARAM_TUI_PIN
Constant PARAM_TUI_PIN="-tuipin"

See Also:
Constant Field Values

PARAM_MICROBLOG_USERNAME

public static final String PARAM_MICROBLOG_USERNAME
Constant PARAM_MICROBLOG_USERNAME="-ublog"

See Also:
Constant Field Values
Constructor Detail

NotificationManager

protected NotificationManager(NotifdConfigManager configManager,
                              DataSource dcf)

Constructor for NotificationManager.

Parameters:
configManager - a NotifdConfigManager object.
dcf - a DataSource object.
Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.
Method Detail

parseXML

@Deprecated
public void parseXML(Reader reader)
              throws org.exolab.castor.xml.MarshalException,
                     org.exolab.castor.xml.ValidationException
Deprecated. 

parseXML

Parameters:
reader - a Reader object.
Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

parseXML

public void parseXML(InputStream stream)
              throws org.exolab.castor.xml.MarshalException,
                     org.exolab.castor.xml.ValidationException

parseXML

Parameters:
stream - a InputStream object.
Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

hasUei

public boolean hasUei(String uei)
               throws IOException,
                      org.exolab.castor.xml.MarshalException,
                      org.exolab.castor.xml.ValidationException

hasUei

Parameters:
uei - a String object.
Returns:
a boolean.
Throws:
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

getNotifForEvent

public Notification[] getNotifForEvent(Event event)
                                throws IOException,
                                       org.exolab.castor.xml.MarshalException,
                                       org.exolab.castor.xml.ValidationException

getNotifForEvent

Parameters:
event - a Event object.
Returns:
an array of Notification objects.
Throws:
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

getConfigManager

protected NotifdConfigManager getConfigManager()

getConfigManager

Returns:
a NotifdConfigManager object.

nodeInterfaceServiceValid

protected boolean nodeInterfaceServiceValid(Notification notif,
                                            Event event)

nodeInterfaceServiceValid

Parameters:
notif - a Notification object.
event - a Event object.
Returns:
a boolean.

getNoticeId

public int getNoticeId()
                throws SQLException,
                       IOException,
                       org.exolab.castor.xml.MarshalException,
                       org.exolab.castor.xml.ValidationException
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.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

getUserNotifId

public int getUserNotifId()
                   throws SQLException,
                          IOException,
                          org.exolab.castor.xml.MarshalException,
                          org.exolab.castor.xml.ValidationException

getUserNotifId

Returns:
a int.
Throws:
SQLException - if any.
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

noticeOutstanding

public boolean noticeOutstanding(int noticeId)
                          throws IOException,
                                 org.exolab.castor.xml.MarshalException,
                                 org.exolab.castor.xml.ValidationException
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.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

acknowledgeNotice

public Collection<Integer> acknowledgeNotice(Event event,
                                             String uei,
                                             String[] matchList)
                                      throws SQLException,
                                             IOException,
                                             org.exolab.castor.xml.MarshalException,
                                             org.exolab.castor.xml.ValidationException

acknowledgeNotice

Parameters:
event - a Event object.
uei - a String object.
matchList - an array of String objects.
Returns:
a Collection object.
Throws:
SQLException - if any.
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - 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 - a String object.
ipaddr - a String object.
service - a String 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,
                                     org.exolab.castor.xml.MarshalException,
                                     org.exolab.castor.xml.ValidationException,
                                     IOException

updateNoticeWithUserInfo

Parameters:
userId - a String object.
noticeId - a int.
media - a String object.
contactInfo - a String object.
autoNotify - a String object.
Throws:
IOException - if any.
org.exolab.castor.xml.ValidationException - if any.
org.exolab.castor.xml.MarshalException - 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 - a String object.
notification - TODO
notifyId - a int.
params - a Map object.
Throws:
SQLException - if any.

getNotifications

public Map<String,Notification> getNotifications()
                                          throws IOException,
                                                 org.exolab.castor.xml.MarshalException,
                                                 org.exolab.castor.xml.ValidationException

getNotifications

Returns:
a Map object.
Throws:
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

getServiceNames

public List<String> getServiceNames()
                             throws SQLException

getServiceNames

Returns:
a List object.
Throws:
SQLException - if any.

getNotification

public Notification getNotification(String name)
                             throws IOException,
                                    org.exolab.castor.xml.MarshalException,
                                    org.exolab.castor.xml.ValidationException

getNotification

Parameters:
name - a String object.
Returns:
a Notification object.
Throws:
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

getNotificationNames

public List<String> getNotificationNames()
                                  throws IOException,
                                         org.exolab.castor.xml.MarshalException,
                                         org.exolab.castor.xml.ValidationException

getNotificationNames

Returns:
a List object.
Throws:
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

removeNotification

public void removeNotification(String name)
                        throws org.exolab.castor.xml.MarshalException,
                               org.exolab.castor.xml.ValidationException,
                               IOException,
                               ClassNotFoundException

removeNotification

Parameters:
name - a String object.
Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.
IOException - if any.
ClassNotFoundException - if any.

addNotification

public void addNotification(Notification notice)
                     throws org.exolab.castor.xml.MarshalException,
                            org.exolab.castor.xml.ValidationException,
                            IOException,
                            ClassNotFoundException
Handles adding a new Notification.

Parameters:
notice - The Notification to add.
Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.
IOException - if any.
ClassNotFoundException - if any.

replaceNotification

public void replaceNotification(String oldName,
                                Notification newNotice)
                         throws org.exolab.castor.xml.MarshalException,
                                org.exolab.castor.xml.ValidationException,
                                IOException,
                                ClassNotFoundException

replaceNotification

Parameters:
oldName - a String object.
newNotice - a Notification object.
Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.
IOException - if any.
ClassNotFoundException - if any.

updateStatus

public void updateStatus(String name,
                         String status)
                  throws org.exolab.castor.xml.MarshalException,
                         org.exolab.castor.xml.ValidationException,
                         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:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.
IOException - if any.
ClassNotFoundException - if any.

saveCurrent

public void saveCurrent()
                 throws org.exolab.castor.xml.MarshalException,
                        org.exolab.castor.xml.ValidationException,
                        IOException,
                        ClassNotFoundException

saveCurrent

Throws:
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.
IOException - if any.
ClassNotFoundException - if any.

saveXML

protected abstract void saveXML(String xmlString)
                         throws IOException

saveXML

Parameters:
xmlString - a String object.
Throws:
IOException - if any.

update

public abstract void update()
                     throws IOException,
                            org.exolab.castor.xml.MarshalException,
                            org.exolab.castor.xml.ValidationException

update

Throws:
IOException - if any.
org.exolab.castor.xml.MarshalException - if any.
org.exolab.castor.xml.ValidationException - if any.

rebuildParameterMap

public Map<String,String> rebuildParameterMap(int notifId,
                                              String resolutionPrefix,
                                              boolean skipNumericPrefix)
                                       throws Exception

rebuildParameterMap

Parameters:
notifId - a int.
resolutionPrefix - a String object.
skipNumericPrefix - a boolean.
Returns:
a Map object.
Throws:
Exception - if any.

addNotificationParams

public static void addNotificationParams(Map<String,String> paramMap,
                                         Notification notification)
Adds additional parameters defined by the user in the notificaiton configuration XML.

Parameters:
paramMap - a Map object.
notification - a Notification object.

forEachUserNotification

public void forEachUserNotification(int notifId,
                                    RowProcessor rp)

forEachUserNotification

Parameters:
notifId - a int.
rp - a RowProcessor object.

getQueueForNotification

public String getQueueForNotification(int notifId)

getQueueForNotification

Parameters:
notifId - a int.
Returns:
a String object.

expandMapValues

public static void expandMapValues(Map<String,String> map,
                                   Event event)

expandMapValues

Parameters:
map - a Map object.
event - a Event 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


Copyright © 2011. All Rights Reserved.