atg.userprofiling.email
Class HtmlContentProcessor

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.userprofiling.email.MessageContentProcessor
              extended by atg.userprofiling.email.HtmlContentProcessor
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class HtmlContentProcessor
extends MessageContentProcessor

A MessageContentProcessor which takes in HTML content and converts it into plain text. The Message content is set based on the values of two properties: sendAsHtml and sendAsText. If both are true, the Message content is set to the multipart (with content type "multipart/alternative") containing both the text and the HTML versions. If only sendAsHtml is true, the Message content is set to the HTML version. If only sendAsText is true, the Message content is set to the plain text version.

See Also:
Message

Nested Class Summary
 
Nested classes/interfaces inherited from class atg.userprofiling.email.MessageContentProcessor
MessageContentProcessor.UrlAndMimeType
 
Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
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
HtmlContentProcessor()
           
 
Method Summary
 char getHrChar()
          Returns the char used by the HTML to text converter when constructing a horizontal rule (an <hr> tag).
 java.util.List getIgnorableContentTags()
          Gets the list of tag names which should have their content ignored
 int getIndentWidth()
          Returns the indentation width used by the HTML to text converter.
 char getLiChar()
          Returns the char used by the HTML to text converter when displaying list elements inside a <ul> tag.
 int getLineWidth()
          Returns the line width used by the HTML to text converter.
 boolean getReplaceATagWithHrefAttribute()
          Flag to indicate if we should replace all <a> tag contents with the tags href attribute (if available)
 boolean getSendAsHtml()
          Returns the property indicating whether message content should be sent as HTML.
 boolean getSendAsText()
          Returns the property indicating whether message content should be sent as plain text.
 void setHrChar(char pHrChar)
          Sets the char used by the HTML to text converter when constructing a horizontal rule (an <hr> tag).
 void setIgnorableContentTags(java.util.List pIgnorableContentTags)
          Sets the list of tags which should have their content ignored
 void setIndentWidth(int pIndentWidth)
          Sets the indentation width used by the HTML to text converter.
 void setLiChar(char pLiChar)
          Returns the char used by the HTML to text converter when displaying list elements inside a <ul> tag.
 void setLineWidth(int pLineWidth)
          Sets the line width used by the HTML to text converter.
 void setMessageContent(javax.mail.Message pMessage, java.lang.String pContent, java.lang.String pContentType, java.io.File[] pAttachments, boolean pInlineAttachments)
          Processes the email message content (assumed to be HTML) and stuffs the resulting content into the Message.
 void setMessageContents(javax.mail.Message pMessage, java.lang.String[] pContents, java.lang.String[] pContentTypes, java.io.File[] pAttachments, boolean pInlineAttachments)
          Processes the email message content (assumed to be HTML) and stuffs the resulting content into the Message.
 void setReplaceATagWithHrefAttribute(boolean pReplaceATagWithHrefAttribute)
          Sets mReplaceATagWithHrefAttribute
 void setSendAsHtml(boolean pSendAsHtml)
          Sets the property indicating whether message content should be sent as HTML.
 void setSendAsText(boolean pSendAsText)
          Sets the property indicating whether message content should be sent as plain text.
 boolean supportsMultipleContents()
          We do support multiple contents.
 
Methods inherited from class atg.userprofiling.email.MessageContentProcessor
pruneAlternatives, setMessageContent, setMessageContent
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, 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, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, 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

Constructor Detail

HtmlContentProcessor

public HtmlContentProcessor()
Method Detail

getSendAsHtml

public boolean getSendAsHtml()
Returns the property indicating whether message content should be sent as HTML. If both sendAsHtml and sendAsText are true, both versions of the content will be sent in a multipart message.


setSendAsHtml

public void setSendAsHtml(boolean pSendAsHtml)
Sets the property indicating whether message content should be sent as HTML. If both sendAsHtml and sendAsText are true, both versions of the content will be sent in a multipart message.


getSendAsText

public boolean getSendAsText()
Returns the property indicating whether message content should be sent as plain text. If both sendAsHtml and sendAsText are true, both versions of the content will be sent in a multipart message.


setSendAsText

