atg.service.email.pop
Class StoreService

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.service.email.pop.StoreService
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, Schedulable, java.util.EventListener
Direct Known Subclasses:
POP3Service

public class StoreService
extends GenericService
implements Schedulable

A class used to expose a Store as a nucleus service. This class is responsible for checking for inbound email and emmitting inbound email and bounced email events.

See Also:
Store

Field Summary
static java.lang.String CLASS_VERSION
          Class version string
protected  int mBatchSize
          The size of the batch of emails before we close and reopen the mail folder
protected  java.util.ArrayList mBounceListeners
          Maintained list of bounced email listeners
protected  java.util.ArrayList mEmailExaminers
          Maintained list of email examiners
protected  boolean mEnabled
          True if this mail store should be polled.
protected  boolean mFireBouncedMailEvents
          Indicates whether we want to fire BouncedMailEvents
protected  boolean mFireInboundMailEvents
          Indicates whether we want to fire InboundMailEvents
protected  java.lang.String mFolder
          The folder to retrieve messages from.
protected  java.lang.String mHost
          Specifies the hostname
protected  java.util.ArrayList mInboundListeners
          Maintained list of inbound email listeners
protected  int mJobId
          The id of the scheduled job this service performs
protected  java.lang.String mPassword
          Specifies the password
protected  java.lang.String mPasswordAlias
          the password alias for password access
protected  atg.security.AliasedPasswordBroker mPasswordBroker
          password broker to use
protected  int mPort
          Specifies the port
protected  java.lang.String mProtocol
          The mail protocol to use when retrieving messages
protected  boolean mRemoveBouncedEMail
          Specifies whether bounced email should be removed from the server
protected  boolean mRemoveEMail
          Specifies whether normal email should be removed from the server
protected  boolean mRemoveMalformedEmail
          Specifies whether malformed email is discarded, or treated like normal
protected  boolean mRemoveUnsupportedEncodingEMail
          Specifies whether email using unsupported encodings should be removed from the server
protected  Schedule mSchedule
          The schedule under which we check for email
protected  Scheduler mScheduler
          The scheduler service we use to tell us when to check for email
protected  java.lang.String mUsername
          Specifies the username
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
StoreService()
          Create a disconnected StoreService object
 
