public class FlashMailMessage extends MailMessage
| Modifier and Type | Field and Description |
|---|---|
protected NotificationMessage |
ivNFMessage
The current Notfication Framework message handler.
|
static java.lang.String |
MSG_CCREJECT
The message type for a credit card reject message.
|
static java.lang.String |
MSG_CUSTDEF
The message type for a custom-defined message.
|
static java.lang.String |
MSG_LOGONHELP
The message type for a logon assistance message.
|
static java.lang.String |
MSG_LOWSTOCK
The message type for a product low stock notification message.
|
static java.lang.String |
MSG_MASSMAIL
The message type for a mass mail message.
|
static java.lang.String |
MSG_NEWACCOUNT
The message type for a new account notification message.
|
static java.lang.String |
MSG_ORDERCONF
The message type for an order confirmation message.
|
static java.lang.String |
MSG_QUOTECONF
The message type for a quote creation confirmation message.
|
static java.lang.String |
MSG_RESTOCK
The message type for a product restock notification message.
|
static java.lang.String |
MSG_SHIPCONF
The message type for a shipment confirmation message.
|
private static long |
serialVersionUID
The class' serialization version id.
|
ivAlternate, ivAttachments, ivContent, ivContentType, ivDebugMode, ivMessage, ivPreferred, ivSampleMode, ivSession, ivSmtpHost, ivSmtpPwd, ivSmtpUser, ivTemplate, ivType, MSG_ALERT, MSG_GENERIC, MSG_SITEMON| Modifier | Constructor and Description |
|---|---|
protected |
FlashMailMessage()
Constructs a
FlashMailMessage object. |
|
FlashMailMessage(java.lang.String type)
Constructs a
FlashMailMessage object. |
| Modifier and Type | Method and Description |
|---|---|
void |
addFileAttachment(java.io.File file)
Adds a file attachment to the message.
|
void |
addFileAttachment(javax.mail.internet.MimeBodyPart attachment)
Adds a file attachment to the message.
|
void |
addFileAttachment(java.lang.String path)
Adds a file attachment to the message.
|
void |
addFrom(java.lang.Object from)
Adds to the message's list of from addresses using the given object (User,
ArrayList, etc.).
|
void |
addFrom(java.lang.String name,
java.lang.String address)
Adds to the message's list of from addresses using the given name and email
address.
|
void |
addRecipientBCC(java.lang.Object bcc)
Adds to the message's list of BCC addresses using the given object (User,
ArrayList, etc.).
|
void |
addRecipientBCC(java.lang.String name,
java.lang.String address)
Adds to the message's list of BCC addresses using the given name and email
address.
|
void |
addRecipientCC(java.lang.Object cc)
Adds to the message's list of CC addresses using the given object (User,
ArrayList, etc.).
|
void |
addRecipientCC(java.lang.String name,
java.lang.String address)
Adds to the message's list of CC addresses using the given name and email
address.
|
void |
addRecipientTO(java.lang.Object to)
Adds to the message's list of TO addresses using the given object (User,
ArrayList, etc.).
|
void |
addRecipientTO(java.lang.String name,
java.lang.String address)
Adds to the message's list of TO addresses using the given name and email
address.
|
protected void |
createMessage()
Creates the SMTP server session and message object.
|
void |
finalizeMessage()
Performs finalization for a message that is being scheduled for later
sending, such as a mass mail message.
|
protected void |
formatMessage()
Formats the message content for the current email type.
|
private javax.mail.internet.InternetAddress |
getAddressFromArray(java.lang.String[] arr)
Returns an
InternetAddress object for the email name and
address contained within the given String array. |
private javax.mail.internet.InternetAddress |
getAddressFromCustomer(Customer customer)
Returns an
InternetAddress object for the email name and
address contained within the given customer. |
protected javax.mail.internet.InternetAddress[] |
getAddressFromObject(java.lang.Object obj)
Returns an array of
InternetAddress objects for the email
names and addresses contained within the given object. |
private javax.mail.internet.InternetAddress |
getAddressFromRestock(RestockNotification restock)
Returns an
InternetAddress object for the email name and
address contained within the given product restock notification. |
private javax.mail.internet.InternetAddress |
getAddressFromUser(User user)
Returns an
InternetAddress object for the email name and
address contained within the given user. |
java.lang.String |
getSubject()
Returns the message's subject.
|
static org.apache.velocity.VelocityContext |
initTemplateData(FlashServletContext ctx)
Creates, initializes and returns a Velocity Context object that can then
be used as the template data for an email message.
|
protected NotificationMessage |
newNFMessage(java.lang.String type)
Returns the Notification Framework message object that is to be used for
processing this message.
|
void |
send()
Sends the message.
|
void |
setContent(java.lang.Object content)
Sets the message's content using the given object.
|
void |
setFrom(java.lang.Object from)
Sets the message's from address(es) using the given object (User, ArrayList,
etc.).
|
void |
setFrom(java.lang.String name,
java.lang.String address)
Sets the message's from address using the given name and email address.
|
protected void |
setMessageFormats(java.lang.String pcontent,
java.lang.String ptype,
java.lang.String acontent,
java.lang.String atype)
Sets the message content formats for the current message based on whether
the message will contain a single format or multiple formats.
|
void |
setRecipientBCC(java.lang.Object bcc)
Sets the message's BCC address(es) using the given object (User, ArrayList,
etc.).
|
void |
setRecipientBCC(java.lang.String name,
java.lang.String address)
Sets the message's BCC address using the given name and email address.
|
void |
setRecipientCC(java.lang.Object cc)
Sets the message's CC address(es) using the given object (User, ArrayList,
etc.).
|
void |
setRecipientCC(java.lang.String name,
java.lang.String address)
Sets the message's CC address using the given name and email address.
|
void |
setRecipientTO(java.lang.Object to)
Sets the message's TO address(es) using the given object (User, ArrayList,
etc.).
|
void |
setRecipientTO(java.lang.String name,
java.lang.String address)
Sets the message's TO address using the given name and email address.
|
void |
setSampleMethod(java.lang.String delvmeth)
Sets the sample delivery method (email, sms, push).
|
void |
setSampleMode(boolean on)
Sets the sample mode on/off state.
|
void |
setSampleVersion(java.lang.String version)
Sets the sample version number.
|
void |
setSubject(java.lang.String text)
Sets the message's subject.
|
void |
setTemplate(java.io.File file)
Sets the message's template file.
|
void |
setTemplate(java.lang.String filename)
Sets the message's template file name.
|
protected void |
setType(java.lang.String type)
Sets the message type and then invokes additional type initialization.
|
protected java.lang.Object |
verifyContent(java.lang.Object content)
Verifies that the given content is appropriate for the current email type.
|
addDebugRecipient, addSiteBaseURLs, formatProperty, getAlternateFormatFile, getContent, getContentType, isValidEmailAddress, resend, reviseRecipients, setDebugMode, setHeaderValues, setHostValues, setSubjectFromContent, toInternetAddress, toString, verifyFile, verifyHasRecipients, verifyInternetAddress, verifyTypeprivate static final long serialVersionUID
public static final java.lang.String MSG_ORDERCONF
public static final java.lang.String MSG_SHIPCONF
public static final java.lang.String MSG_QUOTECONF
public static final java.lang.String MSG_CCREJECT
public static final java.lang.String MSG_LOGONHELP
public static final java.lang.String MSG_NEWACCOUNT
public static final java.lang.String MSG_RESTOCK
public static final java.lang.String MSG_LOWSTOCK
public static final java.lang.String MSG_MASSMAIL
public static final java.lang.String MSG_CUSTDEF
The actual message type passed to the constructor for a custom-defined message must be a concatenation of this constant plus the name given to the message in properties. Example: MSG_CUSTDEF + ".mymessage".
protected NotificationMessage ivNFMessage
protected FlashMailMessage()
throws java.lang.Exception
FlashMailMessage object.java.lang.Exception - - if an error occurs while constructing
the FlashMailMessage object.public FlashMailMessage(java.lang.String type)
throws java.lang.Exception
FlashMailMessage object.
This constructor should never the called directly. New instances of
this class should be obtained from the MailFactory class.
type - (String) The type code for the message to send. Must be
one of the predefined MSG_* type constants in this class or in
the base class.
NOTE: The message type passed to this constructor for a user defined message must be a concatenation of the MSG_USERDEF constant plus the name given to the message in properties. Example: MSG_USERDEF + ".mymessage".
java.lang.Exception - - if an error occurs while constructing
the FlashMailMessage object.public void send()
throws java.lang.Exception
Overrides send in base MailMessage.
send in class MailMessagejava.lang.Exception - - if an error occurs while sending the
message.public void setContent(java.lang.Object content)
throws java.lang.Exception
String, a message file name String,
or a VelocityContext of template tags and values.
NOTE: All file attachments must be added before setting the message's content.
Overrides setContent in base MailMessage.
setContent in class MailMessagecontent - (Object) The object that contains the message's content.java.lang.Exception - - if an error occurs while setting the
content.public void setFrom(java.lang.Object from)
throws java.lang.Exception
Overrides setFrom in base MailMessage.
setFrom in class MailMessagefrom - (Object) The object that contains the from address
information.java.lang.Exception - - if an error occurs while setting the
from address(es).public void setFrom(java.lang.String name,
java.lang.String address)
throws java.lang.Exception
Overrides setFrom in base MailMessage.
setFrom in class MailMessagename - (String) The name associated with the from address.address - (String) The email address associated with the from
address.java.lang.Exception - - if an error occurs while setting the
from address.public void addFrom(java.lang.Object from)
throws java.lang.Exception
Overrides addFrom in base MailMessage.
addFrom in class MailMessagefrom - (Object) The object that contains the from address
information.java.lang.Exception - - if an error occurs while adding to the
list of from addresses.public void addFrom(java.lang.String name,
java.lang.String address)
throws java.lang.Exception
Overrides addFrom in base MailMessage.
addFrom in class MailMessagename - (String) The name associated with the from address.address - (String) The email address associated with the from
address.java.lang.Exception - - if an error occurs while adding to the
list of from addresses.public void setRecipientTO(java.lang.Object to)
throws java.lang.Exception
Overrides setRecipientTO in base MailMessage.
setRecipientTO in class MailMessageto - (Object) The object that contains the TO address information.java.lang.Exception - - if an error occurs while setting the
TO address(es).public void setRecipientTO(java.lang.String name,
java.lang.String address)
throws java.lang.Exception
Overrides setRecipientTO in base MailMessage.
setRecipientTO in class MailMessagename - (String) The name associated with the TO address.address - (String) The email address associated with the TO
address.java.lang.Exception - - if an error occurs while setting the
TO address.public void addRecipientTO(java.lang.Object to)
throws java.lang.Exception
Overrides addRecipientTO in base MailMessage.
addRecipientTO in class MailMessageto - (Object) The object that contains the TO address information.java.lang.Exception - - if an error occurs while adding to the
list of TO addresses.public void addRecipientTO(java.lang.String name,
java.lang.String address)
throws java.lang.Exception
Overrides addRecipientTO in base MailMessage.
addRecipientTO in class MailMessagename - (String) The name associated with the TO address.address - (String) The email address associated with the TO
address.java.lang.Exception - - if an error occurs while adding to the
list of TO addresses.public void setRecipientCC(java.lang.Object cc)
throws java.lang.Exception
Overrides setRecipientCC in base MailMessage.
setRecipientCC in class MailMessagecc - (Object) The object that contains the CC address information.java.lang.Exception - - if an error occurs while setting the
CC address(es).public void setRecipientCC(java.lang.String name,
java.lang.String address)
throws java.lang.Exception
Overrides setRecipientCC in base MailMessage.
setRecipientCC in class MailMessagename - (String) The name associated with the CC address.address - (String) The email address associated with the CC
address.java.lang.Exception - - if an error occurs while setting the
CC address.public void addRecipientCC(java.lang.Object cc)
throws java.lang.Exception
Overrides addRecipientCC in base MailMessage.
addRecipientCC in class MailMessagecc - (Object) The object that contains the CC address information.java.lang.Exception - - if an error occurs while adding to the
list of CC addresses.public void addRecipientCC(java.lang.String name,
java.lang.String address)
throws java.lang.Exception
Overrides addRecipientCC in base MailMessage.
addRecipientCC in class MailMessagename - (String) The name associated with the CC address.address - (String) The email address associated with the CC
address.java.lang.Exception - - if an error occurs while adding to the
list of CC addresses.public void setRecipientBCC(java.lang.Object bcc)
throws java.lang.Exception
Overrides setRecipientBCC in base MailMessage.
setRecipientBCC in class MailMessagebcc - (Object) The object that contains the BCC address
information.java.lang.Exception - - if an error occurs while setting the
BCC address(es).public void setRecipientBCC(java.lang.String name,
java.lang.String address)
throws java.lang.Exception
Overrides setRecipientBCC in base MailMessage.
setRecipientBCC in class MailMessagename - (String) The name associated with the BCC address.address - (String) The email address associated with the BCC
address.java.lang.Exception - - if an error occurs while setting the
BCC address.public void addRecipientBCC(java.lang.Object bcc)
throws java.lang.Exception
Overrides addRecipientBCC in base MailMessage.
addRecipientBCC in class MailMessagebcc - (Object) The object that contains the BCC address
information.java.lang.Exception - - if an error occurs while adding to the
list of BCC addresses.public void addRecipientBCC(java.lang.String name,
java.lang.String address)
throws java.lang.Exception
Overrides addRecipientBCC in base MailMessage.
addRecipientBCC in class MailMessagename - (String) The name associated with the BCC address.address - (String) The email address associated with the BCC
address.java.lang.Exception - - if an error occurs while adding to the
list of BCC addresses.public void addFileAttachment(java.io.File file)
throws java.lang.Exception
NOTE: All file attachments must be added before setting the message's content.
Overrides addFileAttachment in base MailMessage.
addFileAttachment in class MailMessagefile - (File) The object for the file to attach.java.lang.Exception - - if an error occurs while adding the
attachment.public void addFileAttachment(java.lang.String path)
throws java.lang.Exception
NOTE: All file attachments must be added before setting the message's content.
Overrides addFileAttachment in base MailMessage.
addFileAttachment in class MailMessagepath - (String) The full path to the file to attach.java.lang.Exception - - if an error occurs while adding the
attachment.public void addFileAttachment(javax.mail.internet.MimeBodyPart attachment)
throws java.lang.Exception
NOTE: All file attachments must be added before setting the message's content.
Overrides addFileAttachment in base MailMessage.
addFileAttachment in class MailMessageattachment - (MimeBodyPart) The object for the file to attach.java.lang.Exception - - if an error occurs while adding the
attachment.public void setSampleMethod(java.lang.String delvmeth)
delvmeth - (String) The sample delivery method.public void setSampleMode(boolean on)
Overrides setSampleMode in base MailMessage.
setSampleMode in class MailMessageon - (boolean) true if sample mode is to be turned
on, otherwise false (default).public void setSampleVersion(java.lang.String version)
version - (String) The sample version number.public void setSubject(java.lang.String text)
throws java.lang.Exception
Overrides setSubject in base MailMessage.
setSubject in class MailMessagetext - (String) The message subject text.java.lang.Exception - - if an error occurs while setting the
subject.public java.lang.String getSubject()
throws java.lang.Exception
Overrides getSubject in base MailMessage.
getSubject in class MailMessagejava.lang.Exception - - if an error occurs while getting the
subject.public void setTemplate(java.io.File file)
throws java.lang.Exception
Overrides setTemplate in base MailMessage.
setTemplate in class MailMessagefile - (File) The template file.java.lang.Exception - - if an error occurs while setting the
template file.public void setTemplate(java.lang.String filename)
throws java.lang.Exception
Overrides setTemplate in base MailMessage.
setTemplate in class MailMessagefilename - (String) The template file name. The template is
assumed to reside in the configured Velocity template folder or
in a subfolder of the configured folder.java.lang.Exception - - if an error occurs while setting the
template file name.protected void createMessage()
throws java.lang.Exception
Overrides createMessage in base MailMessage.
createMessage in class MailMessagejava.lang.Exception - - if an error occurs while creating the
session and the message object.protected void formatMessage()
throws java.lang.Exception
Overrides formatMessage in base MailMessage.
formatMessage in class MailMessagejava.lang.Exception - - if an error occurs while formatting the
message content.protected void setMessageFormats(java.lang.String pcontent,
java.lang.String ptype,
java.lang.String acontent,
java.lang.String atype)
throws java.lang.Exception
Overrides setMessageFormats in base MailMessage.
setMessageFormats in class MailMessagepcontent - (String) The message's preferred content.ptype - (String) The message's preferred content type.acontent - (String) The message's alternate content. Will be
null if there is no alternate content.atype - (String) The message's alternate content type. Will be
null if there is no alternate content.java.lang.Exception - - if an error occurs while setting the
message formats.protected void setType(java.lang.String type)
throws java.lang.Exception
Overrides setType in base MailMessage.
setType in class MailMessagetype - (String) The type code for the message. Must be one
of the predefined MSG_* type constants in this class or in
the base class.java.lang.Exception - - if an error occurs while setting the type
or if the specified type is invalid.protected java.lang.Object verifyContent(java.lang.Object content)
throws java.lang.Exception
String, a message file name
String, or a VelocityContext of template tags
and values.
Overrides verifyContent in base MailMessage.
verifyContent in class MailMessagecontent - (Object) The object that contains the email's
content.java.lang.Exception - - if the specified content is invalid.protected javax.mail.internet.InternetAddress[] getAddressFromObject(java.lang.Object obj)
throws java.lang.Exception
InternetAddress objects for the email
names and addresses contained within the given object.
Overrides getAddressFromObject in base MailMessage.
The currently supported objects are:
getAddressFromObject in class MailMessageobj - (Object) The object that contains email name & address
information.InternetAddress
objects, extracted from the given object.java.lang.Exception - - if an error occurs while extracting the
name and address information.private javax.mail.internet.InternetAddress getAddressFromArray(java.lang.String[] arr)
throws java.lang.Exception
InternetAddress object for the email name and
address contained within the given String array.arr - (String[]) The array that contains email
name & address information (index 0 is the formatted name, index
1 is the email address).InternetAddress object, or null
if an InternetAddress object could not be created.java.lang.Exception - - if an error occurs while extracting the
name and address information.private javax.mail.internet.InternetAddress getAddressFromCustomer(Customer customer) throws java.lang.Exception
InternetAddress object for the email name and
address contained within the given customer.customer - (Customer) The Customer that contains email
name & address information.InternetAddress object, or
null if an InternetAddress object
could not be created.java.lang.Exception - - if an error occurs while extracting the
name and address information.private javax.mail.internet.InternetAddress getAddressFromRestock(RestockNotification restock) throws java.lang.Exception
InternetAddress object for the email name and
address contained within the given product restock notification.restock - (RestockNotification) The RestockNotification
that contains email name & address information.InternetAddress object, or
null if an InternetAddress object
could not be created.java.lang.Exception - - if an error occurs while extracting the
name and address information.private javax.mail.internet.InternetAddress getAddressFromUser(User user) throws java.lang.Exception
InternetAddress object for the email name and
address contained within the given user.user - (User) The User that contains email name and
address information.InternetAddress object, or null
if an InternetAddress object could not be created.java.lang.Exception - - if an error occurs while extracting the
name and address information.public static org.apache.velocity.VelocityContext initTemplateData(FlashServletContext ctx)
ctx - (Context) The current servlet or thread context.public void finalizeMessage()
throws java.lang.Exception
java.lang.Exception - - if an error occurs during finalization.protected NotificationMessage newNFMessage(java.lang.String type)
Uses the Notification.Framework.NotificationMessage.class
property to determine if a custom message class should be created. If no
value is assigned or found for this property then the default class
com.dpslink.flash.util.NotificationMessage is created.
type - (String) The type code for the message. Must be one
of the predefined MSG_* type constants in this class or in
the base class.null if the class could
not be created.