cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r630004 - in /incubator/cxf/branches/2.0.x-fixes: ./ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java
Date Thu, 21 Feb 2008 21:30:57 GMT
Author: dkulp
Date: Thu Feb 21 13:30:56 2008
New Revision: 630004

URL: http://svn.apache.org/viewvc?rev=630004&view=rev
Log:
Merged revisions 629997 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/cxf/trunk

........
  r629997 | dkulp | 2008-02-21 16:13:57 -0500 (Thu, 21 Feb 2008) | 2 lines
  
  [CXF-1269] If file DataContent, get the size directly
........

Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java

Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java?rev=630004&r1=630003&r2=630004&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java
Thu Feb 21 13:30:56 2008
@@ -19,12 +19,15 @@
 
 package org.apache.cxf.jaxb.attachment;
 
+import java.io.File;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.util.Collection;
 import java.util.UUID;
 
 import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.activation.FileDataSource;
 import javax.xml.bind.attachment.AttachmentMarshaller;
 
 import org.apache.cxf.attachment.AttachmentImpl;
@@ -82,19 +85,27 @@
             return null;
         }        
 
-        if ("application/octet-stream".equals(handler.getContentType())) {
-            try {
+        // The following is just wrong. Even if the DataHandler has a stream, we should still
+        // apply the threshold.
+        try {
+            DataSource ds = handler.getDataSource();
+            if (ds instanceof FileDataSource) {
+                FileDataSource fds = (FileDataSource)ds;
+                File file = fds.getFile();
+                if (file.length() < THRESHOLD) {
+                    return null;
+                }
+            } else if (ds.getClass().getName().endsWith("ObjectDataSource")) {
                 Object o = handler.getContent();
                 if (o instanceof String 
                     && ((String)o).length() < THRESHOLD) {
                     return null;
-                } else if (o instanceof byte[]
-                            && ((byte[])o).length < THRESHOLD) {
+                } else if (o instanceof byte[] && ((byte[])o).length < THRESHOLD)
{
                     return null;
                 }
-            } catch (IOException e1) {
-                //ignore, just do the normal attachment thing
             }
+        } catch (IOException e1) {
+            //ignore, just do the normal attachment thing
         }
         
         String id;



Mime
View raw message