Method Summary
 void addBounceListener(atg.service.email.pop.POP3BounceListener l)
          Add a listener for a bounced email event
 void addEmailExaminer(EmailExaminer pEmailExaminer)
          Adds an email examiner to this service
 void addInboundListener(atg.service.email.pop.POP3InboundMailListener pInboundListener)
          Adds a listener for an inbound event
 void doStartService()
          Starts the Store service.
 void doStopService()
          Stops the service.
 void fireInboundMailEvent(javax.mail.Message pMsg, boolean pBounced)
          Notify listening objects that an email has been received
 void fireInboundMailEvent(javax.mail.Message pMessage, boolean pBounced, EmailExaminer pExaminer)
          Notify listening objects that an email has been received
 void fireMailBounceEvent(java.lang.String address, java.lang.String date, int id)
          Notify listening objects of bounce events.
 void fireMailBounceEvent(java.lang.String address, java.lang.String date, int id, boolean isSoftBounce, java.util.Map atgHeaders, java.util.Map trackingData)
          Notify listening objects of bounce events.
 int getBatchSize()
          The size of the batch of messages we should process before reopening the folder.
 EmailExaminer[] getEmailExaminers()
          Gets the EmailExaminers property
 java.lang.String getFolder()
          Gets the folder to retrieve email from If unset, the "INBOX" will be used.
 java.lang.String getHost()
          Retrieves the host for the active POP session
 java.lang.String getPassword()
          Retrieves the password for the active POP session
 java.lang.String getPasswordAlias()
          Returns property passwordAlias
 atg.security.AliasedPasswordBroker getPasswordBroker()
          Returns property passwordBroker
 int getPort()
          Retrieves the port for the active POP session
 java.lang.String getProtocol()
          The mail protocol to use when retrieving messages Default implementations are "pop3" and "imap".
 boolean getRemoveBouncedEMail()
          Retrieves the remove bounced email flag
 boolean getRemoveEMail()
          Retrieves the remove email flag
 boolean getRemoveMalformedEmail()
          Returns property discardMalformedEmail
 boolean getRemoveUnsupportedEncodingEMail()
          Retrieves the remove unsuppported encoding email flag
 Schedule getSchedule()
          Gets the schedule property
 Scheduler getScheduler()
          Gets the value of the scheduler property
 java.lang.String getUsername()
          Retrieves the username for the active POP session
 boolean isEnabled()
          Gets the enabled property.
 boolean isFireBouncedMailEvents()
          Gets the fireBouncedMailEvents property
 boolean isFireInboundMailEvents()
          Gets the fireInboundMailEvents property
 void performScheduledTask(Scheduler pScheduler, ScheduledJob pJob)
          Performs the scheduled task for this service.
 void removeBounceListener(atg.service.email.pop.POP3BounceListener l)
          Remove a bounce event listener.
 void removeEmailExaminer(EmailExaminer pEmailExaminer)
          Removes an email examiner from this service
 void removeInboundListener(atg.service.email.pop.POP3InboundMailListener pInboundListener)
          Removes an inbound listener.
 void setBatchSize(int pBatchSize)
          The size of the batch of messages we should process before reopening the folder.
 void setEmailExaminers(EmailExaminer[] pEmailExaminers)
          Sets the EmailExaminers property
 void setEnabled(boolean pEnabled)
          Sets the enabled property.
 void setFireBouncedMailEvents(boolean pFireBouncedMailEvents)
          Sets the fireBouncedMailEvents property
 void setFireInboundMailEvents(boolean pFireInboundMailEvents)
          Sets the fireInboundMailEvents property
 void setFolder(java.lang.String folder)
          Sets the folder to retrieve email from.
 void setHost(java.lang.String host)
          Sets the host for the active POP session
 void setPassword(java.lang.String password)
          Sets the password for the active POP session
 void setPasswordAlias(java.lang.String pPasswordAlias)
          Sets property passwordAlias
 void setPasswordBroker(atg.security.AliasedPasswordBroker pPasswordBroker)
          Sets property passwordBroker
 void setPort(int port)
          Sets the port for the active POP session
 void setProtocol(java.lang.String protocol)
          The mail protocol to use when retrieving messages.
 void setRemoveBouncedEMail(boolean remove)
          Sets the flag for removing bounced email from the mail server
 void setRemoveEMail(boolean remove)
          Sets the flag for removing email from the mail server
 void setRemoveMalformedEmail(boolean pRemoveMalformedEmail)
          Sets property discardMalformedEmail
 void setRemoveUnspportedEncodingEMail(boolean remove)
          Sets the flag for removing email that uses an unsupported encoding from the mail server
 void setSchedule(Schedule pSchedule)
          Sets the schedule property
 void setScheduler(Scheduler pScheduler)
          Sets the scheduler property
 void setUsername(java.lang.String username)
          Sets the username for the active POP session
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


mEnabled

protected boolean mEnabled
True if this mail store should be polled.


mProtocol

protected java.lang.String mProtocol
The mail protocol to use when retrieving messages

See Also:
Session.getProvider(String)

mUsername

protected java.lang.String mUsername
Specifies the username


mPassword

protected java.lang.String mPassword
Specifies the password


mHost

protected java.lang.String mHost
Specifies the hostname


mPort

protected int mPort
Specifies the port


mFolder

protected java.lang.String mFolder
The folder to retrieve messages from.

See Also:
Store.getFolder(String)

mRemoveBouncedEMail

protected boolean mRemoveBouncedEMail
Specifies whether bounced email should be removed from the server


mRemoveEMail

protected boolean mRemoveEMail
Specifies whether normal email should be removed from the server


mRemoveMalformedEmail

protected boolean mRemoveMalformedEmail
Specifies whether malformed email is discarded, or treated like normal


mRemoveUnsupportedEncodingEMail

protected boolean mRemoveUnsupportedEncodingEMail
Specifies whether email using unsupported encodings should be removed from the server


mBounceListeners

protected java.util.ArrayList mBounceListeners
Maintained list of bounced email listeners


mInboundListeners

protected java.util.ArrayList mInboundListeners
Maintained list of inbound email listeners


mEmailExaminers

protected java.util.ArrayList mEmailExaminers
Maintained list of email examiners


mJobId

protected int mJobId
The id of the scheduled job this service performs


mScheduler

protected Scheduler mScheduler
The scheduler service we use to tell us when to check for email


mSchedule

protected Schedule mSchedule
The schedule under which we check for email


mFireInboundMailEvents

protected boolean mFireInboundMailEvents
Indicates whether we want to fire InboundMailEvents


mFireBouncedMailEvents

protected boolean mFireBouncedMailEvents
Indicates whether we want to fire BouncedMailEvents


mBatchSize

protected int mBatchSize
The size of the batch of emails before we close and reopen the mail folder


mPasswordBroker

protected atg.security.AliasedPasswordBroker mPasswordBroker
password broker to use


mPasswordAlias

protected java.lang.String mPasswordAlias
the password alias for password access

