You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by sc...@apache.org on 2007/09/13 22:15:01 UTC

svn commit: r575430 - /webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/Attachments.java

Author: scheu
Date: Thu Sep 13 13:15:01 2007
New Revision: 575430

URL: http://svn.apache.org/viewvc?rev=575430&view=rev
Log:
WSCOMMONS-246 WSCOMMONS-250
Contributor:Michal Stochmialek
Always keep the first part in memory (it is probably the SOAP Part)
Expose a method to get all of the attachments in a single stream

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/Attachments.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/Attachments.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/Attachments.java?rev=575430&r1=575429&r2=575430&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/Attachments.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/attachments/Attachments.java Thu Sep 13 13:15:01 2007
@@ -312,13 +312,12 @@
      * @param blobContentID
      */
     public void removeDataHandler(String blobContentID) {
-        DataHandler dataHandler;
         if (attachmentsMap.containsKey(blobContentID)) {
             attachmentsMap.remove(blobContentID);
         } else if (!noStreams) {
             //This loop will be terminated by the Exceptions thrown if the Mime
             // part searching was not found
-            while ((dataHandler = this.getNextPartDataHandler()) != null) {
+            while (this.getNextPartDataHandler() != null) {
                 if (attachmentsMap.containsKey(blobContentID)) {
                     attachmentsMap.remove(blobContentID);
                 }
@@ -459,6 +458,26 @@
     }
 
     /**
+     * Returns the rest of mime stream. It will contain all attachments without
+     * soappart (first attachment) with headers and mime boundary. Raw content! 
+     */
+    public InputStream getIncomingAttachmentsAsSingleStream() throws IllegalStateException {
+        if (partsRequested) {
+            throw new IllegalStateException(
+                    "The attachments stream can only be accessed once; either by using the IncomingAttachmentStreams class or by getting a " +
+                            "collection of AttachmentPart objects. They cannot both be called within the life time of the same service request.");
+        }
+        if (noStreams) {
+            throw new IllegalStateException(
+                    "The attachments map was created programatically. No streams are available.");
+        }
+
+        streamsRequested = true;
+
+    	return this.pushbackInStream;
+    }
+
+    /**
      * @return the Next valid MIME part + store the Part in the Parts List
      * @throws OMException throw if content id is null or if two MIME parts contain the same
      *                     content-ID & the exceptions throws by getPart()
@@ -534,8 +553,10 @@
         try {
             if (fileCacheEnable) {
                 try {
-                    if (contentLength != 0 &&
-                            contentLength <= fileStorageThreshold) {
+                    // The soapPart is normally the first part, 
+                    // so always keep the first part in memory
+                    if ((contentLength != 0 && contentLength <= fileStorageThreshold) ||
+                         partIndex == 0) {  
                         // Since the content-length is less than the threshold, we can safely 
                         // store it in memory.
                         if (log.isDebugEnabled()) {



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org