org.apache.axiom.attachments
Class Attachments

java.lang.Object
  extended by org.apache.axiom.attachments.Attachments
All Implemented Interfaces:
OMAttachmentAccessor

public class Attachments
extends java.lang.Object
implements OMAttachmentAccessor


Field Summary
protected static org.apache.commons.logging.Log log
           
 
Constructor Summary
Attachments()
          Use this constructor when instantiating this to store the attachments set programatically through the SwA API.
Attachments(java.io.InputStream inStream, java.lang.String contentTypeString)
          Sets file cache to false.
Attachments(java.io.InputStream inStream, java.lang.String contentTypeString, boolean fileCacheEnable, java.lang.String attachmentRepoDir, java.lang.String fileThreshold)
          Moves the pointer to the beginning of the first MIME part.
Attachments(java.io.InputStream inStream, java.lang.String contentTypeString, boolean fileCacheEnable, java.lang.String attachmentRepoDir, java.lang.String fileThreshold, int contentLength)
          Moves the pointer to the beginning of the first MIME part.
Attachments(LifecycleManager manager, java.io.InputStream inStream, java.lang.String contentTypeString, boolean fileCacheEnable, java.lang.String attachmentRepoDir, java.lang.String fileThreshold)
          Moves the pointer to the beginning of the first MIME part.
Attachments(LifecycleManager manager, java.io.InputStream inStream, java.lang.String contentTypeString, boolean fileCacheEnable, java.lang.String attachmentRepoDir, java.lang.String fileThreshold, int contentLength)
          Moves the pointer to the beginning of the first MIME part.
 
Method Summary
 void addDataHandler(java.lang.String contentID, javax.activation.DataHandler dataHandler)
          Programatically adding an SOAP with Attachments(SwA) Attachment.
 java.lang.String[] getAllContentIDs()
           
 java.lang.String getAttachmentSpecType()
           
 java.util.List getContentIDList()
           
 java.util.Set getContentIDSet()
           
 long 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)
 javax.activation.DataHandler getDataHandler(java.lang.String blobContentID)
          Checks whether the MIME part is already parsed by checking the attachments HashMap.
 java.io.InputStream getIncomingAttachmentsAsSingleStream()
          Returns the rest of mime stream.
 IncomingAttachmentStreams getIncomingAttachmentStreams()
          Stream based access
 LifecycleManager getLifecycleManager()
           
 java.util.Map getMap()
           
 java.lang.String getSOAPPartContentID()
           
 java.lang.String getSOAPPartContentType()
           
 java.io.InputStream getSOAPPartInputStream()
           
 void removeDataHandler(java.lang.String blobContentID)
          Removes the DataHandler corresponding to the given contenID.
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
 void setLifecycleManager(LifecycleManager manager)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
Constructor Detail

Attachments

public Attachments(LifecycleManager manager,
                   java.io.InputStream inStream,
                   java.lang.String contentTypeString,
                   boolean fileCacheEnable,
                   java.lang.String attachmentRepoDir,
                   java.lang.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,
                   java.io.InputStream inStream,
                   java.lang.String contentTypeString,
                   boolean fileCacheEnable,
                   java.lang.String attachmentRepoDir,
                   java.lang.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(java.io.InputStream inStream,
                   java.lang.String contentTypeString,
                   boolean fileCacheEnable,
                   java.lang.String attachmentRepoDir,
                   java.lang.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(java.io.InputStream inStream,
                   java.lang.String contentTypeString,
                   boolean fileCacheEnable,
                   java.lang.String attachmentRepoDir,
                   java.lang.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(java.io.InputStream inStream,
                   java.lang.String contentTypeString)
            throws OMException
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 Detail

getLifecycleManager

public LifecycleManager getLifecycleManager()

setLifecycleManager

public void setLifecycleManager(LifecycleManager manager)

getAttachmentSpecType

public java.lang.String getAttachmentSpecType()
Returns:
whether Message Type is SOAP with Attachments or MTOM optimized, by checking the application type parameter in the Content Type.

getDataHandler

public javax.activation.DataHandler getDataHandler(java.lang.String blobContentID)
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:
getDataHandler in interface OMAttachmentAccessor
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

public void addDataHandler(java.lang.String contentID,
                           javax.activation.DataHandler dataHandler)
Programatically adding an SOAP with Attachments(SwA) Attachment. These attachments will get serialized only if SOAP with Attachments is enabled.

Parameters:
contentID -
dataHandler -

removeDataHandler

public void removeDataHandler(java.lang.String blobContentID)
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

public java.io.InputStream getSOAPPartInputStream()
                                           throws OMException
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

public java.lang.String 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

public java.lang.String getSOAPPartContentType()

getIncomingAttachmentStreams

public IncomingAttachmentStreams getIncomingAttachmentStreams()
                                                       throws java.lang.IllegalStateException
Stream based access

Returns:
The stream container of type IncomingAttachmentStreams
Throws:
java.lang.IllegalStateException - if application has alreadt started using Part's directly

getAllContentIDs

public java.lang.String[] getAllContentIDs()

getContentIDSet

public java.util.Set getContentIDSet()

getMap

public java.util.Map getMap()

getContentIDList

public java.util.List getContentIDList()
Returns:
List of content ids in order of appearance in message

getContentLength

public long getContentLength()
                      throws java.io.IOException
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:
java.io.IOException
See Also:
getMessageLength

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

public java.io.InputStream getIncomingAttachmentsAsSingleStream()
                                                         throws java.lang.IllegalStateException
Returns the rest of mime stream. It will contain all attachments without soappart (first attachment) with headers and mime boundary. Raw content!

Throws:
java.lang.IllegalStateException


Copyright © 2004-2009 The Apache Software Foundation. All Rights Reserved.