public class AttachmentUtil extends Object
Modifier and Type | Method and Description |
---|---|
static Attachment |
addAttachment(List<Attachment> attachments,
Object content,
String type)
Creates an Attachment and adds it to the provided list.
|
static Attachment |
createAttachment(ImmutableConnectorMessage connectorMessage,
Object content,
String type)
Creates an attachment associated with a given connector message, and inserts it into the
database.
|
static Attachment |
getMessageAttachment(String channelId,
Long messageId,
String attachmentId)
Retrieves an attachment from a specific channel/message ID.
|
static List<Attachment> |
getMessageAttachments(ImmutableConnectorMessage connectorMessage)
Retrieves all attachments associated with a connector message.
|
static List<Attachment> |
getMessageAttachments(String channelId,
Long messageId)
Retrieves all attachments associated with a specific channel/message ID.
|
static List<Attachment> |
getMessageAttachmentsFromSourceChannel(ImmutableConnectorMessage connectorMessage)
Retrieves an attachment from an upstream channel that sent a message to the current channel.
|
static String |
reAttachMessage(ImmutableConnectorMessage connectorMessage)
Replaces any unique attachment tokens (e.g.
|
static String |
reAttachMessage(String raw,
ImmutableConnectorMessage connectorMessage)
Replaces any unique attachment tokens (e.g.
|
static byte[] |
reAttachMessage(String raw,
ImmutableConnectorMessage connectorMessage,
String charsetEncoding,
boolean binary)
Replaces any unique attachment tokens (e.g.
|
static byte[] |
reAttachMessage(String raw,
ImmutableConnectorMessage connectorMessage,
String charsetEncoding,
boolean binary,
boolean reattach,
boolean localOnly)
Replaces any unique attachment tokens (e.g.
|
public static byte[] reAttachMessage(String raw, ImmutableConnectorMessage connectorMessage, String charsetEncoding, boolean binary)
raw
- The raw message string to replace tokens from.connectorMessage
- The ConnectorMessage associated with this message, used to identify the
channel/message ID.charsetEncoding
- If binary mode is not used, the resulting byte array will be encoded using this
charset.binary
- If enabled, the raw data is assumed to be Base64 encoded. The resulting byte array
will be the raw Base64 decoded bytes.public static byte[] reAttachMessage(String raw, ImmutableConnectorMessage connectorMessage, String charsetEncoding, boolean binary, boolean reattach, boolean localOnly)
raw
- The raw message string to replace tokens from.connectorMessage
- The ConnectorMessage associated with this message, used to identify the
channel/message ID.charsetEncoding
- If binary mode is not used, the resulting byte array will be encoded using this
charset.binary
- If enabled, the raw data is assumed to be Base64 encoded. The resulting byte array
will be the raw Base64 decoded bytes.reattach
- If true, attachment tokens will be replaced with the actual attachment content.
Otherwise, local attachment tokens will be replaced only with the corresponding
expanded tokens.localOnly
- If true, only local attachment tokens will be replaced, and expanded tokens will
be ignored.public static String reAttachMessage(ImmutableConnectorMessage connectorMessage)
connectorMessage
- The ConnectorMessage associated with this message, used to identify the
channel/message ID. The message string will be either the encoded or raw content.public static String reAttachMessage(String raw, ImmutableConnectorMessage connectorMessage)
raw
- The raw message string to replace tokens from.connectorMessage
- The ConnectorMessage associated with this message, used to identify the
channel/message ID.public static List<Attachment> getMessageAttachments(ImmutableConnectorMessage connectorMessage) throws com.mirth.connect.donkey.model.message.MessageSerializerException
connectorMessage
- The ConnectorMessage associated with this message, used to identify the
channel/message ID.com.mirth.connect.donkey.model.message.MessageSerializerException
public static List<Attachment> getMessageAttachments(String channelId, Long messageId) throws com.mirth.connect.donkey.model.message.MessageSerializerException
channelId
- The ID of the channel to retrieve the attachments from.messageId
- The ID of the message to retrieve the attachments from.com.mirth.connect.donkey.model.message.MessageSerializerException
public static Attachment getMessageAttachment(String channelId, Long messageId, String attachmentId) throws com.mirth.connect.donkey.model.message.MessageSerializerException
channelId
- The ID of the channel to retrieve the attachment from.messageId
- The ID of the message to retrieve the attachment from.attachmentId
- The ID of the attachment to retrieve.com.mirth.connect.donkey.model.message.MessageSerializerException
public static List<Attachment> getMessageAttachmentsFromSourceChannel(ImmutableConnectorMessage connectorMessage) throws com.mirth.connect.donkey.model.message.MessageSerializerException
connectorMessage
- The ConnectorMessage associated with this message. The channel ID and message ID
will be retrieved from the source map.com.mirth.connect.donkey.model.message.MessageSerializerException
public static Attachment addAttachment(List<Attachment> attachments, Object content, String type) throws UnsupportedDataTypeException
attachments
- The list of attachments to add to.content
- The attachment content (must be a string or byte array).type
- The MIME type of the attachment.UnsupportedDataTypeException
public static Attachment createAttachment(ImmutableConnectorMessage connectorMessage, Object content, String type) throws UnsupportedDataTypeException
connectorMessage
- The connector message to be associated with the attachment.content
- The attachment content (must be a string or byte array).type
- The MIME type of the attachment.UnsupportedDataTypeException