cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1099619 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/
Date Wed, 04 May 2011 22:01:54 GMT
Author: sergeyb
Date: Wed May  4 22:01:54 2011
New Revision: 1099619

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

........
  r1099611 | sergeyb | 2011-05-04 22:28:18 +0100 (Wed, 04 May 2011) | 1 line
  
  [CXF-3490] Updating WADL Generator to handle repeating parameters correctly
........

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed May  4 22:01:54 2011
@@ -1 +1 @@
-/cxf/trunk:1094926,1094992,1095349,1095666,1097071,1097175,1097178,1097816,1099421,1099496
+/cxf/trunk:1094926,1094992,1095349,1095666,1097071,1097175,1097178,1097816,1099421,1099496,1099611

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

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=1099619&r1=1099618&r2=1099619&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
Wed May  4 22:01:54 2011
@@ -26,6 +26,7 @@ import java.io.StringReader;
 import java.io.StringWriter;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
+import java.lang.reflect.Type;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -451,7 +452,8 @@ public class WadlGenerator implements Re
     private void writeParam(StringBuilder sb, Parameter pm, OperationResourceInfo ori) {
         Class<?> type = getMethod(ori).getParameterTypes()[pm.getIndex()];
         if (!"".equals(pm.getName())) {
-            doWriteParam(sb, pm, type, pm.getName());
+            doWriteParam(sb, pm, type, getMethod(ori).getGenericParameterTypes()[pm.getIndex()],
+                         pm.getName());
         } else {
             doWriteBeanParam(sb, type, pm, null);
         }
@@ -464,15 +466,18 @@ public class WadlGenerator implements Re
             if (parentName != null) {
                 name = parentName + "." + name;
             }
-            if (InjectionUtils.isPrimitive(entry.getValue())) {
-                doWriteParam(sb, entry.getKey(), entry.getValue(), name);
+            Class<?> paramCls = entry.getValue();
+            boolean isPrimitive = InjectionUtils.isPrimitive(paramCls);
+            if (isPrimitive || InjectionUtils.isSupportedCollectionOrArray(paramCls)) {
+                doWriteParam(sb, entry.getKey(), paramCls, paramCls, name);
             } else {
-                doWriteBeanParam(sb, entry.getValue(), entry.getKey(), name);
+                doWriteBeanParam(sb, paramCls, entry.getKey(), name);
             }
         }
     }
-    
-    protected void doWriteParam(StringBuilder sb, Parameter pm, Class<?> type, String
paramName) {
+
+    protected void doWriteParam(StringBuilder sb, Parameter pm, Class<?> type, 
+                                Type genericType, String paramName) {
         sb.append("<param name=\"").append(paramName).append("\" ");
         String style = ParameterType.PATH == pm.getType() ? "template" 
                        : ParameterType.FORM == pm.getType() ? "query"
@@ -482,6 +487,10 @@ public class WadlGenerator implements Re
         if (pm.getDefaultValue() != null) {
             sb.append(" default=\"").append(pm.getDefaultValue()).append("\"");
         }
+        if (InjectionUtils.isSupportedCollectionOrArray(type)) {
+            type = InjectionUtils.getActualType(genericType);
+            sb.append(" repeating=\"true\"");
+        }
         String value = XmlSchemaPrimitiveUtils.getSchemaRepresentation(type);
         if (value != null) {
             sb.append(" type=\"").append(value).append("\"");
@@ -510,7 +519,7 @@ public class WadlGenerator implements Re
                 sb.append(">");    
                 Parameter p = inbound ? getRequestBodyParam(ori) 
                     : new Parameter(ParameterType.REQUEST_BODY, 0, "result"); 
-                doWriteParam(sb, p, type, p.getName() == null ? "request" : p.getName());
+                doWriteParam(sb, p, type, type, p.getName() == null ? "request" : p.getName());
                 sb.append("</representation>");
             } else  { 
                 type = getActualJaxbType(type, getMethod(ori), inbound);

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java?rev=1099619&r1=1099618&r2=1099619&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
Wed May  4 22:01:54 2011
@@ -18,6 +18,8 @@
  */
 package org.apache.cxf.jaxrs.model.wadl;
 
+import java.util.List;
+
 import javax.ws.rs.Consumes;
 import javax.ws.rs.CookieParam;
 import javax.ws.rs.GET;
@@ -75,6 +77,7 @@ public class BookStore {
                         @HeaderParam("hid") int headerId,
                         @CookieParam("cid") int cookieId,
                         @QueryParam("provider.bar") int queryParam,
+                        @QueryParam("a") List<String> queryList,
                         @Context HttpHeaders headers,
                         @XMLName(value = "{http://books}thesuperbook2", prefix = "p1")
                         Book2 b) {
@@ -99,14 +102,14 @@ public class BookStore {
     
     @GET
     @Path("chapter")
-    public Chapter getChaper() {
+    public Chapter getChapter() {
         return new Chapter(1);
     }
     
     @GET
     @Path("chapter2")
     @WadlElement(response = Chapter.class)
-    public Response getChaper2() {
+    public Response getChapter2() {
         return Response.ok().entity(new Chapter(1)).build();
     }
     

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java?rev=1099619&r1=1099618&r2=1099619&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
Wed May  4 22:01:54 2011
@@ -408,9 +408,10 @@ public class WadlGeneratorTest extends A
                                              WadlGenerator.WADL_NS, "request");
         assertEquals(1, requestEls.size());
         
-        verifyParameters(requestEls.get(0), 2, 
+        verifyParameters(requestEls.get(0), 3, 
                          new Param("hid", "header", "xs:int"),
-                         new Param("provider.bar", "query", "xs:int"));
+                         new Param("provider.bar", "query", "xs:int"),
+                         new Param("a", "query", "xs:string"));
         verifyXmlJsonRepresentations(requestEls.get(0), book2El);
         
         // PUT



Mime
View raw message