cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r923743 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Tue, 16 Mar 2010 13:58:54 GMT
Author: sergeyb
Date: Tue Mar 16 13:58:53 2010
New Revision: 923743

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

........
  r923741 | sergeyb | 2010-03-16 13:46:14 +0000 (Tue, 16 Mar 2010) | 1 line
  
  CXF-2717: fix for primitive(string) multipart/form-data values be decoded by default
........

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/PrimitiveTextProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.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:923741

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/PrimitiveTextProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java?rev=923743&r1=923742&r2=923743&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
Tue Mar 16 13:58:53 2010
@@ -24,6 +24,7 @@ import java.io.OutputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 
+import javax.ws.rs.Encoded;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.MessageBodyReader;
@@ -31,6 +32,7 @@ import javax.ws.rs.ext.MessageBodyWriter
 
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.jaxrs.model.ParameterType;
+import org.apache.cxf.jaxrs.utils.AnnotationUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 
 public class PrimitiveTextProvider 
@@ -46,10 +48,18 @@ public class PrimitiveTextProvider 
 
     public Object readFrom(Class<Object> type, Type genType, Annotation[] anns, MediaType
mt, 
                            MultivaluedMap<String, String> headers, InputStream is)
throws IOException {
+        
+        String value = IOUtils.readStringFromStream(is);
+        if (type.isAssignableFrom(String.class)) {
+            value = InjectionUtils.decodeValue(value, 
+                              AnnotationUtils.getAnnotation(anns, Encoded.class) == null,
+                              ParameterType.REQUEST_BODY);
+        }
         return InjectionUtils.handleParameter(
-                    IOUtils.readStringFromStream(is).toString(), 
+                    value, 
                     type,
                     ParameterType.REQUEST_BODY, null);
+        
     }
 
     public long getSize(Object t, Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=923743&r1=923742&r2=923743&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
Tue Mar 16 13:58:53 2010
@@ -879,7 +879,7 @@ public final class InjectionUtils {
             || String.class == type;
     }
     
-    private static String decodeValue(String value, boolean decode, ParameterType param)
{
+    public static String decodeValue(String value, boolean decode, ParameterType param) {
         if (!decode) {
             return value;
         }

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=923743&r1=923742&r2=923743&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
Tue Mar 16 13:58:53 2010
@@ -155,6 +155,12 @@ public class JAXRSMultipartTest extends 
     }
     
     @Test
+    public void testAddBookFormParam2() throws Exception {
+        String address = "http://localhost:9085/bookstore/books/formparam2";
+        doAddBook("multipart/form-data", address, "attachmentForm", 200);               
+    }
+    
+    @Test
     public void testAddBookFormBody() throws Exception {
         String address = "http://localhost:9085/bookstore/books/formbody";
         doAddBook("multipart/form-data", address, "attachmentForm", 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=923743&r1=923742&r2=923743&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
Tue Mar 16 13:58:53 2010
@@ -152,6 +152,9 @@ public class MultipartStore {
     @Produces("text/xml")
     public Response addBookFromFormParam(@FormParam("name") String title, 
                                          @FormParam("id") Long id) throws Exception {
+        if (!"CXF in Action - 2".equals(title)) {
+            throw new RuntimeException();
+        }
         Book b = new Book();
         b.setId(id);
         b.setName(title);
@@ -159,9 +162,17 @@ public class MultipartStore {
     }
     
     @POST
+    @Path("/books/formparam2")
+    @Produces("text/xml")
+    public Response addBookFromFormParam2(@Multipart("name") String title, 
+                                          @Multipart("id") Long id) throws Exception {
+        return addBookFromFormParam(title, id);
+    }
+    
+    @POST
     @Path("/books/formparambean")
     @Produces("text/xml")
-    public Response addBookFromFormParam(@FormParam("") Book b) throws Exception {
+    public Response addBookFromFormBean(@FormParam("") Book b) throws Exception {
         return Response.ok(b).build();
     }
     



Mime
View raw message