public class MimeAggregator extends MessageAggregatorImpl
MessageAggregator
implementation that creates a new mime part for each message that needs to be joined up.
The pre-split message is always treated as the first part of the resulting multipart message; the payloads from the split
messages form the second and subsequent parts. If the split message contains a specific metadata key (as configured by
setPartContentIdMetadataKey(String)
) then the corresponding value will be used as that parts Content-Id
. If
the metadata key does not exist, or is not configured, then the split message's unique-id will be used. If the same
Content-Id
is observed for multiple split messages then results are undefined. The most likely situation is that
parts will be lost and only one preserved.
Note that the first part's Content-Id
will always be the original messages unique-id. Also, if the original message
was a Multipart message, then this will be added as a single part to the resulting multipart message (giving you a nested
multipart as the first part).
As a result of this join operation, the message will be marked as MIME encoded using CoreConstants.MSG_MIME_ENCODED
metadata.
CoreConstants.MSG_MIME_ENCODED
In the adapter configuration file this class is aliased as mime-aggregator which is the preferred alternative to the fully qualified classname when building your configuration.
Constructor and Description |
---|
MimeAggregator() |
Modifier and Type | Method and Description |
---|---|
protected javax.mail.internet.MimeBodyPart |
createBodyPart(AdaptrisMessage msg) |
protected MultiPartOutput |
createInitialPart(AdaptrisMessage original) |
java.lang.String |
getEncoding() |
protected java.lang.String |
getMetadataValue(AdaptrisMessage msg,
java.lang.String key,
java.lang.String defaultValue) |
java.lang.String |
getPartContentIdMetadataKey() |
java.lang.String |
getPartContentTypeMetadataKey() |
void |
joinMessage(AdaptrisMessage original,
java.util.Collection<AdaptrisMessage> messages)
Joins multiple
AdaptrisMessage s into a single AdaptrisMessage objects. |
void |
setEncoding(java.lang.String s)
Set the encoding to be used for the content.
|
void |
setPartContentIdMetadataKey(java.lang.String s)
Set the content ID for a given mime part based on a metadata key.
|
void |
setPartContentTypeMetadataKey(java.lang.String s)
The key to derive the content-type.
|
getOverwriteMetadata, overwriteMetadata, overwriteMetadata, setOverwriteMetadata
public void joinMessage(AdaptrisMessage original, java.util.Collection<AdaptrisMessage> messages) throws CoreException
MessageAggregator
Joins multiple AdaptrisMessage
s into a single AdaptrisMessage objects. Preservation of metadata is down to the
implementation.
original
- the msg to insert all the messages intomessages
- the list of messages to join.CoreException
- wrapping any other exceptionprotected javax.mail.internet.MimeBodyPart createBodyPart(AdaptrisMessage msg) throws javax.mail.MessagingException, java.io.IOException
javax.mail.MessagingException
java.io.IOException
protected MultiPartOutput createInitialPart(AdaptrisMessage original) throws javax.mail.MessagingException, java.io.IOException
javax.mail.MessagingException
java.io.IOException
public java.lang.String getEncoding()
public void setEncoding(java.lang.String s)
s
- the encoding to set, defaults to no-encoding (null)public java.lang.String getPartContentIdMetadataKey()
public void setPartContentIdMetadataKey(java.lang.String s)
s
- the partContentIdMetadataKey to setprotected java.lang.String getMetadataValue(AdaptrisMessage msg, java.lang.String key, java.lang.String defaultValue)
public java.lang.String getPartContentTypeMetadataKey()
public void setPartContentTypeMetadataKey(java.lang.String s)
s
- the partContentTypeMetadataKey to set