cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r924315 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Wed, 17 Mar 2010 14:43:58 GMT
Author: sergeyb
Date: Wed Mar 17 14:43:58 2010
New Revision: 924315

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

........
  r924306 | sergeyb | 2010-03-17 14:35:31 +0000 (Wed, 17 Mar 2010) | 1 line
  
  CXF-2717: support for base64 and quoted-printable part encodings
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:924306

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

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java?rev=924315&r1=924314&r2=924315&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
Wed Mar 17 14:43:58 2010
@@ -35,6 +35,7 @@ import java.util.logging.Logger;
 
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
+import javax.mail.internet.MimeUtility;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.Produces;
 import javax.ws.rs.WebApplicationException;
@@ -165,13 +166,27 @@ public class MultipartProvider extends A
             MessageBodyReader<Object> r = 
                 mc.getProviders().getMessageBodyReader((Class)c, t, anns, multipart.getContentType());
             if (r != null) {
+                InputStream is = multipart.getDataHandler().getInputStream();
+                is = decodeIfNeeded(multipart, is);
                 return r.readFrom((Class)c, t, anns, multipart.getContentType(), multipart.getHeaders(),

-                                  multipart.getDataHandler().getInputStream());
+                                  is);
             }
         }
         return null;
     }
     
+    private InputStream decodeIfNeeded(Attachment multipart, InputStream is) {
+        String value = multipart.getHeader("Content-Transfer-Encoding");
+        if ("base64".equals(value) || "quoted-printable".equals(value)) {
+            try {
+                is = MimeUtility.decode(is, value);
+            } catch (Exception ex) {
+                LOG.warning("Problem with decoding an input stream, encoding : " + value);
+            }
+        }
+        return is;
+    }
+    
     private boolean mediaTypeSupported(MediaType mt) {
         return mt.getType().equals("multipart") && (mt.getSubtype().equals("related")

             || mt.getSubtype().equals("mixed") || mt.getSubtype().equals("alternative"));

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java?rev=924315&r1=924314&r2=924315&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
Wed Mar 17 14:43:58 2010
@@ -107,6 +107,12 @@ public class JAXRSMultipartTest extends 
     }
     
     @Test
+    public void testBookJSONJAXBFormEncoded() throws Exception {
+        String address = "http://localhost:9085/bookstore/books/jsonjaxbform";
+        doAddFormBook(address, "attachmentFormJsonJaxbEncoded", 200);
+    }
+    
+    @Test
     public void testBookJSONFormFiles() throws Exception {
         String address = "http://localhost:9085/bookstore/books/filesform";
         doAddFormBook(address, "attachmentFormJsonFiles", 200);               

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java?rev=924315&r1=924314&r2=924315&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java
Wed Mar 17 14:43:58 2010
@@ -282,6 +282,16 @@ public class MultipartStore {
         return Response.ok(b2).build();
     }
     
+    @POST
+    @Path("/books/jsonjaxbformencoded")
+    @Produces("text/xml")
+    @Consumes("multipart/form-data")
+    public Response addBookJaxbJsonFormEncoded(@Multipart("jsonPart") Book b1, 
+                                        @Multipart("bookXML") Book b2) 
+        throws Exception {
+        return addBookJaxbJsonForm(b1, b2);
+    }
+    
     
     @POST
     @Path("/books/dsource2")



Mime
View raw message