atg.userprofiling.email
Class TemplateEmailSender

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.userprofiling.email.TemplateEmailSender
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, atg.servlet.TemplateEmailConstants, java.util.EventListener

public class TemplateEmailSender
extends GenericService
implements atg.servlet.TemplateEmailConstants

The TemplateEmailSender service is responsible for sending template-based email. Given a TemplateEmailInfo and a list of recipient profiles, it renders the jhtml page specified via the TemplateEmailInfo's templateURL property for each of the profiles, uses that to create a Message, and sends each message to the corresponding user.

The template rendering functionality in TemplateEmailSender is implemented with the help of its templateRendererServlet. In the service's standard configuration, this property points to the head of Dynamo's servlet pipeline. Thus, the template page is rendered simply as if it were a jhtml page requested through a browser. However, one can configure the templateRendererServlet property to point to any custom Servlet, which might implement a different scheme for rendering the page.

It's also possible to change the rendering behavior more dramatically by subclassing this service and overriding some of its methods. Here is a detailed description of the rendering process corresponding to a single call to TemplateEmailSender's sendEmailMessage, together with pointers for how the default behavior might be overriden:

  1. Given a TemplateEmailInfo which points to a particular templateURL, we create a request/response pair (specifically, instances of DynamoHttpServletRequest and DynamoHttpServletResponse) which will be reused to render the template for each of the recipient profiles. The path info in the request is set to point to the templateURL. In addition, the request is serviced once using the requestSetupServlet (which, in the standard configuration, again points to the head of the servlet pipeline) - this associates the request with a session, sets it up for name resolution, and so on.
  2. For each recipient profile, we call the methods initializeRequest and initializeResponse to initialize request/response with any recipient-specific information. The default implementation associates the session-scoped Profile object in the request with the given profile object; this allows us to resolve any references to the profile attributes in the template page when the template is being rendered. Subclasses may override these methods to implement other schemes for associating the recipient's profile with the request, etc.
  3. For each recipient profile, we call the method renderTemplate, which takes the already initialized request/response pair and actually performs the rendering. The default implementation simply calls the templateRendererServlet's service method, and captures and returns the output in the response. If you are implementing your own Servlet to do the rendering, note that your servlet can access the template URL by calling getPathInfo on the request. Again, you can also override this method and implement a different scheme for rendering the template.
  4. The actual sending of the email is performed by an EmailMessageSender, pointed at by the service's emailMessageSender property.

    See Also:
    TemplateEmailInfo, EmailMessageSender

    Nested Class Summary
     class TemplateEmailSender.TemplateEmailSenderResReqInitter
              An implementation of a RequestResponseInitializer that calls through to initializeRequest and initializeResponse.
     
    Field Summary
    static java.lang.String ATG_MAILING_ID_HEADER_NAME
              The name of the mailingId header.
    static java.lang.String ATG_MAILING_ID_HEADER_NAME_TO_LOWER
              The name of the mailingId header.
    static java.lang.String CLASS_VERSION
              Class version string
    static java.lang.String[] INCOMPLETE_STATUSES
               
    static ParameterName PARAM_MESSAGE_FILL_FROM_TEMPLATE
               
     
    Fields inherited from class atg.nucleus.GenericService
    SERVICE_INFO_KEY
     
    Fields inherited from interface atg.servlet.TemplateEmailConstants
    ATTR_EMAIL_SESSION, ATTR_INPUT_PARAMS, ATTR_PREFIX, ATTR_SESSION_COOKIES, PARAM_FILL_FROM_TEMPLATE, PARAM_MAILING_NAME, PARAM_MESSAGE_ATTACHMENTS, PARAM_MESSAGE_BCC, PARAM_MESSAGE_CC, PARAM_MESSAGE_FROM, PARAM_MESSAGE_REPLY_TO, PARAM_MESSAGE_SUBJECT, PARAM_MESSAGE_TO, TEMPLATE_PARAMS
     
    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
    TemplateEmailSender()
               
     
    Method Summary
     void addTemplateEmailListener(TemplateEmailListener pListener)
              Adds a listener to the list of TemplateEmailListeners.
    protected  javax.servlet.Servlet createAdminServlet()
              Creates and returns a new Servlet that will administer this service.
     javax.mail.Message createMessage(TemplateEmailInfo pEmailInfo, java.lang.Object pRecipient)
              Given a TemplateEmailInfo and a specific recipient profile, renders the page specified by the TemplateEmailInfo's templateURL for that profile, and creates a Message with the resulting content.
     void doStartService()
              Called after the service has been created, placed into the naming hierarchy, and initialized with its configured property values.
     void doStopService()
              This is called when a Service is required to shut down.
     boolean getAlwaysPruneAfterRendering()
              Get prune after rendering, which does any alternative pruning after render, rather than using mime-type from the previous rendering.
     java.lang.String getApplicationPrefix()
              Returns the Dynamo application prefix.
     long getAppServerConnectRetryTime()
              Gets the AppServerConnectRetryTime property
     atg.userprofiling.email.BatchEmailPeriodicService getBatchEmailPeriodicService()
              Get the batch email periodic service.
     java.lang.String getContextPathPrefix()
              Returns the string that this TemplateEmailSender should prepend to all template URLs.
     int getCreateMessagesBatchSize()
               
     java.lang.Float getDaysContactFatigue()
               
     java.lang.String getDynamoInitSessionURL()
              Get the URL for a page from which to obtain the initial session on DAS.
     java.lang.String getEmailAddressPropertyName()
              Returns the property name of the email address in the profile.
     java.util.Properties getEmailEncodingMap()
              Gets the mEmailEncodingMap property
     EmailMessageSender getEmailMessageSender()
              Returns the EmailMessageSender that will send out email messages.
     java.lang.String getEmailStatusInvalidOptionValue()
              Returns the option value for invalid email status in the profile.
     java.lang.String getEmailStatusPropertyName()
              Returns the property name of the email status in the profile.
     java.lang.String getEmailStatusValidOptionValue()
              Returns the option value for valid email status in the profile.
     atg.servlet.pagecompile.PageEncodingTyper getEncodingTyper()
              The EncodingTyper used by the pagecompiler rendering the email msg.
     java.lang.Float getHoursContactFatigue()
               
     java.lang.String getInitSessionURL()
              Returns the URL to use when creating a session via a loopback request, when running in another app server.
     java.lang.String getLastEmailedPropertyName()
              Returns the property name of the email last sent timestamp in the profile.
     java.lang.String getLocalePropertyName()
              Returns the property name of the locale in the profile.
     boolean getLoopbackRequestsEnabled()
              Returns the flag indicating whether loopback requests should be performed when running in another app server.
     atg.userprofiling.email.TemplateEmailBatchInfo getNextBatchMailing(boolean pClaim)
              Return the next batch mailing to process.
     int getNumAppServerConnectAttempts()
              Gets the NumAppServerConnectAttempts property
     java.lang.String getProfilePath()
              Returns the Nucleus path of the session-scoped Profile object.
     java.lang.String getReceiveEmailPropertyName()
              Returns the property name of the receiveEmail property in the profile.
     java.lang.String getRequestLocalePath()
              Returns the Nucleus path of the session-scoped RequestLocale object.
     HeadPipelineServlet getRequestSetupServlet()
              Returns the HeadPipelineServlet that will be used to service each newly created request and thus setup the request for name resolution, associate it with a session, etc.
     boolean getRestartRequestThread()
              Gets the mRestartRequestThread property
     atg.servlet.sessiontracking.DynamoSessionManager getSessionManager()
              Returns the session manager.
     SiteContextManager getSiteContextManager()
               
     java.lang.String getSiteHttpServerName()
              Returns the name of the server configured to serve HTTP requests.
     int getSiteHttpServerPort()
              Returns the port of the server configured to serve HTTP requests.
     atg.userprofiling.email.TemplateEmailBatchPersister getTemplateEmailBatchPersister()
              Get the TemplateEmailBatchPersister that will persist batch related data.
     atg.userprofiling.email.TemplateEmailBatchServerPersister getTemplateEmailBatchServerPersister()
              Set the template email batch server perisister...
     int getTemplateEmailListenerCount()
              Returns the number of TemplateEmailListeners.
     TemplateEmailListener[] getTemplateEmailListeners()
              Returns the array of TemplateEmailListener objects.
     atg.userprofiling.email.TemplateEmailPersister getTemplateEmailPersister()
              Returns the TemplateEmailPersister that will send out email messages.
     TemplateInvoker getTemplateInvoker()
               
     javax.servlet.Servlet getTemplateRendererServlet()
              Returns the Servlet responsible for rendering the template.
     java.lang.String getTemplateURL(java.lang.String pTemplateURL)
              Returns the given template URL prepended if contextPathPrefix, if any.
     java.lang.String getTemplateURL(TemplateEmailInfo pTemplateEmailInfo)
              Returns the template URL of the given TemplateEmailInfo, prepended if contextPathPrefix, if any.
     javax.transaction.TransactionManager getTransactionManager()
              Returns the TransactionManager.
     int getUpdateBatchCountsEveryNMessages()
              When doing batch processing, how often to update the counts in the database.
     int getUpdateProfileStatusesEveryNMessages()
              How often to update the profile email statuses...
    protected  void initializeRequest(DynamoHttpServletRequest pRequest, java.lang.Object pRecipient)
              Initializes the request to contain any recipient-specific information.
    protected  void initializeResponse(DynamoHttpServletResponse pResponse, java.lang.Object pRecipient)
              Initializes the response to contain any recipient-specific information.
     boolean isAddingDebuggingHeaders()
              Whether we are adding debugging headers identifying host and thread.
     boolean isAddingMailingIdHeader()
              Whether to add the mailing id header.
     boolean isBatchIfPossible()
              Get whether to batch email messages if possible (that is if there are no transient profiles).
     boolean isBypassRecipientVerification()
              Whether to bypass recipient verification before attempting to send an email.
     boolean isEnabledAsTemplateMailServer()
               
     boolean isSetValidEmailStatus()
              Whether to set valid email status when an email is sent successfully.
    protected  boolean recipientIsContactFatigued(TemplateEmailInfo pEmailInfo, java.lang.Object pRecipient)
              Return whether the recipient is considered contact fatigued.
     void removeTemplateEmailListener(TemplateEmailListener pListener)
              Removes a listener from the list of TemplateEmailListeners.
     void sendBatch(atg.userprofiling.email.TemplateEmailBatchInfo pBatchInfo)
              restartMailing
     void sendEmailMessage(TemplateEmailInfo pEmailInfo, java.util.Collection pRecipients)
              Sends an email message described by the TemplateEmailInfo to each of the recipient profile objects in the Collection.
     void sendEmailMessage(TemplateEmailInfo pEmailInfo, java.util.Collection pRecipients, boolean pRunInSeparateThread, boolean pPersist)
              Sends an email message described by the TemplateEmailInfo to each of the recipient profile objects in the Collection.
     void sendEmailMessage(TemplateEmailInfo pEmailInfo, java.util.Enumeration pRecipients)
              Sends an email message described by the TemplateEmailInfo to each of the recipient profile objects in the array.
     void sendEmailMessage(TemplateEmailInfo pEmailInfo, java.util.Enumeration pRecipients, boolean pRunInSeparateThread, boolean pPersist)
              Sends an email message described by the TemplateEmailInfo to each of the recipient profile objects in the array.
     void sendEmailMessage(TemplateEmailInfo pEmailInfo, java.lang.Object[] pRecipients)
              Sends an email message described by the TemplateEmailInfo to each of the recipient profile objects in the array.
     void sendEmailMessage(TemplateEmailInfo pEmailInfo, java.lang.Object[] pRecipients, boolean pRunInSeparateThread, boolean pPersist)
              Sends an email message described by the TemplateEmailInfo to each of the recipient profile objects in the array.
    protected  void sendEmailNotSentEvent(TemplateEmailInfo pEmailInfo, java.lang.Object pRecipient, javax.mail.Message pMessage, java.lang.String pErrorMessage)
              Sends a TemplateEmailEvent signifying that a message could not be sent to all the TemplateEmailListener objects.
    protected  void sendEmailSentEvent(TemplateEmailInfo pEmailInfo, java.lang.Object pRecipient, javax.mail.Message pMessage)
              Sends a TemplateEmailEvent signifying that a message was sent successfully to all the TemplateEmailListener objects.
     void serviceNextBatchMailing()
              Service the next bath mailing, if any.
     void setAddingDebuggingHeaders(boolean pAddingDebuggingHeaders)
              Whether to add debugging headers identifying host and thread.
     void setAddingMailingIdHeader(boolean pAddingMailingIdHeader)
              Whether to add the mailing id header.
     void setAlwaysPruneAfterRendering(boolean pAlwaysPruneAfterRendering)
              Set prune after rendering, which does any alternative pruning after render, rather than using mime-type from the previous rendering.
     void setApplicationPrefix(java.lang.String pApplicationPrefix)
              Sets the Dynamo application prefix.
     void setAppServerConnectRetryTime(long pAppServerConnectRetryTime)
              Sets the AppServerConnectRetryTime property
     void setBatchEmailPeriodicService(atg.userprofiling.email.BatchEmailPeriodicService pBatchEmailPeriodicService)
              Set the batch email periodic service.
     void setBatchIfPossible(boolean pBatchIfPossible)
              Set whether to batch email messages if possible (that is if there are no transient profiles).
     void setBypassRecipientVerification(boolean pBypassRecipientVerification)
              Whether to bypass recipient verification before attempting to send an email
     void setContextPathPrefix(java.lang.String pContextPathPrefix)
              Sets the string that this TemplateEmailSender should prepend to all template URLs.
     void setCreateMessagesBatchSize(int pCreateMessagesBatchSize)
              Sets the maximum number of messages created in one batch
     void setDaysContactFatigue(java.lang.Float pDaysContactFatigue)
               
     void setDynamoInitSessionURL(java.lang.String pDynamoInitSessionURL)
              Set the URL for a page from which to obtain the initial session on DAS.
     void setEmailAddressPropertyName(java.lang.String pPropertyName)
              Sets the property name of the email address in the profile.
     void setEmailEncodingMap(java.util.Properties pProperties)
              Sets the mEmailEncodingMap property
     void setEmailMessageSender(EmailMessageSender pSender)
              Sets the EmailMessageSender that will send out email messages.
     void setEmailStatusInvalidOptionValue(java.lang.String pEmailStatusInvalidOptionValue)
              Sets the options value for invalid email status for a profile.
     void setEmailStatusPropertyName(java.lang.String pPropertyName)
              Sets the property name of the email status in the profile.
     void setEmailStatusValidOptionValue(java.lang.String pEmailStatusValidOptionValue)
              Sets the options value for valid email status for a profile.
     void setEnabledAsTemplateMailServer(boolean pEnabledAsTemplateMailServer)
               
     void setEncodingTyper(atg.servlet.pagecompile.PageEncodingTyper pValue)
              The EncodingTyper used by the pagecompiler rendering the email msg.
     void setHoursContactFatigue(java.lang.Float pHoursContactFatigue)
               
     void setInitSessionURL(java.lang.String pInitSessionURL)
              Sets the URL to use when creating a session via a loopback request, when running in another app server.
     void setLastEmailedPropertyName(java.lang.String pLastEmailedPropertyName)
              Sets the property name of the email last sent timestamp in the profile.
     void setLocalePropertyName(java.lang.String pPropertyName)
              Sets the property name of the locale in the profile.
     void setLoopbackRequestsEnabled(boolean pLoopbackRequestsEnabled)
              Sets the flag indicating whether loopback requests should be performed when running in another app server.
     void setNumAppServerConnectAttempts(int pNumAppServerConnectAttempts)
              Sets the NumAppServerConnectAttempts property
     void setProfilePath(java.lang.String pProfilePath)
              Sets the Nucleus path of the session-scoped Profile object.
     void setReceiveEmailPropertyName(java.lang.String pPropertyName)
              Sets the property name of the receiveEmail property in the profile.
     void setRequestLocalePath(java.lang.String pRequestLocalePath)
              Sets the Nucleus path of the session-scoped RequestLocale object.
     void setRequestSetupServlet(HeadPipelineServlet pServlet)
              Sets the HeadPipelineServlet that will be used to service each newly created request and thus setup the request for name resolution, associate it with a session, etc.
     void setRestartRequestThread(boolean pRestartRequestThread)
              Sets the mRestartRequestThread property
     void setSessionManager(atg.servlet.sessiontracking.DynamoSessionManager pSessionManager)
              Sets the session manager.
     void setSetValidEmailStatus(boolean pSetValidEmailStatus)
              Whether to set valid email status when an email is sent successfully.
     void setSiteContextManager(SiteContextManager pSiteContextManager)
               
     void setSiteHttpServerName(java.lang.String pSiteHttpServerName)
              Sets the name of the server configured to serve HTTP requests.
     void setSiteHttpServerPort(int port)
              Sets the port of the server configured to serve HTTP requests.
     void setTemplateEmailBatchPersister(atg.userprofiling.email.TemplateEmailBatchPersister pTemplateEmailBatchPersister)
              Set the TemplateEmailBatchPersister that will persist batch related data.
     void setTemplateEmailBatchServerPersister(atg.userprofiling.email.TemplateEmailBatchServerPersister pTemplateEmailBatchServerPersister)
              Set the template email batch server perisister...
     void setTemplateEmailPersister(atg.userprofiling.email.TemplateEmailPersister pTemplateEmailPersister)
              Sets the TemplateEmailPersister that will send out email messages.
     void setTemplateInvoker(TemplateInvoker pTemplateInvoker)
               
     void setTemplateRendererServlet(javax.servlet.Servlet pServlet)
              Sets the Servlet responsible for rendering the template.
     void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
              Sets the TransactionManager.
     void setUpdateBatchCountsEveryNMessages(int pUpdateBatchCountsEveryNMessages)
              When doing batch processing, how often to update the counts in the database.
     void setUpdateProfileStatusesEveryNMessages(int pUpdateProfileStatusesEveryNMessages)
              How often to update the profile email statuses...
     
    Methods inherited from class atg.nucleus.GenericService
    addLogListener, 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


    PARAM_MESSAGE_FILL_FROM_TEMPLATE

    public static final ParameterName PARAM_MESSAGE_FILL_FROM_TEMPLATE

    INCOMPLETE_STATUSES

    public static final java.lang.String[] INCOMPLETE_STATUSES

    ATG_MAILING_ID_HEADER_NAME

    public static java.lang.String ATG_MAILING_ID_HEADER_NAME
    The name of the mailingId header.


    ATG_MAILING_ID_HEADER_NAME_TO_LOWER

    public static java.lang.String ATG_MAILING_ID_HEADER_NAME_TO_LOWER
    The name of the mailingId header.

    Constructor Detail

    TemplateEmailSender

    public TemplateEmailSender()
    Method Detail

    setAppServerConnectRetryTime

    public void setAppServerConnectRetryTime(long pAppServerConnectRetryTime)
    Sets the AppServerConnectRetryTime property

    Parameters:
    pAppServerConnectRetryTime - the length of time to wait in between connections to the underlying app server if we are unable to connect. In non-DAS environments, we need to call the init-session servlet to get a session to use when sending email. If we try to send email before the app server has started up, this service will keep trying to connect to the app server to see if it has started yet.

    getAppServerConnectRetryTime

    public long getAppServerConnectRetryTime()
    Gets the AppServerConnectRetryTime property

    Returns:
    the length of time to wait in between connections to the underlying app server if we are unable to connect. In non-DAS environments, we need to call the init-session servlet to get a session to use when sending email. If we try to send email before the app server has started up, this service will keep trying to connect to the app server to see if it has started yet.

    setNumAppServerConnectAttempts

    public void setNumAppServerConnectAttempts(int pNumAppServerConnectAttempts)
    Sets the NumAppServerConnectAttempts property

    Parameters:
    pNumAppServerConnectAttempts - the number of attempts made to connect to the underlying app server if we are unable to hit the init-session servlet on the first try. In non-DAS environments, we need to call the init-session servlet to get a session to use when sending email. If we try to send email before the app server has started up, this service will keep trying to connect to the app server to see if it has started yet.

    getNumAppServerConnectAttempts

    public int getNumAppServerConnectAttempts()
    Gets the NumAppServerConnectAttempts property

    Returns:
    the number of attempts made to connect to the underlying app server if we are unable to hit the init-session servlet on the first try. In non-DAS environments, we need to call the init-session servlet to get a session to use when sending email. If we try to send email before the app server has started up, this service will keep trying to connect to the app server to see if it has started yet.

    getSiteHttpServerName

    public java.lang.String getSiteHttpServerName()
    Returns the name of the server configured to serve HTTP requests. This is used for loopback requests when running in another app server.


    setSiteHttpServerName

    public void setSiteHttpServerName(java.lang.String pSiteHttpServerName)
    Sets the name of the server configured to serve HTTP requests. This is used for loopback requests when running in another app server.


    getSiteHttpServerPort

    public int getSiteHttpServerPort()
    Returns the port of the server configured to serve HTTP requests. This is used for loopback requests when running in another app server.


    setSiteHttpServerPort

    public void setSiteHttpServerPort(int port)
    Sets the port of the server configured to serve HTTP requests. This is used for loopback requests when running in another app server.


    getSiteContextManager

    public SiteContextManager getSiteContextManager()
    Returns:
    the mSiteContextManager

    setSiteContextManager

    public void setSiteContextManager(SiteContextManager pSiteContextManager)
    Parameters:
    mSiteContextManager - the mSiteContextManager to set

    getApplicationPrefix

    public java.lang.String getApplicationPrefix()
    Returns the Dynamo application prefix. This is used for loopback requests when running in another app server.


    setApplicationPrefix

    public void setApplicationPrefix(java.lang.String pApplicationPrefix)
    Sets the Dynamo application prefix. This is used for loopback requests when running in another app server.


    getInitSessionURL

    public java.lang.String getInitSessionURL()
    Returns the URL to use when creating a session via a loopback request, when running in another app server.


    setInitSessionURL

    public void setInitSessionURL(java.lang.String pInitSessionURL)
    Sets the URL to use when creating a session via a loopback request, when running in another app server.


    setDynamoInitSessionURL

    public void setDynamoInitSessionURL(java.lang.String pDynamoInitSessionURL)
    Set the URL for a page from which to obtain the initial session on DAS.


    getDynamoInitSessionURL

    public java.lang.String getDynamoInitSessionURL()
    Get the URL for a page from which to obtain the initial session on DAS.


    getSessionManager

    public atg.servlet.sessiontracking.DynamoSessionManager getSessionManager()
    Returns the session manager.


    setSessionManager

    public void setSessionManager(atg.servlet.sessiontracking.DynamoSessionManager pSessionManager)
    Sets the session manager.


    getLoopbackRequestsEnabled

    public boolean getLoopbackRequestsEnabled()
    Returns the flag indicating whether loopback requests should be performed when running in another app server.


    setLoopbackRequestsEnabled

    public void setLoopbackRequestsEnabled(boolean pLoopbackRequestsEnabled)
    Sets the flag indicating whether loopback requests should be performed when running in another app server.

    This value is true by default. It can be set to false if you are only using this TemplateEmailSender with DSP templates, rather than JSP templates, since DSP templates can always be rendered without making loopback requests.

    Note: if you set this property to false, you should also set the contextPathPrefix property to null, so that the template URLs are not prefixed with "/dyn/dyn," but left to be relative to the Dynamo docroot.


    getContextPathPrefix

    public java.lang.String getContextPathPrefix()
    Returns the string that this TemplateEmailSender should prepend to all template URLs.


    setContextPathPrefix

    public void setContextPathPrefix(java.lang.String pContextPathPrefix)
    Sets the string that this TemplateEmailSender should prepend to all template URLs. For example, if this is set to "/myapp", and an email template is passed in with template URL "/path/email.jhtml", then the template URL that will be rendered is "/myapp/path/email.jhtml." If null, nothing is prepended.


    getTemplateURL

    public java.lang.String getTemplateURL(TemplateEmailInfo pTemplateEmailInfo)
    Returns the template URL of the given TemplateEmailInfo, prepended if contextPathPrefix, if any.


    getTemplateURL

    public java.lang.String getTemplateURL(java.lang.String pTemplateURL)
    Returns the given template URL prepended if contextPathPrefix, if any.


    setRestartRequestThread

    public void setRestartRequestThread(boolean pRestartRequestThread)
    Sets the mRestartRequestThread property


    getRestartRequestThread

    public boolean getRestartRequestThread()
    Gets the mRestartRequestThread property


    setEmailEncodingMap

    public void setEmailEncodingMap(java.util.Properties pProperties)
    Sets the mEmailEncodingMap property


    getEmailEncodingMap

    public java.util.Properties getEmailEncodingMap()
    Gets the mEmailEncodingMap property


    setBatchIfPossible

    public void setBatchIfPossible(boolean pBatchIfPossible)
    Set whether to batch email messages if possible (that is if there are no transient profiles).


    isBatchIfPossible

    public boolean isBatchIfPossible()
    Get whether to batch email messages if possible (that is if there are no transient profiles).


    setEnabledAsTemplateMailServer

    public void setEnabledAsTemplateMailServer(boolean pEnabledAsTemplateMailServer)

    isEnabledAsTemplateMailServer

    public boolean isEnabledAsTemplateMailServer()

    setBatchEmailPeriodicService

    public void setBatchEmailPeriodicService(atg.userprofiling.email.BatchEmailPeriodicService pBatchEmailPeriodicService)
    Set the batch email periodic service.


    getBatchEmailPeriodicService

    public atg.userprofiling.email.BatchEmailPeriodicService getBatchEmailPeriodicService()
    Get the batch email periodic service.


    setTemplateInvoker

    public void setTemplateInvoker(TemplateInvoker pTemplateInvoker)

    getTemplateInvoker

    public TemplateInvoker getTemplateInvoker()

    setAlwaysPruneAfterRendering

    public void setAlwaysPruneAfterRendering(boolean pAlwaysPruneAfterRendering)
    Set prune after rendering, which does any alternative pruning after render, rather than using mime-type from the previous rendering.


    getAlwaysPruneAfterRendering

    public boolean getAlwaysPruneAfterRendering()
    Get prune after rendering, which does any alternative pruning after render, rather than using mime-type from the previous rendering.


    setAddingDebuggingHeaders

    public void setAddingDebuggingHeaders(boolean pAddingDebuggingHeaders)
    Whether to add debugging headers identifying host and thread.


    isAddingDebuggingHeaders

    public boolean isAddingDebuggingHeaders()
    Whether we are adding debugging headers identifying host and thread.


    setAddingMailingIdHeader

    public void setAddingMailingIdHeader(boolean pAddingMailingIdHeader)
    Whether to add the mailing id header.


    isAddingMailingIdHeader

    public boolean isAddingMailingIdHeader()
    Whether to add the mailing id header.


    setUpdateBatchCountsEveryNMessages

    public void setUpdateBatchCountsEveryNMessages(int pUpdateBatchCountsEveryNMessages)
    When doing batch processing, how often to update the counts in the database. Values greater than one may increase performance, but also increase the chance of duplicate messages on failure or fail-over.


    getUpdateBatchCountsEveryNMessages

    public int getUpdateBatchCountsEveryNMessages()
    When doing batch processing, how often to update the counts in the database. Values greater than one may increase performance, but also increase the chance of duplicate messages on failure or fail-over.


    setUpdateProfileStatusesEveryNMessages

    public void setUpdateProfileStatusesEveryNMessages(int pUpdateProfileStatusesEveryNMessages)
    How often to update the profile email statuses... a value greater than one should improve performance, but means that in case of failure, all email statuses may not be up to date.


    getUpdateProfileStatusesEveryNMessages

    public int getUpdateProfileStatusesEveryNMessages()
    How often to update the profile email statuses... a value greater than one should improve performance, but means that in case of failure, all email statuses may not be up to date.


    getTemplateEmailPersister

    public atg.userprofiling.email.TemplateEmailPersister getTemplateEmailPersister()
    Returns the TemplateEmailPersister that will send out email messages.


    setTemplateEmailPersister

    public void setTemplateEmailPersister(atg.userprofiling.email.TemplateEmailPersister pTemplateEmailPersister)
    Sets the TemplateEmailPersister that will send out email messages.


    setTemplateEmailBatchPersister

    public void setTemplateEmailBatchPersister(atg.userprofiling.email.TemplateEmailBatchPersister pTemplateEmailBatchPersister)
    Set the TemplateEmailBatchPersister that will persist batch related data.


    getTemplateEmailBatchPersister

    public atg.userprofiling.email.TemplateEmailBatchPersister getTemplateEmailBatchPersister()
    Get the TemplateEmailBatchPersister that will persist batch related data.


    setTemplateEmailBatchServerPersister

    public void setTemplateEmailBatchServerPersister(atg.userprofiling.email.TemplateEmailBatchServerPersister pTemplateEmailBatchServerPersister)
    Set the template email batch server perisister... used to get a list of the batched servers.


    getTemplateEmailBatchServerPersister

    public atg.userprofiling.email.TemplateEmailBatchServerPersister getTemplateEmailBatchServerPersister()
    Set the template email batch server perisister... used to get a list of the batch servers.


    setSetValidEmailStatus

    public void setSetValidEmailStatus(boolean pSetValidEmailStatus)
    Whether to set valid email status when an email is sent successfully.


    isSetValidEmailStatus

    public boolean isSetValidEmailStatus()
    Whether to set valid email status when an email is sent successfully.


    setBypassRecipientVerification

    public void setBypassRecipientVerification(boolean pBypassRecipientVerification)
    Whether to bypass recipient verification before attempting to send an email


    isBypassRecipientVerification

    public boolean isBypassRecipientVerification()
    Whether to bypass recipient verification before attempting to send an email.


    setHoursContactFatigue

    public void setHoursContactFatigue(java.lang.Float pHoursContactFatigue)

    getHoursContactFatigue

    public java.lang.Float getHoursContactFatigue()

    setDaysContactFatigue

    public void setDaysContactFatigue(java.lang.Float pDaysContactFatigue)

    getDaysContactFatigue

    public java.lang.Float getDaysContactFatigue()

    getTransactionManager

    public javax.transaction.TransactionManager getTransactionManager()
    Returns the TransactionManager.


    setTransactionManager

    public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
    Sets the TransactionManager.


    getEmailMessageSender

    public EmailMessageSender getEmailMessageSender()
    Returns the EmailMessageSender that will send out email messages.


    setEmailMessageSender

    public void setEmailMessageSender(EmailMessageSender pSender)
    Sets the EmailMessageSender that will send out email messages.


    getRequestSetupServlet

    public HeadPipelineServlet getRequestSetupServlet()
    Returns the HeadPipelineServlet that will be used to service each newly created request and thus setup the request for name resolution, associate it with a session, etc.


    setRequestSetupServlet

    public void setRequestSetupServlet(HeadPipelineServlet pServlet)
    Sets the HeadPipelineServlet that will be used to service each newly created request and thus setup the request for name resolution, associate it with a session, etc.


    getProfilePath

    public java.lang.String getProfilePath()
    Returns the Nucleus path of the session-scoped Profile object.


    setProfilePath

    public void setProfilePath(java.lang.String pProfilePath)
    Sets the Nucleus path of the session-scoped Profile object.


    getRequestLocalePath

    public java.lang.String getRequestLocalePath()
    Returns the Nucleus path of the session-scoped RequestLocale object.


    setRequestLocalePath

    public void setRequestLocalePath(java.lang.String pRequestLocalePath)
    Sets the Nucleus path of the session-scoped RequestLocale object.


    getLastEmailedPropertyName

    public java.lang.String getLastEmailedPropertyName()
    Returns the property name of the email last sent timestamp in the profile. This will be used to access the email last sent (expected to be a timestamp) from each of the recipient profile objects.


    setLastEmailedPropertyName

    public void setLastEmailedPropertyName(java.lang.String pLastEmailedPropertyName)
    Sets the property name of the email last sent timestamp in the profile. This will be used to access the email last sent (expected to be a timestamp) from each of the recipient profile objects.


    getEmailStatusPropertyName

    public java.lang.String getEmailStatusPropertyName()
    Returns the property name of the email status in the profile. This will be used to access the email status (expected to be a String) from each of the recipient profile objects.


    setEmailStatusPropertyName

    public void setEmailStatusPropertyName(java.lang.String pPropertyName)
    Sets the property name of the email status in the profile. This will be used to access the email status (expected to be a String) from each of the recipient profile objects.


    getEmailStatusValidOptionValue

    public java.lang.String getEmailStatusValidOptionValue()
    Returns the option value for valid email status in the profile.


    setEmailStatusValidOptionValue

    public void setEmailStatusValidOptionValue(java.lang.String pEmailStatusValidOptionValue)
    Sets the options value for valid email status for a profile.


    getEmailStatusInvalidOptionValue

    public java.lang.String getEmailStatusInvalidOptionValue()
    Returns the option value for invalid email status in the profile.


    setEmailStatusInvalidOptionValue

    public void setEmailStatusInvalidOptionValue(java.lang.String pEmailStatusInvalidOptionValue)
    Sets the options value for invalid email status for a profile.


    getReceiveEmailPropertyName

    public java.lang.String getReceiveEmailPropertyName()
    Returns the property name of the receiveEmail property in the profile. This will be used to access the value of receiveEmail (expected to be a String) from each of the recipient profile objects.


    setReceiveEmailPropertyName

    public void setReceiveEmailPropertyName(java.lang.String pPropertyName)
    Sets the property name of the receiveEmail property in the profile. This will be used to access the value of receiveEmail (expected to be a String) from each of the recipient profile objects.


    getEmailAddressPropertyName

    public java.lang.String getEmailAddressPropertyName()
    Returns the property name of the email address in the profile. This will be used to extract the email address (expected to be a String) from each of the recipient profile objects.


    setEmailAddressPropertyName

    public void setEmailAddressPropertyName(java.lang.String pPropertyName)
    Sets the property name of the email address in the profile. This will be used to extract the email address (expected to be a String) from each of the recipient profile objects.


    getLocalePropertyName

    public java.lang.String getLocalePropertyName()
    Returns the property name of the locale in the profile. This will be used to extract the locale (expected to be a String) from each of the recipient profile objects.


    setLocalePropertyName

    public void setLocalePropertyName(java.lang.String pPropertyName)
    Sets the property name of the locale in the profile. This will be used to extract the locale (expected to be a String) from each of the recipient profile objects.


    getCreateMessagesBatchSize

    public int getCreateMessagesBatchSize()

    setCreateMessagesBatchSize

    public void setCreateMessagesBatchSize(int pCreateMessagesBatchSize)
    Sets the maximum number of messages created in one batch


    getTemplateRendererServlet

    public javax.servlet.Servlet getTemplateRendererServlet()
    Returns the Servlet responsible for rendering the template.

    This servlet's service method will be invoked by the renderTemplate method. If you are implementing your own servlet to do the rendering, note that your servlet can access the template URL by calling getPathInfo on the request.


    setTemplateRendererServlet

    public void setTemplateRendererServlet(javax.servlet.Servlet pServlet)
    Sets the Servlet responsible for rendering the template.

    This servlet's service method will be invoked by the renderTemplate method. If you are implementing your own servlet to do the rendering, note that your servlet can access the template URL by calling getPathInfo on the request.


    setEncodingTyper

    public void setEncodingTyper(atg.servlet.pagecompile.PageEncodingTyper pValue)
    The EncodingTyper used by the pagecompiler rendering the email msg.


    getEncodingTyper

    public atg.servlet.pagecompile.PageEncodingTyper getEncodingTyper()
    The EncodingTyper used by the pagecompiler rendering the email msg.


    addTemplateEmailListener

    public void addTemplateEmailListener(TemplateEmailListener pListener)
    Adds a listener to the list of TemplateEmailListeners.


    removeTemplateEmailListener

    public void removeTemplateEmailListener(TemplateEmailListener pListener)
    Removes a listener from the list of TemplateEmailListeners.


    getTemplateEmailListeners

    public TemplateEmailListener[] getTemplateEmailListeners()
    Returns the array of TemplateEmailListener objects.


    getTemplateEmailListenerCount

    public int getTemplateEmailListenerCount()
    Returns the number of TemplateEmailListeners.


    sendEmailSentEvent

    protected void sendEmailSentEvent(TemplateEmailInfo pEmailInfo,
                                      java.lang.Object pRecipient,
                                      javax.mail.Message pMessage)
    Sends a TemplateEmailEvent signifying that a message was sent successfully to all the TemplateEmailListener objects.


    sendEmailNotSentEvent

    protected void sendEmailNotSentEvent(TemplateEmailInfo pEmailInfo,
                                         java.lang.Object pRecipient,
                                         javax.mail.Message pMessage,
                                         java.lang.String pErrorMessage)
    Sends a TemplateEmailEvent signifying that a message could not be sent to all the TemplateEmailListener objects.


    sendEmailMessage

    public void sendEmailMessage(TemplateEmailInfo pEmailInfo,
                                 java.util.Collection pRecipients)
                          throws TemplateEmailException
    Sends an email message described by the TemplateEmailInfo to each of the recipient profile objects in the Collection. The email is sent in the current thread, and is not persisted. Equivalent to calling sendEmailMessage(TemplateEmailInfo, Collection, false, false).

    Throws:
    TemplateEmailException
    See Also:
    sendEmailMessage(TemplateEmailInfo, Collection, boolean, boolean)

    sendEmailMessage

    public void sendEmailMessage(TemplateEmailInfo pEmailInfo,
                                 java.util.Collection pRecipients,
                                 boolean pRunInSeparateThread,
                                 boolean pPersist)
                          throws TemplateEmailException
    Sends an email message described by the TemplateEmailInfo to each of the recipient profile objects in the Collection. If pRunInSeparateThread is true, the email is sent in a separate worker thread (shared between all calls to sendEmailMessage); otherwise, the email is sent in the current thread.

    For each profile, this method renders the page specified by the TemplateEmailInfo's templateURL, and obtains a Message with the resulting content. For each recipient, if a message is sent successfully, a TargetedEmailEvent of type TYPE_EMAIL_SENT is fired; otherwise, a TargetedEmailEvent of type TYPE_EMAIL_NOT_SENT is fired.

    The recipient profiles in the Collection can be beans of any type, so long as they have an email address property (whose name is given by the service's emailAddressPropertyName property). However, if a profile is of type RepositoryItem, we also associate the RepositoryItem with the session-scoped Profile object in the request before rendering the template page, thus allowing the page to contain references to the recipient's profile.

    The rule of thumb for how error handling is performed in this method is as follows. TemplateEmailException is thrown in those cases when a problem is encountered which is likely to apply when sending email to each of the intended message recipients. However, if the problem is likely to be specific to a particular message recipient, no exception is thrown; instead, a TemplateEmailEvent of type TYPE_EMAIL_NOT_SENT is fired to notify the listeners that the email was not sent to that particular recipient. For example, if templateURL could not be rendered for one of the profiles, we assume that the problem is with the page rather than the profile, and throw an exception. If, on the other hand, a particular email address turns out to be invalid, a TYPE_EMAIL_NOT_SENT event is fired instead.

    If pPersist if true, the mailing will be persisted in the database before the email is actually sent. Thus, if the server goes down unexpectedly, the mailing will resume when the server is restarted.

    Throws:
    TemplateEmailException - if any problem was encountered while assembling or sending the message (but see above for an explanation of when an exception is not thrown)

    sendEmailMessage

    public void sendEmailMessage(TemplateEmailInfo pEmailInfo,
                                 java.lang.Object[] pRecipients)
                          throws TemplateEmailException
    Sends an email message described by the TemplateEmailInfo to each of the recipient profile objects in the array. The email is sent in the current thread, and is not persisted. Equivalent to calling sendEmailMessage(TemplateEmailInfo, Object[], false, false).

    Throws:
    TemplateEmailException
    See Also:
    sendEmailMessage(TemplateEmailInfo, Object[], boolean, boolean)

    sendEmailMessage

    public void sendEmailMessage(TemplateEmailInfo pEmailInfo,
                                 java.lang.Object[] pRecipients,
                                 boolean pRunInSeparateThread,
                                 boolean pPersist)
                          throws TemplateEmailException
    Sends an email message described by the TemplateEmailInfo to each of the recipient profile objects in the array. If pRunInSeparateThread is true, the email is sent in a separate worker thread (shared between all calls to sendEmailMessage); otherwise, the email is sent in the current thread. If pPersist if true, the mailing will be persisted in the database before the email is actually sent. Thus, if the server goes down unexpectedly, the mailing will resume when the server is restarted.

    Identical to sendEmailMessage(TemplateEmailInfo, Collection, boolean, boolean), except that the recipients are specified via an array rather than a Collection.

    Throws:
    TemplateEmailException
    See Also:
    sendEmailMessage(TemplateEmailInfo, Collection, boolean, boolean)

    sendEmailMessage

    public void sendEmailMessage(TemplateEmailInfo pEmailInfo,
                                 java.util.Enumeration pRecipients)
                          throws TemplateEmailException
    Sends an email message described by the TemplateEmailInfo to each of the recipient profile objects in the array. The email is sent in the current thread, and is not persisted. Equivalent to calling sendEmailMessage(TemplateEmailInfo, Enumeration, false, false).

    Throws:
    TemplateEmailException
    See Also:
    sendEmailMessage(TemplateEmailInfo, Enumeration, boolean, boolean)

    sendEmailMessage

    public void sendEmailMessage(TemplateEmailInfo pEmailInfo,
                                 java.util.Enumeration pRecipients,
                                 boolean pRunInSeparateThread,
                                 boolean pPersist)
                          throws TemplateEmailException
    Sends an email message described by the TemplateEmailInfo to each of the recipient profile objects in the array. If pRunInSeparateThread is true, the email is sent in a separate worker thread (shared between all calls to sendEmailMessage); otherwise, the email is sent in the current thread. If pPersist if true, the mailing will be persisted in the database before the email is actually sent. Thus, if the server goes down unexpectedly, the mailing will resume when the server is restarted.

    Identical to sendEmailMessage(TemplateEmailInfo, Collection, boolean, boolean), except that the recipients are specified via an Enumeration rather than a Collection.

    Throws:
    TemplateEmailException
    See Also:
    sendEmailMessage(TemplateEmailInfo, Collection, boolean, boolean)

    createMessage

    public javax.mail.Message createMessage(TemplateEmailInfo pEmailInfo,
                                            java.lang.Object pRecipient)
                                     throws TemplateEmailException
    Given a TemplateEmailInfo and a specific recipient profile, renders the page specified by the TemplateEmailInfo's templateURL for that profile, and creates a Message with the resulting content.

    The recipient can be a bean of any type, so long as it has an email address property (whose name is given by the service's emailAddressPropertyName property). However, if it is of type RepositoryItem, we also associate the RepositoryItem with the session-scoped Profile object in the request before rendering the template page, thus allowing the page to contain references to the recipient's profile.

    Throws:
    TemplateEmailException - if a problem is encountered while creating the Message

    recipientIsContactFatigued

    protected boolean recipientIsContactFatigued(TemplateEmailInfo pEmailInfo,
                                                 java.lang.Object pRecipient)
                                          throws TemplateEmailException
    Return whether the recipient is considered contact fatigued. This is determined by the lastEmailed property on the profile, and by the msecContactFatigue property.

    Throws:
    TemplateEmailException

    initializeRequest

    protected void initializeRequest(DynamoHttpServletRequest pRequest,
                                     java.lang.Object pRecipient)
                              throws TemplateEmailException
    Initializes the request to contain any recipient-specific information.

    This default implementation checks to see if the recipient object is a RepositoryItem; if so, it associates the Profile object in the request with the given RepositoryItem. This allows us to resolve any references to the profile attributes in the template page when we're rendering the template.

    Subclasses may override this method to implement other schemes for associating the recipient's profile with the request, etc.

    Note that the same request will in general be initialized multiple times for different recipient objects.

    Throws:
    TemplateEmailException - if an error occurred while initializing the request

    initializeResponse

    protected void initializeResponse(DynamoHttpServletResponse pResponse,
                                      java.lang.Object pRecipient)
                               throws TemplateEmailException
    Initializes the response to contain any recipient-specific information.

    This default implementation does nothing. Subclasses may override this method to perform any desired initialization.

    Note that the same response will in general be initialized multiple times for different recipient objects.

    Throws:
    TemplateEmailException - if an error occurred while initializing the response

    doStartService

    public void doStartService()
                        throws ServiceException
    Called after the service has been created, placed into the naming hierarchy, and initialized with its configured property values. Makes sure all the required properties have been set in the .properties file.

    Overrides:
    doStartService in class GenericService
    Throws:
    ServiceException - if the service had a problem starting up

    doStopService

    public void doStopService()
                       throws ServiceException
    Description copied from class: GenericService
    This is called when a Service is required to shut down. The Service should respond by stopping any processes that it has started.

    Overrides:
    doStopService in class GenericService
    Throws:
    ServiceException - if the Service had a problem shutting down

    createAdminServlet

    protected javax.servlet.Servlet createAdminServlet()
    Creates and returns a new Servlet that will administer this service.

    Overrides:
    createAdminServlet in class GenericService

    getNextBatchMailing

    public atg.userprofiling.email.TemplateEmailBatchInfo getNextBatchMailing(boolean pClaim)
                                                                       throws TemplateEmailException
    Return the next batch mailing to process.

    Parameters:
    pClaim - whether to claim the mailing for this server.
    Throws:
    TemplateEmailException

    sendBatch

    public void sendBatch(atg.userprofiling.email.TemplateEmailBatchInfo pBatchInfo)
                   throws TemplateEmailException
    restartMailing

    Parameters:
    pEmailInfo - a TemplateEmailInfo value
    Throws:
    TemplateEmailException - if an error occurs

    serviceNextBatchMailing

    public void serviceNextBatchMailing()
                                 throws TemplateEmailException
    Service the next bath mailing, if any. This should typically only be called in a BatchEmailRequestThread.

    Throws:
    TemplateEmailException