Constructor Detail

StoreService

public StoreService()
Create a disconnected StoreService object

Method Detail

setPasswordAlias

public void setPasswordAlias(java.lang.String pPasswordAlias)
Sets property passwordAlias

Parameters:
pPasswordAlias - the alias to use for fetching the smtp connection password

getPasswordAlias

public java.lang.String getPasswordAlias()
Returns property passwordAlias

Returns:
the alias to use for fetching the smtp connection password

setPasswordBroker

public void setPasswordBroker(atg.security.AliasedPasswordBroker pPasswordBroker)
Sets property passwordBroker

Parameters:
pPasswordBroker - the password broker to use for password retrieval

getPasswordBroker

public atg.security.AliasedPasswordBroker getPasswordBroker()
Returns property passwordBroker

Returns:
the password broker to use for password retrieval

getScheduler

public Scheduler getScheduler()
Gets the value of the scheduler property

Returns:
the Scheduler service that tells this service when to check for mail

setScheduler

public void setScheduler(Scheduler pScheduler)
Sets the scheduler property

Parameters:
pScheduler - the scheduler service that tells this service when to check for mail

getSchedule

public Schedule getSchedule()
Gets the schedule property

Returns:
the schedule under which this service checks for email

setSchedule

public void setSchedule(Schedule pSchedule)
Sets the schedule property

Parameters:
pSchedule - the schedule under which this service checks for email

isEnabled

public boolean isEnabled()
Gets the enabled property.


setEnabled

public void setEnabled(boolean pEnabled)
Sets the enabled property.


setEmailExaminers

public void setEmailExaminers(EmailExaminer[] pEmailExaminers)
Sets the EmailExaminers property

Parameters:
pEmailExaminers -

getEmailExaminers

public EmailExaminer[] getEmailExaminers()
Gets the EmailExaminers property

Returns:
pEmailExaminers
See Also:
EmailExaminer

addEmailExaminer

public void addEmailExaminer(EmailExaminer pEmailExaminer)
Adds an email examiner to this service

Parameters:
pEmailExaminer - the email examiner to add

removeEmailExaminer

public void removeEmailExaminer(EmailExaminer pEmailExaminer)
Removes an email examiner from this service

Parameters:
pEmailExaminer - the email examiner to remove

setProtocol

public void setProtocol(java.lang.String protocol)
The mail protocol to use when retrieving messages. Default implementations are "pop3" and "imap".

Parameters:
protocol - The protocol
See Also:
Session.getProvider(String)

getProtocol

public java.lang.String getProtocol()
The mail protocol to use when retrieving messages Default implementations are "pop3" and "imap".

Returns:
The protocol
See Also:
Session.getProvider(String)

setUsername

public void setUsername(java.lang.String username)
Sets the username for the active POP session

Parameters:
username - The username

getUsername

public java.lang.String getUsername()
Retrieves the username for the active POP session

Returns:
The username

setPassword

public void setPassword(java.lang.String password)
Sets the password for the active POP session

Parameters:
password - The password

getPassword

@Hidden
public java.lang.String getPassword()
Retrieves the password for the active POP session

Returns:
The password

setHost

public void setHost(java.lang.String host)
Sets the host for the active POP session

Parameters:
host - The host

getHost

public java.lang.String getHost()
Retrieves the host for the active POP session

Returns:
The host

setPort

public void setPort(int port)
Sets the port for the active POP session

Parameters:
port - The port

getPort

public int getPort()
Retrieves the port for the active POP session

Returns:
The port

setFolder

public void setFolder(java.lang.String folder)
Sets the folder to retrieve email from. If unset, the "INBOX" will be used.

Parameters:
folder - The folder
See Also:
Store.getFolder(String), Store.getDefaultFolder()

getFolder

public java.lang.String getFolder()
Gets the folder to retrieve email from If unset, the "INBOX" will be used.

Returns:
The folder
See Also:
Store.getFolder(String), Store.getDefaultFolder()

setRemoveBouncedEMail

public void setRemoveBouncedEMail(boolean remove)
Sets the flag for removing bounced email from the mail server

Parameters:
remove - false or true

getRemoveBouncedEMail

public boolean getRemoveBouncedEMail()
Retrieves the remove bounced email flag


setRemoveEMail

public void setRemoveEMail(boolean remove)
Sets the flag for removing email from the mail server

Parameters:
remove - false or true

getRemoveEMail

public boolean getRemoveEMail()
Retrieves the remove email flag


setRemoveMalformedEmail

public void setRemoveMalformedEmail(boolean pRemoveMalformedEmail)
Sets property discardMalformedEmail

