cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r573070 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/interceptor/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/
Date Wed, 05 Sep 2007 21:28:57 GMT
Author: dkulp
Date: Wed Sep  5 14:28:56 2007
New Revision: 573070

URL: http://svn.apache.org/viewvc?rev=573070&view=rev
Log:
Some MTOM updates so mime-typed data gets properly attached, check for sizes, etc..


Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/Fault.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/Fault.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/Fault.java?rev=573070&r1=573069&r2=573070&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/Fault.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/Fault.java Wed Sep  5
14:28:56 2007
@@ -21,7 +21,6 @@
 
 import javax.xml.namespace.QName;
 
-import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 import org.apache.cxf.common.i18n.Message;
@@ -132,9 +131,7 @@
 
     public Element getOrCreateDetail() {
         if (detail == null) {
-            Document d = DOMUtils.createDocument();
-            Element element = d.createElement("Fault");
-            this.detail = element;
+            detail = DOMUtils.createDocument().createElement("detail");
         }
         return detail;
     }

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java?rev=573070&r1=573069&r2=573070&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
Wed Sep  5 14:28:56 2007
@@ -93,6 +93,8 @@
                 // do nothing
             }
         }
+        //must turn off mtom when using SAAJ so binary is properly inlined
+        message.put(org.apache.cxf.message.Message.MTOM_ENABLED, false);
         
         // Add a final interceptor to write the message
         message.getInterceptorChain().add(new SAAJOutEndingInterceptor());

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java?rev=573070&r1=573069&r2=573070&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java
Wed Sep  5 14:28:56 2007
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.jaxb.attachment;
 
+import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.util.Collection;
 import java.util.UUID;
@@ -34,7 +35,7 @@
 
 public class JAXBAttachmentMarshaller extends AttachmentMarshaller {
 
-    private static final int THRESH_HOLD = 10 * 1024;
+    private static final int THRESH_HOLD = 5 * 1024;
     private Collection<Attachment> atts;
     private boolean isXop;
 
@@ -48,15 +49,18 @@
     public String addMtomAttachment(byte[] data, int offset, int length, String mimeType,
String elementNS,
                                     String elementLocalName) {
         
-        if (!isXop && length < THRESH_HOLD) {
+        if (!isXop) {
             return null;
         }        
-        ByteDataSource source = new ByteDataSource(data, offset, length);
-        if (mimeType != null) {
-            source.setContentType(mimeType);
-        } else {
-            source.setContentType("application/octet-stream");
+        if (mimeType == null) {
+            mimeType = "application/octet-stream";
+        }
+        if ("application/octet-stream".equals(mimeType)
+            && length < THRESH_HOLD) {
+            return null;
         }
+        ByteDataSource source = new ByteDataSource(data, offset, length);
+        source.setContentType(mimeType);
         DataHandler handler = new DataHandler(source);
 
         String id;
@@ -77,6 +81,21 @@
         if (!isXop) {
             return null;
         }        
+
+        if ("application/octet-stream".equals(handler.getContentType())) {
+            try {
+                Object o = handler.getContent();
+                if (o instanceof String 
+                    && ((String)o).length() < THRESH_HOLD) {
+                    return null;
+                } else if (o instanceof byte[]
+                            && ((byte[])o).length < THRESH_HOLD) {
+                    return null;
+                }
+            } catch (IOException e1) {
+                //ignore, just do the normal attachment thing
+            }
+        }
         
         String id;
         try {



Mime
View raw message