Package org.apache.axiom.attachments
Class Attachments
java.lang.Object
org.apache.axiom.attachments.Attachments
- All Implemented Interfaces:
OMAttachmentAccessor
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionUse this constructor when instantiating this to store the attachments set programatically through the SwA API.Attachments(InputStream inStream, String contentTypeString) Sets file cache to false.Attachments(InputStream inStream, String contentTypeString, boolean fileCacheEnable, String attachmentRepoDir, String fileThreshold) Moves the pointer to the beginning of the first MIME part.Attachments(InputStream inStream, String contentTypeString, boolean fileCacheEnable, String attachmentRepoDir, String fileThreshold, int contentLength) Moves the pointer to the beginning of the first MIME part.Attachments(LifecycleManager manager, InputStream inStream, String contentTypeString, boolean fileCacheEnable, String attachmentRepoDir, String fileThreshold) Moves the pointer to the beginning of the first MIME part.Attachments(LifecycleManager manager, InputStream inStream, String contentTypeString, boolean fileCacheEnable, String attachmentRepoDir, String fileThreshold, int contentLength) Moves the pointer to the beginning of the first MIME part. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDataHandler(String contentID, DataHandler dataHandler) Programatically adding an SOAP with Attachments(SwA) Attachment.String[]Get the content IDs of all MIME parts in the message.Identify the type of message (MTOM or SOAP with attachments) represented by this object.Get the content IDs of the already loaded MIME parts in the message.Get the content IDs of all MIME parts in the message.longIf the Attachments is backed by an InputStream, then this method returns the length of the message contents (Length of the entire message - Length of the Transport Headers)getDataHandler(String blobContentID) Checks whether the MIME part is already parsed by checking the attachments HashMap.Get the headers of the already loaded MIME parts in the message.Returns the rest of mime stream.Stream based accessgetMap()Get a map of all MIME parts in the message.voidremoveDataHandler(String blobContentID) Removes the DataHandler corresponding to the given contenID.protected voidsetEndOfStream(boolean value) endOfStreamReached will be set to true if the message ended in MIME Style having "--" suffix with the last mime boundaryvoidsetHeaders(Map headers) Set the headers of the MIME parts in the message.voidsetLifecycleManager(LifecycleManager manager)
-
Field Details
-
log
protected static org.apache.commons.logging.Log log
-
-
Constructor Details
-
Attachments
public Attachments(LifecycleManager manager, InputStream inStream, String contentTypeString, boolean fileCacheEnable, String attachmentRepoDir, String fileThreshold) throws OMException Moves the pointer to the beginning of the first MIME part. Reads till first MIME boundary is found or end of stream is reached.- Parameters:
inStream-contentTypeString-fileCacheEnable-attachmentRepoDir-- Throws:
OMException
-
Attachments
public Attachments(LifecycleManager manager, InputStream inStream, String contentTypeString, boolean fileCacheEnable, String attachmentRepoDir, String fileThreshold, int contentLength) throws OMException Moves the pointer to the beginning of the first MIME part. Reads till first MIME boundary is found or end of stream is reached.- Parameters:
inStream-contentTypeString-fileCacheEnable-attachmentRepoDir-fileThreshold-contentLength-- Throws:
OMException
-
Attachments
public Attachments(InputStream inStream, String contentTypeString, boolean fileCacheEnable, String attachmentRepoDir, String fileThreshold) throws OMException Moves the pointer to the beginning of the first MIME part. Reads till first MIME boundary is found or end of stream is reached.- Parameters:
inStream-contentTypeString-fileCacheEnable-attachmentRepoDir-- Throws:
OMException
-
Attachments
public Attachments(InputStream inStream, String contentTypeString, boolean fileCacheEnable, String attachmentRepoDir, String fileThreshold, int contentLength) throws OMException Moves the pointer to the beginning of the first MIME part. Reads till first MIME boundary is found or end of stream is reached.- Parameters:
inStream-contentTypeString-fileCacheEnable-attachmentRepoDir-fileThreshold-contentLength-- Throws:
OMException
-
Attachments
Sets file cache to false.- Parameters:
inStream-contentTypeString-- Throws:
OMException
-
Attachments
public Attachments()Use this constructor when instantiating this to store the attachments set programatically through the SwA API.
-
-
Method Details
-
getLifecycleManager
-
setLifecycleManager
-
getAttachmentSpecType
Identify the type of message (MTOM or SOAP with attachments) represented by this object.- Returns:
- One of the
MTOMConstants.MTOM_TYPE,MTOMConstants.SWA_TYPEorMTOMConstants.SWA_TYPE_12constants. - Throws:
OMException- if the message doesn't have one of the supported types, i.e. is neither MTOM nor SOAP with attachments
-
getDataHandler
Checks whether the MIME part is already parsed by checking the attachments HashMap. If it is not parsed yet then call the getNextPart() till the required part is found.- Specified by:
getDataHandlerin interfaceOMAttachmentAccessor- Parameters:
blobContentID- (without the surrounding angle brackets and "cid:" prefix)- Returns:
- The DataHandler of the mime part referred by the Content-Id or *null* if the mime part referred by the content-id does not exist
-
addDataHandler
Programatically adding an SOAP with Attachments(SwA) Attachment. These attachments will get serialized only if SOAP with Attachments is enabled.- Parameters:
contentID-dataHandler-
-
removeDataHandler
Removes the DataHandler corresponding to the given contenID. If it is not present, then trying to find it calling the getNextPart() till the required part is found.- Parameters:
blobContentID-
-
getSOAPPartInputStream
- Returns:
- the InputStream which includes the SOAP Envelope. It assumes that the root mime part is always pointed by "start" parameter in content-type.
- Throws:
OMException
-
getSOAPPartContentID
- Returns:
- the Content-ID of the SOAP part It'll be the value Start Parameter of Content-Type header if given in the Content type of the MIME message. Else it'll be the content-id of the first MIME part of the MIME message
-
getSOAPPartContentType
-
getIncomingAttachmentStreams
Stream based access- Returns:
- The stream container of type
IncomingAttachmentStreams - Throws:
IllegalStateException- if application has alreadt started using Part's directly
-
getAllContentIDs
Get the content IDs of all MIME parts in the message. This includes the content ID of the SOAP part as well as the content IDs of the attachments. Note that if this object has been created from a stream, a call to this method will force reading of all MIME parts that have not been fetched from the stream yet.- Returns:
- an array with the content IDs in order of appearance in the message
-
getContentIDSet
Get the content IDs of all MIME parts in the message. This includes the content ID of the SOAP part as well as the content IDs of the attachments. Note that if this object has been created from a stream, a call to this method will force reading of all MIME parts that have not been fetched from the stream yet.- Returns:
- the set of content IDs
-
getMap
Get a map of all MIME parts in the message. This includes the SOAP part as well as the attachments. Note that if this object has been created from a stream, a call to this method will force reading of all MIME parts that have not been fetched from the stream yet.- Returns:
- A map of all MIME parts in the message, with content IDs as keys and
DataHandlerobjects as values.
-
getContentIDList
Get the content IDs of the already loaded MIME parts in the message. This includes the content ID of the SOAP part as well as the content IDs of the attachments. If this object has been created from a stream, only the content IDs of the MIME parts that have already been fetched from the stream are returned. If this is not the desired behavior,getAllContentIDs()orgetContentIDSet()should be used instead.- Returns:
- List of content IDs in order of appearance in message
-
getHeaders
Get the headers of the already loaded MIME parts in the message.- Returns:
- Map of MIME headers of the message
-
setHeaders
Set the headers of the MIME parts in the message.- Parameters:
headers- Map of MIME headers
-
getContentLength
If the Attachments is backed by an InputStream, then this method returns the length of the message contents (Length of the entire message - Length of the Transport Headers)- Returns:
- length of message content or -1 if Attachments is not backed by an InputStream
- Throws:
IOException
-
setEndOfStream
protected void setEndOfStream(boolean value) endOfStreamReached will be set to true if the message ended in MIME Style having "--" suffix with the last mime boundary- Parameters:
value-
-
getIncomingAttachmentsAsSingleStream
Returns the rest of mime stream. It will contain all attachments without soappart (first attachment) with headers and mime boundary. Raw content!- Throws:
IllegalStateException
-