Parameters:
pRemoveMalformedEmail - indicates whether malformed email should be immediately discarded, or should be treated as a normal email

getRemoveMalformedEmail

public boolean getRemoveMalformedEmail()
Returns property discardMalformedEmail

Returns:
indicates whether malformed email should be immediately discarded, or should be treated as a normal email

setRemoveUnspportedEncodingEMail

public void setRemoveUnspportedEncodingEMail(boolean remove)
Sets the flag for removing email that uses an unsupported encoding from the mail server

Parameters:
remove - false or true

getRemoveUnsupportedEncodingEMail

public boolean getRemoveUnsupportedEncodingEMail()
Retrieves the remove unsuppported encoding email flag


setFireBouncedMailEvents

public void setFireBouncedMailEvents(boolean pFireBouncedMailEvents)
Sets the fireBouncedMailEvents property

Parameters:
pFireBouncedMailEvents - if true, then events will be fired if a bounced email is received

isFireBouncedMailEvents

public boolean isFireBouncedMailEvents()
Gets the fireBouncedMailEvents property

Returns:
whether events are fired if a bounced email is received

setFireInboundMailEvents

public void setFireInboundMailEvents(boolean pFireInboundMailEvents)
Sets the fireInboundMailEvents property

Parameters:
pFireInboundMailEvents - if true, then events will be fired for each email received by the client

isFireInboundMailEvents

public boolean isFireInboundMailEvents()
Gets the fireInboundMailEvents property

Returns:
whether events are fired for each email received by the client

addBounceListener

public void addBounceListener(atg.service.email.pop.POP3BounceListener l)
Add a listener for a bounced email event

Parameters:
l - The POP3BounceListener to add

removeBounceListener

public void removeBounceListener(atg.service.email.pop.POP3BounceListener l)
Remove a bounce event listener.

Parameters:
l - The POP3BounceListener to remove.

addInboundListener

public void addInboundListener(atg.service.email.pop.POP3InboundMailListener pInboundListener)
Adds a listener for an inbound event

Parameters:
pInboundListener - The POP3InboundListener to add

removeInboundListener

public void removeInboundListener(atg.service.email.pop.POP3InboundMailListener pInboundListener)
Removes an inbound listener.

Parameters:
pInboundListener - The POP3InboundListener to remove.

setBatchSize

public void setBatchSize(int pBatchSize)
The size of the batch of messages we should process before reopening the folder.

Parameters:
pBatchSize - The size of the batch

getBatchSize

public int getBatchSize()
The size of the batch of messages we should process before reopening the folder.

Returns:
The size of the batch

fireMailBounceEvent

public void fireMailBounceEvent(java.lang.String address,
                                java.lang.String date,
                                int id)
Notify listening objects of bounce events.

Parameters:
address - The offending email address
date - The date of the original sent email
id - The id of the original sent email

fireMailBounceEvent

public void fireMailBounceEvent(java.lang.String address,
                                java.lang.String date,
                                int id,
                                boolean isSoftBounce,
                                java.util.Map atgHeaders,
                                java.util.Map trackingData)
Notify listening objects of bounce events.

Parameters:
address - The offending email address
date - The date of the original sent email
id - The id of the original sent email
isSoftBounce - A flag indicating if this is a soft bounce.
atgHeaders - A map of ATG headers contained in the bounced message.
trackingData - A map of tracking data contained in the bounced message
See Also:
EmailTrackingTools

fireInboundMailEvent

public void fireInboundMailEvent(javax.mail.Message pMsg,
                                 boolean pBounced)
Notify listening objects that an email has been received

Parameters:
pMsg - The Message that was created for this email
pBounced - whether or not this message was bounced

fireInboundMailEvent

public void fireInboundMailEvent(javax.mail.Message pMessage,
                                 boolean pBounced,
                                 EmailExaminer pExaminer)
Notify listening objects that an email has been received

Parameters:
pMsg - The Message that was created for this email
pBounced - whether or not this message was bounced

doStartService

public void doStartService()
                    throws ServiceException
Starts the Store service.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if an error occurs during startup of this service

doStopService

public void doStopService()
                   throws ServiceException
Stops the service.

Overrides:
doStopService in class GenericService
Throws:
ServiceException - if an error occurs while the service tried to stop

performScheduledTask

public void performScheduledTask(Scheduler pScheduler,
                                 ScheduledJob pJob)
Performs the scheduled task for this service. This includes checking the server for email, and firing InboundMailEvents and MailBounceEvents.

Specified by:
performScheduledTask in interface Schedulable
Parameters:
pScheduler - the scheduler that alerts this service to perform its scheduled task
pJob - the ScheduledJob for this service