public void setSendAsText(boolean pSendAsText)
Sets the property indicating whether message content should be sent as plain text. If both sendAsHtml and sendAsText are true, both versions of the content will be sent in a multipart message.


getLineWidth

public int getLineWidth()
Returns the line width used by the HTML to text converter. When the conversion is performed, the resulting text will be word wrapped at the specified width.


setLineWidth

public void setLineWidth(int pLineWidth)
Sets the line width used by the HTML to text converter. When the conversion is performed, the resulting text will be word wrapped at the specified width.


getIndentWidth

public int getIndentWidth()
Returns the indentation width used by the HTML to text converter. When the conversion is performed, any text inside <blockquote> tags, as well as list items inside <ul> and <ol> tags, will be indented by the specified amount.


setIndentWidth

public void setIndentWidth(int pIndentWidth)
Sets the indentation width used by the HTML to text converter. When the conversion is performed, any text inside <blockquote> tags, as well as list items inside <ul> and <ol> tags, will be indented by the specified amount.


getHrChar

public char getHrChar()
Returns the char used by the HTML to text converter when constructing a horizontal rule (an <hr> tag).


setHrChar

public void setHrChar(char pHrChar)
Sets the char used by the HTML to text converter when constructing a horizontal rule (an <hr> tag).


getLiChar

public char getLiChar()
Returns the char used by the HTML to text converter when displaying list elements inside a <ul> tag.


setLiChar

public void setLiChar(char pLiChar)
Returns the char used by the HTML to text converter when displaying list elements inside a <ul> tag.


getIgnorableContentTags

public java.util.List getIgnorableContentTags()
Gets the list of tag names which should have their content ignored

Returns:
the list of ignorable tags

setIgnorableContentTags

public void setIgnorableContentTags(java.util.List pIgnorableContentTags)
Sets the list of tags which should have their content ignored

Parameters:
pIgnorableContentTags - The IgnorableContentTags to set

getReplaceATagWithHrefAttribute

public boolean getReplaceATagWithHrefAttribute()
Flag to indicate if we should replace all <a> tag contents with the tags href attribute (if available)

Returns:
true if mReplaceATagWithHrefAttribute

setReplaceATagWithHrefAttribute

public void setReplaceATagWithHrefAttribute(boolean pReplaceATagWithHrefAttribute)
Sets mReplaceATagWithHrefAttribute

Parameters:
pReplaceATagWithHrefAttribute - The flag to set

setMessageContent

public void setMessageContent(javax.mail.Message pMessage,
                              java.lang.String pContent,
                              java.lang.String pContentType,
                              java.io.File[] pAttachments,
                              boolean pInlineAttachments)
                       throws TemplateEmailException
Processes the email message content (assumed to be HTML) and stuffs the resulting content into the Message. If the sendAsText property is set to true, the content is converted into text, and the text version is sent. If the sendAsHtml property is also true, the HTML version is sent along as well.

Specified by:
setMessageContent in class MessageContentProcessor
Parameters:
pAttachments - the files to attach to the message, in addition to setting the regular content
pInlineAttachments - if true, the files will be inlined into the message, rather than attached
Throws:
TemplateEmailException - if the content could not be processed or set in the Message

setMessageContents

public void setMessageContents(javax.mail.Message pMessage,
                               java.lang.String[] pContents,
                               java.lang.String[] pContentTypes,
                               java.io.File[] pAttachments,
                               boolean pInlineAttachments)
                        throws TemplateEmailException
Processes the email message content (assumed to be HTML) and stuffs the resulting content into the Message. If the sendAsText property is set to true, the content is converted into text, and the text version is sent. If the sendAsHtml property is also true, the HTML version is sent along as well.

Overrides:
setMessageContents in class MessageContentProcessor
Parameters:
pAttachments - the files to attach to the message, in addition to setting the regular content
pInlineAttachments - if true, the files will be inlined into the message, rather than attached
pContents - an array of multi-part-alternative contents
pContentTypes - an array of content types which correspond to each of the pContents elements.
Throws:
TemplateEmailException - if the content could not be processed or set in the Message

supportsMultipleContents

public boolean supportsMultipleContents()
We do support multiple contents.

Overrides:
supportsMultipleContents in class MessageContentProcessor