Class 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 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
        Constant PARAM_TYPE="-t"
        See Also:
        Constant Field Values
      • PARAM_DESTINATION

        public static final java.lang.String PARAM_DESTINATION
        Constant PARAM_DESTINATION="-d"
        See Also:
        Constant Field Values
      • PARAM_TEXT_MSG

        public static final java.lang.String PARAM_TEXT_MSG
        Constant PARAM_TEXT_MSG="-tm"
        See Also:
        Constant Field Values
      • PARAM_NUM_MSG

        public static final java.lang.String PARAM_NUM_MSG
        Constant PARAM_NUM_MSG="-nm"
        See Also:
        Constant Field Values
      • PARAM_RESPONSE

        public static final java.lang.String PARAM_RESPONSE
        Constant PARAM_RESPONSE="-r"
        See Also:
        Constant Field Values
      • PARAM_NODE

        public static final java.lang.String PARAM_NODE
        Constant PARAM_NODE="-nodeid"
        See Also:
        Constant Field Values
      • PARAM_INTERFACE

        public static final java.lang.String PARAM_INTERFACE
        Constant PARAM_INTERFACE="-interface"
        See Also:
        Constant Field Values
      • PARAM_SERVICE

        public static final java.lang.String PARAM_SERVICE
        Constant PARAM_SERVICE="-service"
        See Also:
        Constant Field Values
      • PARAM_SUBJECT

        public static final java.lang.String PARAM_SUBJECT
        Constant PARAM_SUBJECT="-subject"
        See Also:
        Constant Field Values
      • PARAM_EMAIL

        public static final java.lang.String PARAM_EMAIL
        Constant PARAM_EMAIL="-email"
        See Also:
        Constant Field Values
      • PARAM_PAGER_EMAIL

        public static final java.lang.String PARAM_PAGER_EMAIL
        Constant PARAM_PAGER_EMAIL="-pemail"
        See Also:
        Constant Field Values
      • PARAM_XMPP_ADDRESS

        public static final java.lang.String PARAM_XMPP_ADDRESS
        Constant PARAM_XMPP_ADDRESS="-xmpp"
        See Also:
        Constant Field Values
      • PARAM_TEXT_PAGER_PIN

        public static final java.lang.String PARAM_TEXT_PAGER_PIN
        Constant PARAM_TEXT_PAGER_PIN="-tp"
        See Also:
        Constant Field Values
      • PARAM_NUM_PAGER_PIN

        public static final java.lang.String PARAM_NUM_PAGER_PIN
        Constant PARAM_NUM_PAGER_PIN="-np"
        See Also:
        Constant Field Values
      • PARAM_WORK_PHONE

        public static final java.lang.String PARAM_WORK_PHONE
        Constant PARAM_WORK_PHONE="-wphone"
        See Also:
        Constant Field Values
      • PARAM_HOME_PHONE

        public static final java.lang.String PARAM_HOME_PHONE
        Constant PARAM_HOME_PHONE="-hphone"
        See Also:
        Constant Field Values
      • PARAM_MOBILE_PHONE

        public static final java.lang.String PARAM_MOBILE_PHONE
        Constant PARAM_MOBILE_PHONE="-mphone"
        See Also:
        Constant Field Values
      • PARAM_TUI_PIN

        public static final java.lang.String PARAM_TUI_PIN
        Constant PARAM_TUI_PIN="-tuipin"
        See Also:
        Constant Field Values
      • PARAM_MICROBLOG_USERNAME

        public static final java.lang.String PARAM_MICROBLOG_USERNAME
        Constant PARAM_MICROBLOG_USERNAME="-ublog"
        See Also:
        Constant Field Values
    • Constructor Detail

      • NotificationManager

        protected NotificationManager​(NotifdConfigManager configManager,
                                      javax.sql.DataSource dcf)

        Constructor for NotificationManager.

        Parameters:
        configManager - a NotifdConfigManager object.
        dcf - a DataSource 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 string
        paramMap - 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 - a Reader object.
      • parseXML

        public void parseXML​(java.io.InputStream stream)
                      throws java.io.IOException

        parseXML

        Parameters:
        stream - a InputStream object.
        Throws:
        java.io.IOException
      • hasUei

        public boolean hasUei​(java.lang.String uei)
                       throws java.io.IOException

        hasUei

        Parameters:
        uei - a String object.
        Returns:
        a boolean.
        Throws:
        java.io.IOException - if any.
      • getNotifForEvent

        public Notification[] getNotifForEvent​(Event event)
                                        throws java.io.IOException

        getNotifForEvent

        Parameters:
        event - a Event object.
        Returns:
        an array of Notification objects.
        Throws:
        java.io.IOException - if any.
      • 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 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 - a Event object.
        uei - a String object.
        matchList - an array of String 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 - a Event 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 - a String object.
        ipaddr - a String object.
        service - a String 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 - a String object.
        noticeId - a int.
        media - a String object.
        contactInfo - a String object.
        autoNotify - a String 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 - a String object.
        notification - TODO
        notifyId - a int.
        params - a Map 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 - a String 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 - a String 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 - a String object.
        newNotice - a Notification 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 - a String 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 - a String 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 - 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 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()