com.isti.quakewatch.alertemail
Class AlertEmailRecipient

java.lang.Object
  extended by com.isti.quakewatch.alert.AlertRecipient
      extended by com.isti.quakewatch.alertemail.AlertEmailRecipient
All Implemented Interfaces:
AlertRecipientInterface, AlertEmailRecipientInterface

public class AlertEmailRecipient
extends AlertRecipient
implements AlertEmailRecipientInterface

Class AlertEmailRecipient defines a QuakeWatch Emailer alert recipient. NOTE: Every subclass must have a constructor with a 'QWProgramInformationInterface' and 'Element' parameter.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.isti.quakewatch.alert.AlertRecipient
AlertRecipient.RecipientSetupException
 
Field Summary
protected  NotifyEventQueue alertEmailMessageQueue
          Queue for alert-email messages.
protected  AlertEmailSenderInterface alertEmailSenderObj
          EmailSenderInterface object.
 CfgPropItem emailAddressListProp
          List of one or more email addresses for recipient.
 CfgPropItem emailsEnabledFlagProp
          Flag set true to enable sending of emails to recipient.
 CfgPropItem longEmailFormatFlagProp
          Flag set true to enable "long" message format for emails.
protected  long numberOfAlertsCount
          Counter for number of alert messages have been sent.
 
Fields inherited from class com.isti.quakewatch.alert.AlertRecipient
alarmCfgProps, ALARMS_GROUP_STR, alertRecipientClassNameProp, cfgProps, classNameText, defaultClassName, GENERAL_GROUP_STR, globalAlarmEnabledFlagProp, logObj, MSG_CANCEL_TYPE, MSG_NEWEVT_TYPE, MSG_UPDATE_TYPE, progInfoObj, recipDeletedFlag, RECIPIENT_CLASSNAME, RECIPIENT_NAMESTR, recipientNameProp
 
Constructor Summary
  AlertEmailRecipient(AlertEmailRecipient sourceRecipientObj)
          Creates an new recipient, with all fields set equal to those in the given recipient.
  AlertEmailRecipient(QWProgramInformationInterface progInfoObj)
          Creates an "empty" recipient, with all fields set to default values.
  AlertEmailRecipient(QWProgramInformationInterface progInfoObj, org.jdom.Element recipientElementObj)
          Creates an new recipient, with fields filled via the given "Recipient" element object.
protected AlertEmailRecipient(QWProgramInformationInterface progInfoObj, org.jdom.Element recipientElementObj, boolean initFlag)
          Creates an new recipient, with fields filled via the given "Recipient" element object.
 
Method Summary
protected  AlertEmailMessage createAlertEmailMessage(QWEventMsgRecord recObj, int messageType)
          Creates an alert email message.
static AlertEmailSenderInterface getAlertEmailSender(QWProgramInformationInterface progInfoObj)
          Gets the 'AlertEmailSenderInterface'.
 NotifyEventQueue getAlertMessageQueue()
          Returns the alert-message-queue object for this recipient.
 java.lang.String getEmailAddressListStr()
          Returns the list of email addresses for this recipient.
 java.lang.String getRecipID()
          Returns an ID string for this recipient.
protected  void init(org.jdom.Element recipientElementObj)
          Initialize the recipient.
 boolean isSendEnabled()
          Returns the status of whether or not sending emails is enabled for this recipient.
protected  void pushAlertEmailMsgToQueue(AlertEmailMessageInterface emailMsgObj)
          Pushes given alert-email message onto the transmit queue.
 void sendAlertMessage(QWEventMsgRecord recObj, int messageType)
          Generates an alert email message for the given event-message record.
 void setSendEnabled(boolean b)
          Sets the status of whether or not sending is enabled for this recipient.
protected  void setupMessageQueue(boolean startThreadFlag)
          Sets up the queue for transmitting alert-email messages.
 void terminateMsgQueueThread()
          Terminates the processing thread for the queue for transmitting alert-email messages.
 java.lang.String toString()
          Returns a string representation of this recipient.
protected  void transmitAlertEmailMessage(AlertEmailMessageInterface emailMsgObj)
          Transmits the given alert-email message.
 
Methods inherited from class com.isti.quakewatch.alert.AlertRecipient
addToEventRecAlarmRecipList, checkAlarmEventRec, clearEventRecAlarmRecipList, createAlertRecipient, doSendAlertMessage, getAlarmCfgProps, getAlarmRegionStrings, getEventRecAlarmRecipList, getLogPrefixText, getNumRegions, getRecipDeletedFlag, getRecipientName, isGlobalAlarmEnabled, loadFromElement, loadRecipients, loadRecipients, newInstance, popFirstEventRecAlarmRecip, saveRecipients, sendCancelAlertMessage, sendNewAlertMessage, sendUpdateAlertMessage, setGlobalAlarmEnabled, setIstiRegionMgrObj, setRecipDeletedFlag, setRecipientName, toElement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.isti.quakewatch.alert.AlertRecipientInterface
isGlobalAlarmEnabled
 

Field Detail

alertEmailSenderObj

protected final AlertEmailSenderInterface alertEmailSenderObj
EmailSenderInterface object.


alertEmailMessageQueue

protected NotifyEventQueue alertEmailMessageQueue
Queue for alert-email messages.


numberOfAlertsCount

protected long numberOfAlertsCount
Counter for number of alert messages have been sent.


emailAddressListProp

public final CfgPropItem emailAddressListProp
List of one or more email addresses for recipient.


emailsEnabledFlagProp

public final CfgPropItem emailsEnabledFlagProp
Flag set true to enable sending of emails to recipient.


longEmailFormatFlagProp

public final CfgPropItem longEmailFormatFlagProp
Flag set true to enable "long" message format for emails.

Constructor Detail

AlertEmailRecipient

