@ConfigurationDescription(properties={@Property(name="IsCritical",type=BOOLEAN,defaultValue="true",description="Whether the event handler is critical and problems handling the event should abort all handling of the current event."),,,,}) public class MailEventActivityHandler extends AbstractActivityEventHandler
This implementation is robust with respect to invalid parameter configurations and conversions, that is a parameter configuration referring to an unknown field of the mail or failing value conversions are just logged. The activity will be terminated normally but in case of a mandatory output parameter this will fail the activity.
| Modifier and Type | Field and Description |
|---|---|
protected java.io.File |
fileStore
The configured file store path, used for providing the mail content as file
URI to the started process or
null in case no files should be
stored. |
static long |
HANDLER_MAIL_INVALID_DATA_TYPE_EXCEPTION_CODE
Code for an output parameter having an inappropriate type.
|
static java.lang.String |
HANDLER_MAIL_INVALID_DATA_TYPE_EXCEPTION_STATE
State for an output parameter having an inappropriate type.
|
static long |
HANDLER_MAIL_IO_EXCEPTION_CODE
Code for creating UDT values based on the message fields or content fails.
|
static java.lang.String |
HANDLER_MAIL_IO_EXCEPTION_STATE
State for creating UDT values based on the message fields or content fails.
|
static long |
HANDLER_MAIL_MESSAGING_EXCEPTION_CODE
Code for retrieving fields from the message fails.
|
static java.lang.String |
HANDLER_MAIL_MESSAGING_EXCEPTION_STATE
State for retrieving fields from the message fails.
|
static java.lang.String |
PAC_MAIL_EVENT_FIELD
Parameter activity configuration: the field of the mail to be stored, e.g
MailTools.PARAM_BODY. |
static java.lang.String |
PAC_MAIL_EVENT_REGEX
Parameter activity configuration: a regular expression for picking some
data out of the message body and store it to the parameter.
|
static java.lang.String |
PAC_MAIL_EVENT_REGEX_GROUP
Parameter activity configuration: the matching group of
PAC_MAIL_EVENT_REGEX to be used for getting the data from the
matched regex. |
static java.lang.String |
PARAM_AC_PREFIX
Prefix for our configuration values in the parameter's activity
configuration.
|
contexts, eventManagerconsuming, critical, exclusive, id, interruptible, logger| Constructor and Description |
|---|
MailEventActivityHandler(Configuration conf,
ActivityEventManager eventManager,
Registry registry)
Creates a new handler for mail events that starts or resumes activities and
stores data from the mail in their output data context.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
canHandle(Event event,
boolean consumed)
Gets whether the designated event can be handled by this (sub-)class.
|
protected void |
handleField(java.lang.String field,
Parameter param,
MailEvent event,
ActivityData data)
Gets the designated field from the message of the designated mail event and
stores the value for the output parameter in the designated data context.
|
protected void |
handleRegEx(java.lang.String regex,
Parameter param,
MailEvent event,
ActivityData data)
Applies the designated regular expression to (the string representation of)
the content of the message of the designated mail event and stores the
match for the output parameter in the designated data context.
|
protected boolean |
processEvent(Event event,
ActivityInstance activity,
DataContext dataContext)
Processes the designated event for the designated activity instance.
|
close, handleEvent, init, kill, remove, reset, signal, suspendgetID, isConsuming, isCritical, isExclusive, isInterruptibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetID, isConsuming, isExclusive, isInterruptiblepublic static final java.lang.String HANDLER_MAIL_MESSAGING_EXCEPTION_STATE
public static final long HANDLER_MAIL_MESSAGING_EXCEPTION_CODE
public static final java.lang.String HANDLER_MAIL_IO_EXCEPTION_STATE
public static final long HANDLER_MAIL_IO_EXCEPTION_CODE
public static final java.lang.String HANDLER_MAIL_INVALID_DATA_TYPE_EXCEPTION_STATE
public static final long HANDLER_MAIL_INVALID_DATA_TYPE_EXCEPTION_CODE
public static final java.lang.String PARAM_AC_PREFIX
public static final java.lang.String PAC_MAIL_EVENT_FIELD
MailTools.PARAM_BODY.public static final java.lang.String PAC_MAIL_EVENT_REGEX
public static final java.lang.String PAC_MAIL_EVENT_REGEX_GROUP
PAC_MAIL_EVENT_REGEX to be used for getting the data from the
matched regex. Defaults to group 1.protected final java.io.File fileStore
null in case no files should be
stored.public MailEventActivityHandler(Configuration conf, ActivityEventManager eventManager, Registry registry) throws ConfigurationException
conf - The configuration for this plugin instance.eventManager - The event manager for communicating with the runtime
service.registry - The registry for retrieving the plugin instance name
(handler ID).ConfigurationException - If there are problems creating the
configured file store or writing to it, a
ConfigurationException will be thrown.protected boolean canHandle(Event event, boolean consumed)
AbstractActivityEventHandlercanHandle in class AbstractActivityEventHandlerevent - The event which is about to be handled.consumed - Whether the event has been consumed by a previous event
handler.true).protected boolean processEvent(Event event, ActivityInstance activity, DataContext dataContext)
AbstractActivityEventHandlerprocessEvent in class AbstractActivityEventHandlerevent - The event to be processed.activity - The activity for which to process event. This also provides
the configuration of the activity and also the defined output
parameters.dataContext - The data context to write the values of the output
parameters to.true).ApplicationFailedException - If
ApplicationFailedException will be thrown.protected void handleField(java.lang.String field,
Parameter param,
MailEvent event,
ActivityData data)
throws java.io.IOException,
javax.mail.MessagingException
field - The field which to retrieve from the message.param - The output parameter for which to retrieve the value.event - The mail event that is currently being handled.data - The activity data in which to store the determined value of the
output parameter.java.io.IOException - If there are problems serialising fields of the message
or retrieving content, an IOException will be thrown.javax.mail.MessagingException - If there are problems retrieving the message
content or its fields, a MessagingException will be
thrown.protected void handleRegEx(java.lang.String regex,
Parameter param,
MailEvent event,
ActivityData data)
throws javax.mail.MessagingException,
java.io.IOException
regex - The regular expression which to apply to (the string
representation of) the message content.param - The output parameter for which to retrieve the value with the
regular expression.event - The mail event that is currently being handled.data - The activity data in which to store the determined value of the
output parameter.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.