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 |
addAttachment(List<Attachment> attachments,
Object content,
String type,
boolean base64Encode)
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 |
createAttachment(ImmutableConnectorMessage connectorMessage,
Object content,
String type,
boolean base64Encode)
Creates an attachment associated with a given connector message, and inserts it into the
database.
|
static Attachment |
getMessageAttachment(ImmutableConnectorMessage connectorMessage,
String attachmentId)
Retrieves an attachment from the current channel/message ID.
|
static Attachment |
getMessageAttachment(ImmutableConnectorMessage connectorMessage,
String attachmentId,
boolean base64Decode)
Retrieves an attachment from the current channel/message ID.
|
static Attachment |
getMessageAttachment(String channelId,
Long messageId,
String attachmentId)
Retrieves an attachment from a specific channel/message ID.
|
static Attachment |
getMessageAttachment(String channelId,
Long messageId,
String attachmentId,
boolean base64Decode)
Retrieves an attachment from a specific channel/message ID.
|
static List<String> |
getMessageAttachmentIds(ImmutableConnectorMessage connectorMessage)
Returns a List of attachment IDs associated with the current channel / message.
|
static List<String> |
getMessageAttachmentIds(String channelId,
Long messageId)
Returns a List of attachment IDs associated with the current channel / message.
|
static List<Attachment> |
getMessageAttachments(ImmutableConnectorMessage connectorMessage)
Retrieves all attachments associated with a connector message.
|
static List<Attachment> |
getMessageAttachments(ImmutableConnectorMessage connectorMessage,
boolean base64Decode)
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> |
getMessageAttachments(String channelId,
Long messageId,
boolean base64Decode)
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 List<Attachment> |
getMessageAttachmentsFromSourceChannel(ImmutableConnectorMessage connectorMessage,
boolean base64Decode)
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.
|
static Attachment |
updateAttachment(ImmutableConnectorMessage connectorMessage,
Attachment attachment)
Updates an attachment associated with a given connector message.
|
static Attachment |
updateAttachment(ImmutableConnectorMessage connectorMessage,
Attachment attachment,
boolean base64Encode)
Updates an attachment associated with a given connector message.
|
static Attachment |
updateAttachment(ImmutableConnectorMessage connectorMessage,
String attachmentId,
Object content,
String type)
Updates an attachment associated with a given connector message.
|
static Attachment |
updateAttachment(ImmutableConnectorMessage connectorMessage,
String attachmentId,
Object content,
String type,
boolean base64Encode)
Updates an attachment associated with a given connector message.
|
static Attachment |
updateAttachment(String channelId,
Long messageId,
Attachment attachment)
Updates an attachment associated with a given connector message.
|
static Attachment |
updateAttachment(String channelId,
Long messageId,
Attachment attachment,
boolean base64Encode)
Updates an attachment associated with a given connector message.
|
static Attachment |
updateAttachment(String channelId,
Long messageId,
String attachmentId,
Object content,
String type)
Updates an attachment associated with a given connector message.
|
static Attachment |
updateAttachment(String channelId,
Long messageId,
String attachmentId,
Object content,
String type,
boolean base64Encode)
Updates an attachment associated with a given connector message.
|
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<String> getMessageAttachmentIds(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
- If the attachment IDs could be retrieved.public static List<String> getMessageAttachmentIds(String channelId, Long messageId) throws com.mirth.connect.donkey.model.message.MessageSerializerException
channelId
- The ID of the channel the attachments are associated with.messageId
- The ID of the message the attachments are associated with.com.mirth.connect.donkey.model.message.MessageSerializerException
- If the attachment IDs could be retrieved.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
- If the attachments could not be retrieved.public static List<Attachment> getMessageAttachments(ImmutableConnectorMessage connectorMessage, boolean base64Decode) throws com.mirth.connect.donkey.model.message.MessageSerializerException
connectorMessage
- The ConnectorMessage associated with this message, used to identify the
channel/message ID.base64Decode
- If true, the content of each attachment will first be Base64 decoded for
convenient use.com.mirth.connect.donkey.model.message.MessageSerializerException
- If the attachments could not be retrieved.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
- If the attachments could not be retrieved.public static List<Attachment> getMessageAttachments(String channelId, Long messageId, boolean base64Decode) 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.base64Decode
- If true, the content of each attachment will first be Base64 decoded for
convenient use.com.mirth.connect.donkey.model.message.MessageSerializerException
- If the attachments could not be retrieved.public static Attachment getMessageAttachment(ImmutableConnectorMessage connectorMessage, String attachmentId) throws com.mirth.connect.donkey.model.message.MessageSerializerException
connectorMessage
- The ConnectorMessage associated with this message, used to identify the
channel/message ID.attachmentId
- The ID of the attachment to retrieve.com.mirth.connect.donkey.model.message.MessageSerializerException
- If the attachment could not be retrieved.public static Attachment getMessageAttachment(ImmutableConnectorMessage connectorMessage, String attachmentId, boolean base64Decode) throws com.mirth.connect.donkey.model.message.MessageSerializerException
connectorMessage
- The ConnectorMessage associated with this message, used to identify the
channel/message ID.attachmentId
- The ID of the attachment to retrieve.base64Decode
- If true, the content of each attachment will first be Base64 decoded for
convenient use.com.mirth.connect.donkey.model.message.MessageSerializerException
- If the attachment could not be retrieved.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
- If the attachment could not be retrieved.public static Attachment getMessageAttachment(String channelId, Long messageId, String attachmentId, boolean base64Decode) 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.base64Decode
- If true, the content of each attachment will first be Base64 decoded for
convenient use.com.mirth.connect.donkey.model.message.MessageSerializerException
- If the attachment could not be retrieved.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
- If the attachments could not be retrieved.public static List<Attachment> getMessageAttachmentsFromSourceChannel(ImmutableConnectorMessage connectorMessage, boolean base64Decode) 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.base64Decode
- If true, the content of each attachment will first be Base64 decoded for
convenient use.com.mirth.connect.donkey.model.message.MessageSerializerException
- If the attachments could not be retrieved.public static Attachment addAttachment(List<Attachment> attachments, Object content, String type) throws com.mirth.connect.donkey.server.controllers.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.com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
- If the attachment content is not a String or byte array.public static Attachment addAttachment(List<Attachment> attachments, Object content, String type, boolean base64Encode) throws com.mirth.connect.donkey.server.controllers.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.base64Encode
- If true, the content of each attachment will first be Base64 encoded for
convenience.com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
- If the attachment content is not a String or byte array.public static Attachment createAttachment(ImmutableConnectorMessage connectorMessage, Object content, String type) throws com.mirth.connect.donkey.server.controllers.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.com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
- If the attachment content is not a String or byte array.public static Attachment createAttachment(ImmutableConnectorMessage connectorMessage, Object content, String type, boolean base64Encode) throws com.mirth.connect.donkey.server.controllers.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.base64Encode
- If true, the content of each attachment will first be Base64 encoded for
convenience.com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
- If the attachment content is not a String or byte array.public static Attachment updateAttachment(ImmutableConnectorMessage connectorMessage, String attachmentId, Object content, String type) throws com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
connectorMessage
- The connector message to be associated with the attachment.attachmentId
- The unique ID of the attachment to update.content
- The attachment content (must be a string or byte array).type
- The MIME type of the attachment.com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
- If the attachment content is not a String or byte array.public static Attachment updateAttachment(ImmutableConnectorMessage connectorMessage, String attachmentId, Object content, String type, boolean base64Encode) throws com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
connectorMessage
- The connector message to be associated with the attachment.attachmentId
- The unique ID of the attachment to update.content
- The attachment content (must be a string or byte array).type
- The MIME type of the attachment.base64Encode
- If true, the content of each attachment will first be Base64 encoded for
convenience.com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
- If the attachment content is not a String or byte array.public static Attachment updateAttachment(ImmutableConnectorMessage connectorMessage, Attachment attachment) throws com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
connectorMessage
- The connector message to be associated with the attachment.attachment
- The Attachment object to update.com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
- If the attachment content is not a String or byte array.public static Attachment updateAttachment(ImmutableConnectorMessage connectorMessage, Attachment attachment, boolean base64Encode) throws com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
connectorMessage
- The connector message to be associated with the attachment.attachment
- The Attachment object to update.base64Encode
- If true, the content of each attachment will first be Base64 encoded for
convenience.com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
- If the attachment content is not a String or byte array.public static Attachment updateAttachment(String channelId, Long messageId, Attachment attachment) throws com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
channelId
- The ID of the channel the attachment is associated with.messageId
- The ID of the message the attachment is associated with.attachment
- The Attachment object to update.com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
- If the attachment content is not a String or byte array.public static Attachment updateAttachment(String channelId, Long messageId, Attachment attachment, boolean base64Encode) throws com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
channelId
- The ID of the channel the attachment is associated with.messageId
- The ID of the message the attachment is associated with.attachment
- The Attachment object to update.base64Encode
- If true, the content of each attachment will first be Base64 encoded for
convenience.com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
- If the attachment content is not a String or byte array.public static Attachment updateAttachment(String channelId, Long messageId, String attachmentId, Object content, String type) throws com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
channelId
- The ID of the channel the attachment is associated with.messageId
- The ID of the message the attachment is associated with.attachmentId
- The unique ID of the attachment to update.content
- The attachment content (must be a string or byte array).type
- The MIME type of the attachment.com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
- If the attachment content is not a String or byte array.public static Attachment updateAttachment(String channelId, Long messageId, String attachmentId, Object content, String type, boolean base64Encode) throws com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
channelId
- The ID of the channel the attachment is associated with.messageId
- The ID of the message the attachment is associated with.attachmentId
- The unique ID of the attachment to update.content
- The attachment content (must be a string or byte array).type
- The MIME type of the attachment.base64Encode
- If true, the content of each attachment will first be Base64 encoded for
convenience.com.mirth.connect.donkey.server.controllers.UnsupportedDataTypeException
- If the attachment content is not a String or byte array.