cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject svn commit: r463572 - in /incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment: AttachmentDeserializer.java AttachmentSerializer.java JAXBAttachmentMarshaller.java
Date Fri, 13 Oct 2006 06:21:24 GMT
Author: tli
Date: Thu Oct 12 23:21:23 2006
New Revision: 463572

URL: http://svn.apache.org/viewvc?view=rev&rev=463572
Log:
fix the incorrect handling of read mime-boundary to fix '\n--' pattern string problem

Modified:
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/AttachmentDeserializer.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/AttachmentSerializer.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/AttachmentDeserializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/AttachmentDeserializer.java?view=diff&rev=463572&r1=463571&r2=463572
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/AttachmentDeserializer.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/AttachmentDeserializer.java
Thu Oct 12 23:21:23 2006
@@ -267,6 +267,7 @@
         }
 
         public int read() throws IOException {
+            boolean needUnread0d0a = false;
             if (boundaryFound) {
                 return -1;
             }
@@ -288,6 +289,8 @@
                         inStream.unread(value);
                         inStream.unread(10);
                         return 13;
+                    } else {
+                        needUnread0d0a = true;
                     }
                 }
             } else if ((byte) value != boundary[0]) {
@@ -318,8 +321,15 @@
                 // Stream might have ended
                 inStream.unread(value);
             }
-            inStream.unread(boundary, 1, boundaryIndex - 1);
-            return boundary[0];
+            if (needUnread0d0a) {
+                inStream.unread(boundary, 0, boundaryIndex);
+                inStream.unread(10);
+                value = 13;
+            } else {
+                inStream.unread(boundary, 1, boundaryIndex - 1);                
+                value = boundary[0];
+            }
+            return value;
         }
     }
 

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/AttachmentSerializer.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/AttachmentSerializer.java?view=diff&rev=463572&r1=463571&r2=463572
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/AttachmentSerializer.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/AttachmentSerializer.java
Thu Oct 12 23:21:23 2006
@@ -98,11 +98,7 @@
                 Object content = att.getDataHandler().getContent();
                 if (content instanceof InputStream) {
                     InputStream insAtt = (InputStream) content;
-                    if (!att.isXOP()) {
-                        AbstractCachedOutputStream.copyStreamWithBase64Encoding(insAtt, out,
64 * 1024);
-                    } else {
-                        AbstractCachedOutputStream.copyStream(insAtt, out, 64 * 1024);
-                    }
+                    AbstractCachedOutputStream.copyStream(insAtt, out, 64 * 1024);
                 } else {                    
                     ObjectOutputStream oos = new ObjectOutputStream(out);
                     oos.writeObject(content);
@@ -111,7 +107,7 @@
                     out.write(LINE_SEP.getBytes());
                 }
             }
-            out.write(("--" + boundary).getBytes());
+            out.write(("--" + boundary + "--").getBytes());
             out.write(LINE_SEP.getBytes());
             out.flush();            
             // build contentType string for return

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?view=diff&rev=463572&r1=463571&r2=463572
==============================================================================
--- 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
Thu Oct 12 23:21:23 2006
@@ -92,10 +92,10 @@
     }
 
     @Override
-    public String addSwaRefAttachment(DataHandler handler) {
+    public String addSwaRefAttachment(DataHandler handler) {        
         String id = UUID.randomUUID() + "@apache.org";
         AttachmentImpl att = new AttachmentImpl(id, handler);
-        att.setXOP(this.isXop);
+        att.setXOP(false);
         atts.add(att);
         return id;
     }



Mime
View raw message