public class MailTools
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CONF_FILE_STORE_PATH
Configuration key for the path to store files to.
|
static java.lang.String |
CONF_IS_CRITICAL
Configuration key: Whether the event handler is critical and problems
handling the event should abort all handling of the current event.
|
static int |
MAX_FILE_NAME_LENGTH
The maximum length of the file name for a mail event.
|
static java.lang.String |
PARAM_ATTACHMENTS
Process parameter name for the list of attachments.
|
static java.lang.String |
PARAM_BCC
Process parameter name for the message's recipient list.
|
static java.lang.String |
PARAM_BODY
Process parameter name for the message's body.
|
static java.lang.String |
PARAM_CC
Process parameter name for the message's recipient list.
|
static java.lang.String |
PARAM_FROM
Process parameter name for the message's sender list.
|
static java.lang.String |
PARAM_MESSAGE
Process parameter name for the message.
|
static java.lang.String |
PARAM_SENT_DATE
Process parameter name for the message's sent date.
|
static java.lang.String |
PARAM_SUBJECT
Process parameter name for the message's subject.
|
static java.lang.String |
PARAM_TO
Process parameter name for the message's recipient list.
|
protected static java.lang.String |
STRING_LIST_TYPE
The name of the UDT type for String lists.
|
static java.lang.String |
SUBTABLE_NAME_MAIL_ADDRESSES
The name of the subtable that is created for mail addresses.
|
protected static java.lang.String |
URI_LIST_TYPE
The name of the UDT type for URI lists.
|
| Constructor and Description |
|---|
MailTools() |
| Modifier and Type | Method and Description |
|---|---|
protected static UDTValue |
addressListToUDT(Parameter parameter,
javax.mail.Address[] addresses,
java.util.logging.Logger logger)
Creates a UDT value for the designated parameter with the designated
addresses.
|
protected static UDTValue |
attachmentsToUDT(Parameter parameter,
MailEvent event,
java.io.File fileStore,
java.util.logging.Logger logger)
Creates a UDT value for the designated parameter with all attachments of
the message of the designated mail event.
|
protected static java.lang.String |
createFileNameForEvent(MailEvent event,
boolean unique)
Creates a file name for storing a message.
|
protected static UDTValue |
getMessageAsFileUDT(MailEvent event,
java.io.File fileStore,
java.util.logging.Logger logger)
Creates a file for the designated event and returns it as
UDTValue. |
static java.lang.String |
getStringContentOfMessage(javax.mail.Message message)
Gets a string representation of the content of the designated message.
|
static java.lang.String[] |
toString(javax.mail.Address[] addresses)
Converts
Addresses to Strings. |
static java.lang.String |
toString(javax.mail.Message message,
java.util.logging.Logger logger)
Provides a string representing the designated message, that is the subject,
the sender and the receiver of the message.
|
protected static java.io.File |
writeMessageToFile(MailEvent event,
boolean intermediate,
java.io.File fileStore,
java.util.logging.Logger logger)
Writes the mail from the designated mail event to a file with an
appropriate file name.
|
protected static final java.lang.String STRING_LIST_TYPE
protected static final java.lang.String URI_LIST_TYPE
public static final int MAX_FILE_NAME_LENGTH
public static final java.lang.String PARAM_MESSAGE
public static final java.lang.String PARAM_ATTACHMENTS
public static final java.lang.String PARAM_BODY
public static final java.lang.String PARAM_TO
public static final java.lang.String PARAM_CC
public static final java.lang.String PARAM_BCC
public static final java.lang.String PARAM_FROM
public static final java.lang.String PARAM_SENT_DATE
public static final java.lang.String PARAM_SUBJECT
public static final java.lang.String SUBTABLE_NAME_MAIL_ADDRESSES
public static final java.lang.String CONF_IS_CRITICAL
public static final java.lang.String CONF_FILE_STORE_PATH
public static java.lang.String[] toString(javax.mail.Address[] addresses)
Addresses to Strings.addresses - The addresses to convert.public static java.lang.String toString(javax.mail.Message message,
java.util.logging.Logger logger)
message - The message for which to get a string representation.logger - The logger for additional information in case the details of
the message cannot be retrieved.public static java.lang.String getStringContentOfMessage(javax.mail.Message message)
throws javax.mail.MessagingException,
java.io.IOException
message - The message to retrieve the string content of.javax.mail.MessagingException - If there are problems retrieving the message
content, a MessagingException will be thrown.java.io.IOException - If there are problems retrieving the body part content,
an IOException will be thrown.protected static UDTValue addressListToUDT(Parameter parameter, javax.mail.Address[] addresses, java.util.logging.Logger logger) throws java.io.IOException, InvalidDataTypeException
java.util.List<STRING> or
a subtable.parameter - The parameter for which to create a UDT value.addresses - The addresses for which to retrieve a UDT value.logger - The logger for log messages.java.io.IOException - If there are problems serialising the list or the
subtable or creating the subtable-XML, an
IOException will be thrown.InvalidDataTypeException - If the UDT name of the parameter is
unknown or there are problems creating an XML-document for the
subtable, an InvalidDataTypeException will be
thrown.protected static UDTValue getMessageAsFileUDT(MailEvent event, java.io.File fileStore, java.util.logging.Logger logger) throws javax.mail.MessagingException, java.io.IOException
UDTValue. The file will be deleted after the
UDTValue has been created.event - The mail event of which to retrieve the message as file in an
UDTValue.fileStore - The directory for storing attachments. If this is
null, temporary files will be used for the
attachments.logger - The logger for log messages.UDTValue.javax.mail.MessagingException - If writing the mail to the file fails, a
MessagingException will be thrown.java.io.IOException - If creating the file or writing to the file fails, an
IOException will be thrown.protected static java.io.File writeMessageToFile(MailEvent event, boolean intermediate, java.io.File fileStore, java.util.logging.Logger logger) throws javax.mail.MessagingException, java.io.IOException
event - The mail event of which to write the message to a file.intermediate - Whether the file is just for intermediate purpose and
thus the file name does not need to be unique for a longer time.fileStore - The directory for storing attachments. If this is
null, temporary files will be used for the
attachments.logger - The logger for log messages.javax.mail.MessagingException - If writing the mail to the file fails, a
MessagingException will be thrown.java.io.IOException - If creating the file or writing to the file fails, an
IOException will be thrown.protected static java.lang.String createFileNameForEvent(MailEvent event, boolean unique)
MAX_FILE_NAME_LENGTH).event - The mail event to create the file name for.unique - Whether the created file name should be unique to allow for
storing several mails in the same directory.protected static UDTValue attachmentsToUDT(Parameter parameter, MailEvent event, java.io.File fileStore, java.util.logging.Logger logger) throws javax.mail.MessagingException, java.io.IOException, InvalidUDTException
java.util.List<URI> or
a subtable, depending on the UDT of the designated parameter. parameter - The parameter for which to create a UDT value.event - The mail event of which to store all attachments of the
message.fileStore - The directory for storing attachments. If this is
null, temporary files will be used for the
attachments.logger - The logger for log messages.javax.mail.MessagingException - If there are problems retrieving the message
content/attachments or file data, a
MessagingException will be thrown.java.io.IOException - If there are problems serialising the list or the
subtable or creating the subtable-XML or if the directory below
the configured file store cannot be created, an
IOException will be thrown.InvalidUDTException - If the UDT name of the parameter is unknown,
there are problems creating an XML-document for the subtable or
the directory below the configured file store cannot be created,
an InvalidUDTException will be thrown.