Author: dims
Date: Wed Apr 19 22:32:14 2006
New Revision: 395491

URL: http://svn.apache.org/viewcvs?rev=395491&view=rev
Log:
voila! we have an Class/API for accessing the attachments :)

Added:
    
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/attachments/Attachments.java
      - copied, changed from r395364, 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/attachments/MIMEHelper.java
Removed:
    
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/attachments/MIMEHelper.java
Modified:
    
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/attachments/MIMEBodyPartInputStream.java
    
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilder.java
    
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/ImageSampleTest.java
    
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/IncomingAttachmentInputTest.java
    
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/MIMEHelperTest.java
    
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/PartOnFileTest.java
    
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java

Copied: 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/attachments/Attachments.java
 (from r395364, 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/attachments/MIMEHelper.java)
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/attachments/Attachments.java?p2=webservices/commons/trunk/modules/axiom/src/org/apache/axiom/attachments/Attachments.java&p1=webservices/commons/trunk/modules/axiom/src/org/apache/axiom/attachments/MIMEHelper.java&r1=395364&r2=395491&rev=395491&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/attachments/MIMEHelper.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/attachments/Attachments.java
 Wed Apr 19 22:32:14 2006
@@ -33,7 +33,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-public class MIMEHelper {
+public class Attachments {
 
     /**
      * <code>ContentType</code> of the MIME message
@@ -106,9 +106,9 @@
      * @param attachmentRepoDir
      * @throws OMException
      */
-    public MIMEHelper(InputStream inStream, String contentTypeString,
-                      boolean fileCacheEnable, String attachmentRepoDir,
-                      String fileThreshold) throws OMException {
+    public Attachments(InputStream inStream, String contentTypeString,
+                       boolean fileCacheEnable, String attachmentRepoDir,
+                       String fileThreshold) throws OMException {
         this.attachmentRepoDir = attachmentRepoDir;
         this.fileCacheEnable = fileCacheEnable;
         if (fileThreshold != null && (!"".equals(fileThreshold))) {
@@ -178,7 +178,7 @@
      * @param contentTypeString
      * @throws OMException
      */
-    public MIMEHelper(InputStream inStream, String contentTypeString)
+    public Attachments(InputStream inStream, String contentTypeString)
             throws OMException {
         this(inStream, contentTypeString, false, null, null);
     }

Modified: 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/attachments/MIMEBodyPartInputStream.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/attachments/MIMEBodyPartInputStream.java?rev=395491&r1=395490&r2=395491&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/attachments/MIMEBodyPartInputStream.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/attachments/MIMEBodyPartInputStream.java
 Wed Apr 19 22:32:14 2006
@@ -25,7 +25,7 @@
 
     boolean boundaryFound;
 
-    MIMEHelper parent;
+    Attachments parent;
 
     byte[] boundary;
 
@@ -36,7 +36,7 @@
     }
 
     public MIMEBodyPartInputStream(PushbackInputStream inStream,
-            byte[] boundary, MIMEHelper parent) {
+            byte[] boundary, Attachments parent) {
         this(inStream, boundary);
         this.parent = parent;
     }

Modified: 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilder.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilder.java?rev=395491&r1=395490&r2=395491&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilder.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilder.java
 Wed Apr 19 22:32:14 2006
@@ -16,7 +16,7 @@
 
 package org.apache.axiom.om.impl.mtom;
 
-import org.apache.axiom.attachments.MIMEHelper;
+import org.apache.axiom.attachments.Attachments;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNode;
@@ -34,28 +34,28 @@
 public class MTOMStAXSOAPModelBuilder extends StAXSOAPModelBuilder implements 
MTOMConstants {
        
     /**
-     * <code>mimeHelper</code> handles deferred parsing of incoming MIME
+     * <code>Attachments</code> handles deferred parsing of incoming MIME
      * Messages.
      */
-    MIMEHelper mimeHelper;
+    Attachments attachments;
 
     int partIndex = 0;
 
     public MTOMStAXSOAPModelBuilder(XMLStreamReader parser,
                                     SOAPFactory factory,
-                                    MIMEHelper mimeHelper, String soapVersion) 
{
+                                    Attachments attachments, String 
soapVersion) {
         super(parser, factory, soapVersion);
-        this.mimeHelper = mimeHelper;
+        this.attachments = attachments;
     }
 
     /**
      * @param reader
-     * @param mimeHelper
+     * @param attachments
      */
     public MTOMStAXSOAPModelBuilder(XMLStreamReader reader,
-                                    MIMEHelper mimeHelper, String soapVersion) 
{
+                                    Attachments attachments, String 
soapVersion) {
         super(reader, soapVersion);
-        this.mimeHelper = mimeHelper;
+        this.attachments = attachments;
     }
 
     protected OMNode createOMElement() throws OMException {
@@ -148,6 +148,6 @@
     }
 
     public DataHandler getDataHandler(String blobContentID) throws OMException 
{
-        return mimeHelper.getDataHandler(blobContentID);
+        return attachments.getDataHandler(blobContentID);
     }
 }

Modified: 
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/ImageSampleTest.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/ImageSampleTest.java?rev=395491&r1=395490&r2=395491&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/ImageSampleTest.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/ImageSampleTest.java
 Wed Apr 19 22:32:14 2006
@@ -112,14 +112,14 @@
     public void testImageSampleDeserialize() throws Exception {
         InputStream inStream = new FileInputStream(
                 getTestResourceFile(inMimeFileName));
-        MIMEHelper mimeHelper = new MIMEHelper(inStream, contentTypeString);
+        Attachments attachments = new Attachments(inStream, contentTypeString);
         XMLStreamReader reader = XMLInputFactory.newInstance()
                 .createXMLStreamReader(
                         new BufferedReader(
                                 new InputStreamReader(
-                                        mimeHelper
+                                        attachments
                 .getSOAPPartInputStream())));
-        builder = new MTOMStAXSOAPModelBuilder(reader, mimeHelper, null);
+        builder = new MTOMStAXSOAPModelBuilder(reader, attachments, null);
         OMElement root = builder.getDocumentElement();
         OMElement body = (OMElement) root.getFirstOMChild();
         OMElement data = (OMElement) body.getFirstOMChild();

Modified: 
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/IncomingAttachmentInputTest.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/IncomingAttachmentInputTest.java?rev=395491&r1=395490&r2=395491&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/IncomingAttachmentInputTest.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/IncomingAttachmentInputTest.java
 Wed Apr 19 22:32:14 2006
@@ -39,10 +39,10 @@
 
        public void testIncomingAttachmentInputStreamFunctions() throws 
Exception {
         InputStream inStream = new 
FileInputStream(getTestResourceFile(inMimeFileName));
-        MIMEHelper mimeHelper = new MIMEHelper(inStream, contentTypeString);
+        Attachments attachments = new Attachments(inStream, contentTypeString);
 
         // Get the inputstream container
-        IncomingAttachmentStreams ias = 
mimeHelper.getIncomingAttachmentStreams();
+        IncomingAttachmentStreams ias = 
attachments.getIncomingAttachmentStreams();
         
         IncomingAttachmentInputStream dataIs;
 

Modified: 
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/MIMEHelperTest.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/MIMEHelperTest.java?rev=395491&r1=395490&r2=395491&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/MIMEHelperTest.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/MIMEHelperTest.java
 Wed Apr 19 22:32:14 2006
@@ -48,16 +48,16 @@
 
     public void testSimultaneousStreamAccess() throws Exception {
         InputStream inStream;
-        MIMEHelper mimeHelper;
+        Attachments attachments;
 
         inStream = new FileInputStream(getTestResourceFile(inMimeFileName));
-        mimeHelper = new MIMEHelper(inStream, contentTypeString);
+        attachments = new Attachments(inStream, contentTypeString);
 
-        mimeHelper.getDataHandler("2.urn:uuid:[EMAIL PROTECTED]");
+        attachments.getDataHandler("2.urn:uuid:[EMAIL PROTECTED]");
 
         // This should throw an error
         try {
-               mimeHelper.getIncomingAttachmentStreams();
+               attachments.getIncomingAttachmentStreams();
                fail("No exception caught when attempting to access datahandler 
and stream at the same time");
         } catch (IllegalStateException ise) {
                // Nothing
@@ -67,27 +67,27 @@
 
         // Try the other way around.
         inStream = new FileInputStream(getTestResourceFile(inMimeFileName));
-        mimeHelper = new MIMEHelper(inStream, contentTypeString);
+        attachments = new Attachments(inStream, contentTypeString);
 
-        mimeHelper.getIncomingAttachmentStreams();
+        attachments.getIncomingAttachmentStreams();
 
         // These should NOT throw error even though they are using part based 
access
         try {
-            assertEquals("application/xop+xml; charset=UTF-8; 
type=\"application/soap+xml\";", mimeHelper.getSOAPPartContentType());
+            assertEquals("application/xop+xml; charset=UTF-8; 
type=\"application/soap+xml\";", attachments.getSOAPPartContentType());
         } catch (IllegalStateException ise) {
                fail("No exception expected when requesting SOAP part data");
                ise.printStackTrace();
         }
 
         try {
-            mimeHelper.getSOAPPartInputStream();
+            attachments.getSOAPPartInputStream();
         } catch (IllegalStateException ise) {
                fail("No exception expected when requesting SOAP part data");
         }
 
         // These should throw an error
         try {
-            mimeHelper.getDataHandler("2.urn:uuid:[EMAIL PROTECTED]");
+            attachments.getDataHandler("2.urn:uuid:[EMAIL PROTECTED]");
                fail("No exception caught when attempting to access stream and 
datahandler at the same time");
         } catch (IllegalStateException ise) {
                // Nothing
@@ -97,14 +97,14 @@
         // tries to access part data directly
 
         try {
-            mimeHelper.getAllContentIDs();
+            attachments.getAllContentIDs();
                fail("No exception caught when attempting to access stream and 
contentids list at the same time");
         } catch (IllegalStateException ise) {
                // Nothing
         }
 
         try {
-            mimeHelper.getPart("2.urn:uuid:[EMAIL PROTECTED]");
+            attachments.getPart("2.urn:uuid:[EMAIL PROTECTED]");
                fail("No exception caught when attempting to access stream and 
part at the same time");
         } catch (IllegalStateException ise) {
                // Nothing
@@ -119,16 +119,16 @@
         InputStream expectedDataIs;
 
         InputStream inStream = new 
FileInputStream(getTestResourceFile(inMimeFileName));
-        MIMEHelper mimeHelper = new MIMEHelper(inStream, contentTypeString);
+        Attachments attachments = new Attachments(inStream, contentTypeString);
 
         // Since SOAP part operated independently of other streams, access it
         // directly, and then get to the streams. If this sequence throws an
         // error, something is wrong with the stream handling code.
-        InputStream is = mimeHelper.getSOAPPartInputStream();
+        InputStream is = attachments.getSOAPPartInputStream();
         while (is.read() != -1);
 
         // Get the inputstream container
-        IncomingAttachmentStreams ias = 
mimeHelper.getIncomingAttachmentStreams();
+        IncomingAttachmentStreams ias = 
attachments.getIncomingAttachmentStreams();
 
         dataIs = ias.getNextStream();
         expectedImage = ImageIO.read(new 
FileInputStream(getTestResourceFile(img1FileName)));
@@ -147,7 +147,7 @@
 
         // After all is done, we should *still* be able to access and
         // re-consume the SOAP part stream, as it should be cached.. can we?
-        is = mimeHelper.getSOAPPartInputStream();
+        is = attachments.getSOAPPartInputStream();
         while (is.read() != -1);
     }
 
@@ -164,9 +164,9 @@
     public void testGetDataHandler() throws Exception {
 
         InputStream inStream = new 
FileInputStream(getTestResourceFile(inMimeFileName));
-        MIMEHelper mimeHelper = new MIMEHelper(inStream, contentTypeString);
+        Attachments attachments = new Attachments(inStream, contentTypeString);
 
-        DataHandler dh = mimeHelper.getDataHandler("2.urn:uuid:[EMAIL 
PROTECTED]");
+        DataHandler dh = attachments.getDataHandler("2.urn:uuid:[EMAIL 
PROTECTED]");
         InputStream dataIs = dh.getDataSource().getInputStream();
 
         Image expectedImage = ImageIO.read(new 
FileInputStream(getTestResourceFile(img2FileName)));

Modified: 
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/PartOnFileTest.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/PartOnFileTest.java?rev=395491&r1=395490&r2=395491&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/PartOnFileTest.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/attachments/PartOnFileTest.java
 Wed Apr 19 22:32:14 2006
@@ -52,9 +52,9 @@
        public void testHeaderGetSet() throws Exception {
 
         InputStream inStream = new 
FileInputStream(getTestResourceFile(inMimeFileName));
-               MIMEHelper mimeHelper = new MIMEHelper(inStream, 
contentTypeString, true, temp.getPath(), "1");
+               Attachments attachments = new Attachments(inStream, 
contentTypeString, true, temp.getPath(), "1");
 
-               Part p = mimeHelper.getPart("1.urn:uuid:[EMAIL PROTECTED]");
+               Part p = attachments.getPart("1.urn:uuid:[EMAIL PROTECTED]");
                
                if (!(p instanceof PartOnFile)) {
                        fail("Expected PartOnFile");
@@ -70,9 +70,9 @@
        public void testGetAllheaders() throws Exception {
 
         InputStream inStream = new 
FileInputStream(getTestResourceFile(inMimeFileName));
-               MIMEHelper mimeHelper = new MIMEHelper(inStream, 
contentTypeString, true, temp.getPath(), "1");
+               Attachments attachments = new Attachments(inStream, 
contentTypeString, true, temp.getPath(), "1");
 
-               Part p = mimeHelper.getPart("1.urn:uuid:[EMAIL PROTECTED]");
+               Part p = attachments.getPart("1.urn:uuid:[EMAIL PROTECTED]");
                
                if (!(p instanceof PartOnFile)) {
                        fail("Expected PartOnFile");

Modified: 
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/test/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java?rev=395491&r1=395490&r2=395491&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/test/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilderTest.java
 Wed Apr 19 22:32:14 2006
@@ -16,7 +16,7 @@
 
 package org.apache.axiom.om.impl.mtom;
 
-import org.apache.axiom.attachments.MIMEHelper;
+import org.apache.axiom.attachments.Attachments;
 import org.apache.axiom.om.AbstractTestCase;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMText;
@@ -33,7 +33,7 @@
 import java.util.Iterator;
 
 public class MTOMStAXSOAPModelBuilderTest extends AbstractTestCase {
-    MIMEHelper mimeHelper;
+    Attachments attachments;
 
     String inFileName;
 
@@ -52,11 +52,11 @@
         super.setUp();
         inFileName = "mtom/MTOMBuilderTestIn.txt";
         InputStream inStream = new 
FileInputStream(getTestResourceFile(inFileName));
-        mimeHelper = new MIMEHelper(inStream, contentTypeString);
+        attachments = new Attachments(inStream, contentTypeString);
         XMLStreamReader reader = XMLInputFactory.newInstance()
-                .createXMLStreamReader(new BufferedReader(new 
InputStreamReader(mimeHelper
+                .createXMLStreamReader(new BufferedReader(new 
InputStreamReader(attachments
                 .getSOAPPartInputStream())));
-        builder = new MTOMStAXSOAPModelBuilder(reader, mimeHelper, 
SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
+        builder = new MTOMStAXSOAPModelBuilder(reader, attachments, 
SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
     }
 
     public void testCreateOMElement() throws Exception {


Reply via email to