Package de.aristaflow.adept2.model.mail
Class URLAttachment
- java.lang.Object
-
- de.aristaflow.adept2.model.mail.SerialisableAttachment
-
- de.aristaflow.adept2.model.mail.URLAttachment
-
- All Implemented Interfaces:
Closeable
,Serializable
,AutoCloseable
public class URLAttachment extends SerialisableAttachment
ASerialisableAttachment
providing aURL
for the content. Note that this can only be used if theURL
is accessible by the mail service. Otherwise the content cannot be attached!- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected URL
url
TheURL
where to get the content to attach from.-
Fields inherited from class de.aristaflow.adept2.model.mail.SerialisableAttachment
contentType, description, inlineName, name
-
-
Constructor Summary
Constructors Constructor Description URLAttachment(String name, String description, String contentType, URL url)
Creates an attachment having the designated name, description, content type (MIME) andURL
providing the content.URLAttachment(String name, String description, String contentType, URL url, boolean inline)
Creates an attachment having the designated name, description, content type (MIME) andURL
providing the content.URLAttachment(String name, String description, String contentType, URL url, String inlineName)
Creates an attachment having the designated name, description, content type (MIME) andURL
providing the content.URLAttachment(String name, String description, URL url)
Creates an attachment having the designated name, description andURL
providing the content.URLAttachment(String name, String description, URL url, boolean inline)
Creates an attachment having the designated name, description andURL
providing the content.URLAttachment(String name, String description, URL url, String inlineName)
Creates an attachment having the designated name, description andURL
providing the content.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InputStream
getContent()
Gets the content of the attachment represented asInputStream
.-
Methods inherited from class de.aristaflow.adept2.model.mail.SerialisableAttachment
close, getContentType, getDescription, getInlineName, getName
-
-
-
-
Field Detail
-
url
protected final URL url
TheURL
where to get the content to attach from.
-
-
Constructor Detail
-
URLAttachment
public URLAttachment(String name, String description, URL url)
Creates an attachment having the designated name, description andURL
providing the content. The content type is set to "application/octet-stream".- Parameters:
name
- The name of the attachment.description
- The description of the attachment.url
- TheURL
where to get the content to attach from. This needs to be accessible from theMailService
!
-
URLAttachment
public URLAttachment(String name, String description, URL url, boolean inline)
Creates an attachment having the designated name, description andURL
providing the content. The content type is set to "application/octet-stream".- Parameters:
name
- The name of the attachment.description
- The description of the attachment.url
- TheURL
where to get the content to attach from. This needs to be accessible from theMailService
!inline
- Whether to inline this attachment in case of an HTML message using the designated name.
-
URLAttachment
public URLAttachment(String name, String description, URL url, String inlineName)
Creates an attachment having the designated name, description andURL
providing the content. The content type is set to "application/octet-stream".- Parameters:
name
- The name of the attachment.description
- The description of the attachment.url
- TheURL
where to get the content to attach from. This needs to be accessible from theMailService
!inlineName
- The name used in the corresponding HTML message to refer to this attachment to be inlined. Usenull
to not inline the attachment.
-
URLAttachment
public URLAttachment(String name, String description, String contentType, URL url)
Creates an attachment having the designated name, description, content type (MIME) andURL
providing the content.- Parameters:
name
- The name of the attachment.description
- The description of the attachment.contentType
- The content type (MIME) of the attachment.url
- TheURL
where to get the content to attach from. This needs to be accessible from theMailService
!
-
URLAttachment
public URLAttachment(String name, String description, String contentType, URL url, boolean inline)
Creates an attachment having the designated name, description, content type (MIME) andURL
providing the content.- Parameters:
name
- The name of the attachment.description
- The description of the attachment.contentType
- The content type (MIME) of the attachment.url
- TheURL
where to get the content to attach from. This needs to be accessible from theMailService
!inline
- Whether to inline this attachment in case of an HTML message using the designated name.
-
URLAttachment
public URLAttachment(String name, String description, String contentType, URL url, String inlineName)
Creates an attachment having the designated name, description, content type (MIME) andURL
providing the content.- Parameters:
name
- The name of the attachment.description
- The description of the attachment.contentType
- The content type (MIME) of the attachment.url
- TheURL
where to get the content to attach from. This needs to be accessible from theMailService
!inlineName
- The name used in the corresponding HTML message to refer to this attachment to be inlined. Usenull
to not inline the attachment.
-
-
Method Detail
-
getContent
public InputStream getContent() throws IOException
Description copied from class:SerialisableAttachment
Gets the content of the attachment represented asInputStream
.
Note that this should only be called by the receiving service since theInputStream
cannot be serialised.- Specified by:
getContent
in 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
, anIOException
will be thrown.
-
-