@NotThreadSafe public class WSS4JAttachment extends org.apache.wss4j.common.ext.Attachment implements IAS4Attachment
InputStreams.| Modifier and Type | Field and Description |
|---|---|
static String |
CONTENT_DESCRIPTION_ATTACHMENT |
static String |
CONTENT_ID_PREFIX |
static String |
CONTENT_ID_SUFFIX |
| Constructor and Description |
|---|
WSS4JAttachment(AS4ResourceHelper aResHelper,
String sMimeType) |
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(String sName,
String sValue) |
void |
addToMimeMultipart(javax.mail.internet.MimeMultipart aMimeMultipart) |
static boolean |
canBeKeptInMemory(long nBytes)
Check if an incoming attachment can be kept in memory, or if a temporary
file is needed.
|
static WSS4JAttachment |
createIncomingFileAttachment(javax.mail.internet.MimeBodyPart aBodyPart,
AS4ResourceHelper aResHelper) |
static WSS4JAttachment |
createOutgoingFileAttachment(byte[] aSrcData,
String sContentID,
String sFilename,
com.helger.commons.mime.IMimeType aMimeType,
EAS4CompressionMode eCompressionMode,
AS4ResourceHelper aResHelper)
Quasi constructor.
|
static WSS4JAttachment |
createOutgoingFileAttachment(File aSrcFile,
com.helger.commons.mime.IMimeType aMimeType,
EAS4CompressionMode eCompressionMode,
AS4ResourceHelper aResHelper) |
static WSS4JAttachment |
createOutgoingFileAttachment(File aSrcFile,
String sContentID,
com.helger.commons.mime.IMimeType aMimeType,
EAS4CompressionMode eCompressionMode,
AS4ResourceHelper aResHelper) |
static WSS4JAttachment |
createOutgoingFileAttachment(File aSrcFile,
String sContentID,
String sFilename,
com.helger.commons.mime.IMimeType aMimeType,
EAS4CompressionMode eCompressionMode,
AS4ResourceHelper aResHelper)
Quasi constructor.
|
Charset |
getCharsetOrDefault(Charset aDefault) |
EAS4CompressionMode |
getCompressionMode() |
com.helger.mail.cte.EContentTransferEncoding |
getContentTransferEncoding() |
com.helger.commons.io.IHasInputStream |
getInputStreamProvider() |
AS4ResourceHelper |
getResHelper() |
InputStream |
getSourceStream()
Get the source stream of the attachment using the default resource helper.
|
InputStream |
getSourceStream(AS4ResourceHelper aResourceHelper)
Get the source stream of the attachment using the provided resource helper.
|
String |
getUncompressedMimeType() |
boolean |
hasCharset() |
void |
overwriteMimeType(String sMimeType) |
WSS4JAttachment |
setCharset(Charset aCharset) |
WSS4JAttachment |
setCompressionMode(EAS4CompressionMode eCompressionMode) |
WSS4JAttachment |
setContentTransferEncoding(com.helger.mail.cte.EContentTransferEncoding eCTE) |
void |
setMimeType(String sMimeType)
Deprecated.
|
void |
setSourceStream(InputStream sourceStream)
Deprecated.
Do not use this, because it can be opened only once. Use
setSourceStreamProvider(IHasInputStream) instead. |
void |
setSourceStreamProvider(com.helger.commons.io.IHasInputStream aISP) |
void |
setUniqueID()
Create a random UUID based ID and call
Attachment.setId(String) |
String |
toString() |
addHeaders, getHeaders, getId, getMimeType, setIdclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetCharset, getId, getMimeType, hasCompressionMode, isRepeatablepublic static final String CONTENT_DESCRIPTION_ATTACHMENT
public static final String CONTENT_ID_PREFIX
public static final String CONTENT_ID_SUFFIX
public WSS4JAttachment(@Nonnull @WillNotClose AS4ResourceHelper aResHelper, @Nullable String sMimeType)
@Nonnull public final AS4ResourceHelper getResHelper()
null.public void setUniqueID()
Attachment.setId(String)@Deprecated @UnsupportedOperation public final void setMimeType(@Nullable String sMimeType)
setMimeType in class org.apache.wss4j.common.ext.Attachmentpublic final void addHeader(String sName, String sValue)
addHeader in class org.apache.wss4j.common.ext.Attachment@Nullable public String getUncompressedMimeType()
getUncompressedMimeType in interface IAS4Attachmentnull.@Nonnull public InputStream getSourceStream()
IAS4AttachmentgetSourceStream in interface IAS4AttachmentgetSourceStream in class org.apache.wss4j.common.ext.Attachmentnull InputStream on the source.@Nonnull public InputStream getSourceStream(@Nonnull AS4ResourceHelper aResourceHelper)
IAS4AttachmentgetSourceStream in interface IAS4AttachmentaResourceHelper - The resource helper to use. May not be null.null InputStream on the source.@Deprecated @UnsupportedOperation public void setSourceStream(InputStream sourceStream)
setSourceStreamProvider(IHasInputStream) instead.setSourceStream in class org.apache.wss4j.common.ext.Attachment@Nullable public com.helger.commons.io.IHasInputStream getInputStreamProvider()
getInputStreamProvider in interface IAS4Attachmentpublic void setSourceStreamProvider(@Nonnull com.helger.commons.io.IHasInputStream aISP)
@Nonnull public final com.helger.mail.cte.EContentTransferEncoding getContentTransferEncoding()
getContentTransferEncoding in interface IAS4Attachmentnull.@Nonnull public final WSS4JAttachment setContentTransferEncoding(@Nonnull com.helger.mail.cte.EContentTransferEncoding eCTE)
@Nullable public final EAS4CompressionMode getCompressionMode()
getCompressionMode in interface IAS4Attachmentnull if the attachment
is not compressed.@Nonnull public final WSS4JAttachment setCompressionMode(@Nonnull EAS4CompressionMode eCompressionMode)
@Nullable public final Charset getCharsetOrDefault(@Nullable Charset aDefault)
getCharsetOrDefault in interface IAS4Attachmentpublic final boolean hasCharset()
hasCharset in interface IAS4Attachment@Nonnull public final WSS4JAttachment setCharset(@Nullable Charset aCharset)
public void addToMimeMultipart(@Nonnull javax.mail.internet.MimeMultipart aMimeMultipart) throws javax.mail.MessagingException
javax.mail.MessagingException@Nonnull public static WSS4JAttachment createOutgoingFileAttachment(@Nonnull File aSrcFile, @Nonnull com.helger.commons.mime.IMimeType aMimeType, @Nullable EAS4CompressionMode eCompressionMode, @Nonnull AS4ResourceHelper aResHelper) throws IOException
IOException@Nonnull public static WSS4JAttachment createOutgoingFileAttachment(@Nonnull File aSrcFile, @Nullable String sContentID, @Nonnull com.helger.commons.mime.IMimeType aMimeType, @Nullable EAS4CompressionMode eCompressionMode, @Nonnull @WillNotClose AS4ResourceHelper aResHelper) throws IOException
IOException@Nonnull public static WSS4JAttachment createOutgoingFileAttachment(@Nonnull File aSrcFile, @Nullable String sContentID, @Nullable String sFilename, @Nonnull com.helger.commons.mime.IMimeType aMimeType, @Nullable EAS4CompressionMode eCompressionMode, @Nonnull @WillNotClose AS4ResourceHelper aResHelper) throws IOException
aSrcFile - Source, uncompressed, unencrypted file.sContentID - Content-ID of the attachment. If null a random ID is
created.sFilename - Filename of the attachment. May be null in which case
no `Content-Disposition` header is created.aMimeType - Original mime type of the file.eCompressionMode - Optional compression mode to use. May be null.aResHelper - The resource manager to use. May not be null.null.IOException - In case something goes wrong during compression@Nonnull public static WSS4JAttachment createOutgoingFileAttachment(@Nonnull byte[] aSrcData, @Nullable String sContentID, @Nullable String sFilename, @Nonnull com.helger.commons.mime.IMimeType aMimeType, @Nullable EAS4CompressionMode eCompressionMode, @Nonnull AS4ResourceHelper aResHelper) throws IOException
aSrcData - Source in-memory data, uncompressed, unencrypted.sContentID - Optional content ID or null to create a random one.
Filename of the attachment. May be null in which case
no `Content-Disposition` header is created.aMimeType - Original mime type of the file. May not be null.eCompressionMode - Optional compression mode to use. May be null.aResHelper - The resource manager to use. May not be null.null.IOException - In case something goes wrong during compressionpublic static boolean canBeKeptInMemory(long nBytes)
nBytes - File size.true if the size is ≤ than 64 Kilobytes@Nonnull public static WSS4JAttachment createIncomingFileAttachment(@Nonnull javax.mail.internet.MimeBodyPart aBodyPart, @Nonnull AS4ResourceHelper aResHelper) throws javax.mail.MessagingException, IOException
javax.mail.MessagingExceptionIOExceptionCopyright © 2015–2020 Philip Helger. All rights reserved.