Class Attachments

    • Field Detail

      • log

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

      • 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

        public Attachments()
        Use this constructor when instantiating this to store the attachments set programatically through the SwA API.
    • Method Detail

      • setLifecycleManager

        public void setLifecycleManager​(LifecycleManager manager)
      • getDataHandler

        public DataHandler getDataHandler​(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​(String contentID,
                                   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​(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 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 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 String getSOAPPartContentType()
      • getAllContentIDs

        public String[] 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

        public Set 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

        public Map 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 DataHandler objects as values.
      • getContentIDList

        public List 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() or getContentIDSet() should be used instead.
        Returns:
        List of content IDs in order of appearance in message
      • getHeaders

        public Map getHeaders()
        Get the headers of the already loaded MIME parts in the message.
        Returns:
        Map of MIME headers of the message
      • setHeaders

        public void setHeaders​(Map headers)
        Set the headers of the MIME parts in the message.
        Parameters:
        headers - Map of MIME headers
      • getContentLength

        public long getContentLength()
                              throws 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:
        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

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