public AlertEmailRecipient(QWProgramInformationInterface progInfoObj,
                           org.jdom.Element recipientElementObj)
                    throws AlertRecipient.RecipientSetupException
Creates an new recipient, with fields filled via the given "Recipient" element object.

Parameters:
progInfoObj - the 'QWProgramInformationInterface' object.
recipientElementObj - the recipient object to use.
Throws:
RecipientSetupException - if an error occurs while loading fields from the element object.
AlertRecipient.RecipientSetupException

AlertEmailRecipient

protected AlertEmailRecipient(QWProgramInformationInterface progInfoObj,
                              org.jdom.Element recipientElementObj,
                              boolean initFlag)
                       throws AlertRecipient.RecipientSetupException
Creates an new recipient, with fields filled via the given "Recipient" element object.

Parameters:
progInfoObj - the 'QWProgramInformationInterface' object.
recipientElementObj - the recipient object to use.
initFlag - true to initialize the recipient, false otherwise.
Throws:
RecipientSetupException - if an error occurs while loading fields from the element object. NOTE: If the recipient is not intialized via the constructor (the 'initFlag' is false) the 'init()' method should be called.
AlertRecipient.RecipientSetupException
See Also:
init

AlertEmailRecipient

public AlertEmailRecipient(QWProgramInformationInterface progInfoObj)
                    throws AlertRecipient.RecipientSetupException
Creates an "empty" recipient, with all fields set to default values.

Parameters:
progInfoObj - the 'QWProgramInformationInterface' object.
Throws:
RecipientSetupException - if an error occurs.
AlertRecipient.RecipientSetupException

AlertEmailRecipient

public AlertEmailRecipient(AlertEmailRecipient sourceRecipientObj)
                    throws AlertRecipient.RecipientSetupException
Creates an new recipient, with all fields set equal to those in the given recipient.

Parameters:
sourceRecipientObj - the recipient object to use.
Throws:
RecipientSetupException - if an error occurs.
AlertRecipient.RecipientSetupException
Method Detail

init

protected final void init(org.jdom.Element recipientElementObj)
                   throws AlertRecipient.RecipientSetupException
Initialize the recipient.

Parameters:
recipientElementObj - the recipient object to use.
Throws:
RecipientSetupException - if an error occurs while loading fields from the element object.
AlertRecipient.RecipientSetupException

getAlertEmailSender

public static AlertEmailSenderInterface getAlertEmailSender(QWProgramInformationInterface progInfoObj)
                                                     throws AlertRecipient.RecipientSetupException
Gets the 'AlertEmailSenderInterface'.

Parameters:
progInfoObj - QWProgramInformationInterface
Returns:
the 'AlertEmailSenderInterface'.
Throws:
RecipientSetupException - if an error occurs.
AlertRecipient.RecipientSetupException

getEmailAddressListStr

public java.lang.String getEmailAddressListStr()
Returns the list of email addresses for this recipient.

Specified by:
getEmailAddressListStr in interface AlertEmailRecipientInterface
Returns:
A string containing the list of email addresses for this recipient.

setupMessageQueue

protected final void setupMessageQueue(boolean startThreadFlag)
Sets up the queue for transmitting alert-email messages.

Parameters:
startThreadFlag - true to start the message-processing thread.

terminateMsgQueueThread

public void terminateMsgQueueThread()
Terminates the processing thread for the queue for transmitting alert-email messages.

Specified by:
terminateMsgQueueThread in class AlertRecipient

getRecipID

public java.lang.String getRecipID()
Returns an ID string for this recipient.

Specified by:
getRecipID in interface AlertRecipientInterface
Returns:
An ID string for this recipient.

toString

public java.lang.String toString()
Returns a string representation of this recipient.

Specified by:
toString in class AlertRecipient
Returns:
A new string in the following format: "name" .

isSendEnabled

public boolean isSendEnabled()
Returns the status of whether or not sending emails is enabled for this recipient.

Specified by:
isSendEnabled in class AlertRecipient
Returns:
true if sending emails is enabled; false if not.

getAlertMessageQueue

public NotifyEventQueue getAlertMessageQueue()
Returns the alert-message-queue object for this recipient.

Specified by:
getAlertMessageQueue in interface AlertRecipientInterface
Specified by:
getAlertMessageQueue in class AlertRecipient
Returns:
The alert-message-queue object for this recipient.

sendAlertMessage

public void sendAlertMessage(QWEventMsgRecord recObj,
                             int messageType)
Generates an alert email message for the given event-message record.

Specified by:
sendAlertMessage in class AlertRecipient
Parameters:
messageType - message type value for message.
recObj - the message-record object for the event.

setSendEnabled

public void setSendEnabled(boolean b)
Sets the status of whether or not sending is enabled for this recipient.

Specified by:
setSendEnabled in class AlertRecipient
Parameters:
b - true if sending is enabled; false if not.

createAlertEmailMessage

protected AlertEmailMessage createAlertEmailMessage(QWEventMsgRecord recObj,
                                                    int messageType)
Creates an alert email message. If the parameters match those used to create the previous alert email message then the previous object will be reused.

Parameters:
messageType - message type value for message.
recObj - the message-record object for the event.
Returns:
An 'AlertEmailMessage' for the given parameters, or null if the network data-source code for the given event-message record is not supported.

pushAlertEmailMsgToQueue

protected void pushAlertEmailMsgToQueue(AlertEmailMessageInterface emailMsgObj)
Pushes given alert-email message onto the transmit queue.

Parameters:
emailMsgObj - the alert-email-message object to use.

transmitAlertEmailMessage

protected void transmitAlertEmailMessage(AlertEmailMessageInterface emailMsgObj)
Transmits the given alert-email message.

Parameters:
emailMsgObj - the alert-email-message object to use.