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

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
           
static String PARAM_EMAIL
           
static String PARAM_INTERFACE
           
static String PARAM_NODE
           
static String PARAM_NUM_MSG
           
static String PARAM_NUM_PAGER_PIN
           
static String PARAM_PAGER_EMAIL
           
static String PARAM_RESPONSE
           
static String PARAM_SERVICE
           
static String PARAM_SUBJECT
           
static String PARAM_TEXT_MSG
           
static String PARAM_TEXT_PAGER_PIN
           
static String PARAM_TYPE
           
static String PARAM_XMPP_ADDRESS
           
 
Constructor Summary
protected NotificationManager(NotifdConfigManager configManager, DataSource dcf)
           
 
Method Summary
 Collection<Integer> acknowledgeNotice(Event event, String uei, String[] matchList)
           
 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)
           
 void forEachUserNotification(int notifId, RowProcessor rp)
           
 List<Integer> getActiveNodes()
           
protected  NotifdConfigManager 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)
           
 Notification getNotification(String name)
           
 List<String> getNotificationNames()
           
 Map<String,Notification> getNotifications()
           
 String getQueueForNotification(int notifId)
           
 List<String> getServiceNames()
           
 String getServiceNoticeStatus(String nodeID, String ipaddr, String service)
           
 int getUserNotifId()
           
 boolean hasUei(String uei)
           
 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)
           
 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(Reader reader)
           
 Map<String,String> rebuildParameterMap(int notifId, String resolutionPrefix, boolean skipNumericPrefix)
           
 void removeNotification(String name)
           
 void replaceNotification(String oldName, Notification newNotice)
           
 void saveCurrent()
           
protected abstract  void saveXML(String xmlString)
           
protected abstract  void update()
           
 void updateNoticeWithUserInfo(String userId, int noticeId, String media, String contactInfo, String autoNotify)
           
 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
See Also:
Constant Field Values

PARAM_DESTINATION

public static final String PARAM_DESTINATION
See Also:
Constant Field Values

PARAM_TEXT_MSG

public static final String PARAM_TEXT_MSG
See Also:
Constant Field Values

PARAM_NUM_MSG

public static final String PARAM_NUM_MSG
See Also:
Constant Field Values

PARAM_RESPONSE

public static final String PARAM_RESPONSE
See Also:
Constant Field Values

PARAM_NODE

public static final String PARAM_NODE
See Also:
Constant Field Values

PARAM_INTERFACE

public static final String PARAM_INTERFACE
See Also:
Constant Field Values

PARAM_SERVICE

public static final String PARAM_SERVICE
See Also:
Constant Field Values

PARAM_SUBJECT

public static final String PARAM_SUBJECT
See Also:
Constant Field Values

PARAM_EMAIL

public static final String PARAM_EMAIL
See Also:
Constant Field Values

PARAM_PAGER_EMAIL

public static final String PARAM_PAGER_EMAIL
See Also:
Constant Field Values

PARAM_XMPP_ADDRESS

public static final String PARAM_XMPP_ADDRESS
See Also:
Constant Field Values

PARAM_TEXT_PAGER_PIN

public static final String PARAM_TEXT_PAGER_PIN
See Also:
Constant Field Values

PARAM_NUM_PAGER_PIN

public static final String PARAM_NUM_PAGER_PIN
See Also:
Constant Field Values
Constructor Detail

NotificationManager

protected NotificationManager(NotifdConfigManager configManager,
                              DataSource dcf)
Parameters:
configIn -
Throws:
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException
Method Detail

parseXML

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

hasUei

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

getNotifForEvent

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

getConfigManager

protected NotifdConfigManager getConfigManager()
Returns:

nodeInterfaceServiceValid

protected boolean nodeInterfaceServiceValid(Notification notif,
                                            Event event)

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
IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

getUserNotifId

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

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.

Throws:
IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

acknowledgeNotice

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

getActiveNodes

public List<Integer> getActiveNodes()
                             throws SQLException
Throws:
SQLException

getServiceNoticeStatus

public String getServiceNoticeStatus(String nodeID,
                                     String ipaddr,
                                     String service)
                              throws SQLException
Throws:
SQLException

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
Throws:
IOException
org.exolab.castor.xml.ValidationException
org.exolab.castor.xml.MarshalException
SQLException

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 -
notification - TODO
Throws:
SQLException

getNotifications

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

getServiceNames

public List<String> getServiceNames()
                             throws SQLException
Throws:
SQLException

getNotification

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

getNotificationNames

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

removeNotification

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

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
org.exolab.castor.xml.ValidationException
IOException
ClassNotFoundException

replaceNotification

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

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
org.exolab.castor.xml.ValidationException
IOException
ClassNotFoundException

saveCurrent

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

saveXML

protected abstract void saveXML(String xmlString)
                         throws IOException
Parameters:
xmlString -
Throws:
IOException

update

protected abstract void update()
                        throws IOException,
                               org.exolab.castor.xml.MarshalException,
                               org.exolab.castor.xml.ValidationException
Throws:
IOException
org.exolab.castor.xml.MarshalException
org.exolab.castor.xml.ValidationException

rebuildParameterMap

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

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 -
notification -

forEachUserNotification

public void forEachUserNotification(int notifId,
                                    RowProcessor rp)
Parameters:
notifId -

getQueueForNotification

public String getQueueForNotification(int notifId)
Parameters:
notifId -
Returns:

expandMapValues

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

getEvent

public Event getEvent(int eventid)
In the absence of DAOs and ORMs this creates an Event object from the persisted record.

Parameters:
eventid -
Returns:
a populated Event object


Copyright © 2009. All Rights Reserved.