cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1144979 - in /cxf/branches/2.4.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Sun, 10 Jul 2011 22:13:43 GMT
Author: sergeyb
Date: Sun Jul 10 22:13:43 2011
New Revision: 1144979

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

........
  r1144977 | sergeyb | 2011-07-10 23:08:45 +0100 (Sun, 10 Jul 2011) | 1 line
  
  [CXF-3641] Support for explicit collections of Form params with proxies
........

Modified:
    cxf/branches/2.4.x-fixes/   (props changed)
    cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
    cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java
    cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresourceImpl.java
    cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
    svn:mergeinfo = /cxf/trunk:1144977

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

Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=1144979&r1=1144978&r2=1144979&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
Sun Jul 10 22:13:43 2011
@@ -25,6 +25,8 @@ import java.lang.reflect.InvocationHandl
 import java.lang.reflect.Method;
 import java.net.URI;
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
@@ -388,8 +390,18 @@ public class ClientProxyImpl extends Abs
         
         List<Parameter> fm = getParameters(map, ParameterType.FORM);
         for (Parameter p : fm) {
-            if (params[p.getIndex()] != null) {
-                FormUtils.addPropertyToForm(form, p.getName(), params[p.getIndex()]);
+            Object pValue = params[p.getIndex()];
+            if (pValue != null) {
+                if (InjectionUtils.isSupportedCollectionOrArray(pValue.getClass())) {
+                    Collection<?> c = pValue.getClass().isArray() 
+                        ? Arrays.asList((Object[]) pValue) : (Collection) pValue;
+                    for (Iterator<?> it = c.iterator(); it.hasNext();) {
+                        FormUtils.addPropertyToForm(form, p.getName(), it.next());
+                    }
+                } else { 
+                    FormUtils.addPropertyToForm(form, p.getName(), pValue); 
+                }
+                
             }
         }
         

Modified: cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java?rev=1144979&r1=1144978&r2=1144979&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java
(original)
+++ cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java
Sun Jul 10 22:13:43 2011
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.systest.jaxrs;
 
+import java.util.List;
+
 import javax.ws.rs.Consumes;
 import javax.ws.rs.CookieParam;
 import javax.ws.rs.FormParam;
@@ -58,8 +60,7 @@ public interface BookSubresource {
     @POST
     @Path("/subresource3")
     Book getTheBook3(@FormParam("id") String id,
-                     @FormParam("name") String name,
-                     @FormParam("nameid") Integer nameid) throws BookNotFoundFault;
+                     @FormParam("name") List<String> nameParts) throws BookNotFoundFault;
     
     @POST
     @Path("/subresource4/{id}/{name}")

Modified: cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresourceImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresourceImpl.java?rev=1144979&r1=1144978&r2=1144979&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresourceImpl.java
(original)
+++ cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresourceImpl.java
Sun Jul 10 22:13:43 2011
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.systest.jaxrs;
 
+import java.util.List;
+
 
 
 public class BookSubresourceImpl implements BookSubresource {
@@ -55,11 +57,15 @@ public class BookSubresourceImpl impleme
         return b;
     }
     
-    public Book getTheBook3(String sid, String name, Integer nameid) throws BookNotFoundFault
{
+    public Book getTheBook3(String sid, List<String> nameParts) throws BookNotFoundFault
{
+        if (nameParts.size() != 2) {
+            throw new RuntimeException("Wrong number of name parts");
+        }
+        
         Book b = new Book();
         
         b.setId(Long.valueOf(sid)); 
-        b.setName(name + nameid.toString());
+        b.setName(nameParts.get(0) + nameParts.get(1));
         return b;
     }
     

Modified: cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java?rev=1144979&r1=1144978&r2=1144979&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
(original)
+++ cxf/branches/2.4.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
Sun Jul 10 22:13:43 2011
@@ -579,8 +579,8 @@ public class JAXRSSoapBookTest extends A
         WebClient wc = WebClient.create(baseAddress);
         MultivaluedMap<String, Object> map = new MetadataMap<String, Object>();
         map.putSingle("id", "679");
-        map.putSingle("name", "CXF in Action - ");
-        map.putSingle("nameid", "679");
+        map.add("name", "CXF in Action - ");
+        map.add("name", "679");
         Book b = readBook((InputStream)wc.accept("application/xml")
                           .form((Map<String, List<Object>>)map).getEntity());
         assertEquals(679, b.getId());
@@ -595,7 +595,7 @@ public class JAXRSSoapBookTest extends A
         WebClient wc = WebClient.create(baseAddress);
         Form f = new Form();
         f.set("id", "679").set("name", "CXF in Action - ")
-            .set("nameid", "679");
+            .set("name", "679");
         Book b = readBook((InputStream)wc.accept("application/xml")
                           .form(f).getEntity());
         assertEquals(679, b.getId());
@@ -609,7 +609,10 @@ public class JAXRSSoapBookTest extends A
         BookStoreJaxrsJaxws proxy = JAXRSClientFactory.create(baseAddress,
                                                                   BookStoreJaxrsJaxws.class);
         BookSubresource bs = proxy.getBookSubresource("679");
-        Book b = bs.getTheBook3("679", "CXF in Action - ", new Integer(679));
+        List<String> parts = new ArrayList<String>();
+        parts.add("CXF in Action - ");
+        parts.add(Integer.toString(679));
+        Book b = bs.getTheBook3("679", parts);
         assertEquals(679, b.getId());
         assertEquals("CXF in Action - 679", b.getName());
     }



Mime
View raw message