Package de.aristaflow.adept2.model.mail
Class DataSourceAttachment
java.lang.Object
de.aristaflow.adept2.model.mail.SerialisableAttachment
de.aristaflow.adept2.model.mail.DataSourceAttachment
- All Implemented Interfaces:
Closeable,Serializable,AutoCloseable
A
SerialisableAttachment having a datasource as content. If this attachment is
serialised, it will become a ByteArrayDataSource.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final jakarta.activation.DataSourceThe data source providing the content.Fields inherited from class de.aristaflow.adept2.model.mail.SerialisableAttachment
contentType, description, inlineName, name -
Constructor Summary
ConstructorsConstructorDescriptionDataSourceAttachment(jakarta.activation.DataSource dataSource, String description) Creates an attachment having the designated data source (content, name and content type).DataSourceAttachment(jakarta.activation.DataSource dataSource, String description, boolean inline) Creates an attachment having the designated data source (content, name and content type).DataSourceAttachment(jakarta.activation.DataSource dataSource, String description, String inlineName) Creates an attachment having the designated data source (content, name and content type).DataSourceAttachment(String name, String description, jakarta.activation.DataSource dataSource) Creates an attachment having the designated name and description retrieving the content from the designated data source.DataSourceAttachment(String name, String description, String contentType, jakarta.activation.DataSource dataSource) Creates an attachment having the designated name, description and content type retrieving the content from the designated data source.DataSourceAttachment(String name, String description, String contentType, jakarta.activation.DataSource dataSource, boolean inline) Creates an attachment having the designated name, description and content type retrieving the content from the designated data source.DataSourceAttachment(String name, String description, String contentType, jakarta.activation.DataSource dataSource, String inlineName) Creates an attachment having the designated name, description and content type retrieving the content from the designated data source. -
Method Summary
Modifier and TypeMethodDescriptionGets the content of the attachment represented asInputStream.Methods inherited from class de.aristaflow.adept2.model.mail.SerialisableAttachment
close, getContentType, getDescription, getInlineName, getName
-
Field Details
-
dataSource
protected final jakarta.activation.DataSource dataSourceThe data source providing the content.
-
-
Constructor Details
-
DataSourceAttachment
public DataSourceAttachment(String name, String description, jakarta.activation.DataSource dataSource) Creates an attachment having the designated name and description retrieving the content from the designated data source. The content type is set to "application/octet-stream". This allows to override name and content type of the data source.- Parameters:
name- The name of the attachment.description- The description of the attachment.dataSource- The data source providing the content (only).
-
DataSourceAttachment
Creates an attachment having the designated data source (content, name and content type).- Parameters:
dataSource- The data source providing the content (and the name and the content type).description- The description of the attachment.
-
DataSourceAttachment
public DataSourceAttachment(String name, String description, String contentType, jakarta.activation.DataSource dataSource) Creates an attachment having the designated name, description and content type retrieving the content from the designated data source. This allows to override name and content type of the data source.- Parameters:
name- The name of the attachment.description- The description of the attachment.contentType- The content type (MIME) of the attachment.dataSource- The data source providing the content (only).
-
DataSourceAttachment
public DataSourceAttachment(jakarta.activation.DataSource dataSource, String description, boolean inline) Creates an attachment having the designated data source (content, name and content type).- Parameters:
dataSource- The data source providing the content (and the name and the content type).description- The description of the attachment.inline- Whether to inline this attachment in case of an HTML message using the designated name.
-
DataSourceAttachment
public DataSourceAttachment(String name, String description, String contentType, jakarta.activation.DataSource dataSource, boolean inline) Creates an attachment having the designated name, description and content type retrieving the content from the designated data source. This allows to override name and content type of the data source.- Parameters:
name- The name of the attachment.description- The description of the attachment.contentType- The content type (MIME) of the attachment.dataSource- The data source providing the content (only).inline- Whether to inline this attachment in case of an HTML message using the designated name.
-
DataSourceAttachment
public DataSourceAttachment(jakarta.activation.DataSource dataSource, String description, String inlineName) Creates an attachment having the designated data source (content, name and content type).- Parameters:
dataSource- The data source providing the content (and the name and the content type).description- The description of the attachment.inlineName- The name used in the corresponding HTML message to refer to this attachment to be inlined. Usenullto not inline the attachment.
-
DataSourceAttachment
public DataSourceAttachment(String name, String description, String contentType, jakarta.activation.DataSource dataSource, String inlineName) Creates an attachment having the designated name, description and content type retrieving the content from the designated data source. This allows to override name and content type of the data source.- Parameters:
name- The name of the attachment.description- The description of the attachment.contentType- The content type (MIME) of the attachment.dataSource- The data source providing the content (only).inlineName- The name used in the corresponding HTML message to refer to this attachment to be inlined. Usenullto not inline the attachment.
-
-
Method Details
-
getContent
Description copied from class:SerialisableAttachmentGets the content of the attachment represented asInputStream.
Note that this should only be called by the receiving service since theInputStreamcannot be serialised.- Specified by:
getContentin classSerialisableAttachment- Returns:
- The actual data of the attachment. The caller is responsible for closing.
- Throws:
IOException- If there are problems retrieving the content, for instance converting the transferred serialisable data to anInputStream, anIOExceptionwill be thrown.
-