axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r733900 - in /webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj: SOAPConnectionImpl.java util/SAAJUtil.java
Date Mon, 12 Jan 2009 21:22:29 GMT
Author: gawor
Date: Mon Jan 12 13:22:25 2009
New Revision: 733900

URL: http://svn.apache.org/viewvc?rev=733900&view=rev
Log:
AttachmentPart and DataHandler content-types might be different so make sure the content-type
of AttachmentPart is used

Modified:
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
    webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/util/SAAJUtil.java

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java?rev=733900&r1=733899&r2=733900&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/SOAPConnectionImpl.java
Mon Jan 12 13:22:25 2009
@@ -20,6 +20,7 @@
 package org.apache.axis2.saaj;
 
 import org.apache.axiom.attachments.Attachments;
+import org.apache.axiom.attachments.ConfigurableDataHandler;
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNode;
@@ -148,7 +149,14 @@
                 if (contentId == null) {
                     contentId = IDGenerator.generateID();
                 }
-                attachments.addDataHandler(contentId, attachment.getDataHandler());
+                DataHandler handler = attachment.getDataHandler();
+                // make sure that AttachmentPart content-type overrides DataHandler content-type
+                if (!SAAJUtil.compareContentTypes(attachment.getContentType(), handler.getContentType()))
{
+                    ConfigurableDataHandler configuredHandler = new ConfigurableDataHandler(handler.getDataSource());
+                    configuredHandler.setContentType(attachment.getContentType());
+                    handler = configuredHandler;
+                }
+                attachments.addDataHandler(contentId, handler);
             }
             options.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE);
         }

Modified: webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/util/SAAJUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/util/SAAJUtil.java?rev=733900&r1=733899&r2=733900&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/util/SAAJUtil.java
(original)
+++ webservices/axis2/trunk/java/modules/saaj/src/org/apache/axis2/saaj/util/SAAJUtil.java
Mon Jan 12 13:22:25 2009
@@ -163,4 +163,10 @@
         int idx = contentType.indexOf(";");
         return (idx == -1 ? contentType : contentType.substring(0, idx)).trim().toLowerCase();
     }
+    
+    public static boolean compareContentTypes(String contentType1, String contentType2) {
+        String ct1 = (contentType1 == null) ? "" : contentType1.trim().toLowerCase();
+        String ct2 = (contentType2 == null) ? "" : contentType2.trim().toLowerCase();
+        return ct1.equals(ct2);        
+    }
 }



Mime
View raw message