cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1148067 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/model/wadl/ test/java/org/apache/cxf/jaxrs/model/wadl/ test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/
Date Mon, 18 Jul 2011 21:46:43 GMT
Author: sergeyb
Date: Mon Jul 18 21:46:42 2011
New Revision: 1148067

URL: http://svn.apache.org/viewvc?rev=1148067&view=rev
Log:
[CXF-3656] Combination of form and other jaxrs parameter types was causing IllegalStateException

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/FormInterface.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Book.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=1148067&r1=1148066&r2=1148067&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
Mon Jul 18 21:46:42 2011
@@ -665,7 +665,9 @@ public class WadlGenerator implements Re
             sb.append("<representation");
             sb.append(" mediaType=\"").append(formType).append("\">");
             for (Parameter pm : ori.getParameters()) {
-                writeParam(sb, pm, ori);
+                if (pm.getType() == ParameterType.FORM) {
+                    writeParam(sb, pm, ori);
+                }
             }
             sb.append("</representation>");
         }
@@ -888,11 +890,12 @@ public class WadlGenerator implements Re
     }
     
     private Class<?> getFormClass(OperationResourceInfo ori) {
-        if (ori.getParameters().get(0).getType() == ParameterType.FORM) {
-            return null;
-        } else {
-            return MultivaluedMap.class;
-        }
+        for (Parameter p : ori.getParameters()) {
+            if (p.getType() == ParameterType.FORM) {
+                return null;
+            }
+        } 
+        return MultivaluedMap.class;
     }
 
     // TODO : can we reuse this block with JAXBBinding somehow ?

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/FormInterface.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/FormInterface.java?rev=1148067&r1=1148066&r2=1148067&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/FormInterface.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/FormInterface.java
Mon Jul 18 21:46:42 2011
@@ -22,6 +22,7 @@ import javax.ws.rs.Consumes;
 import javax.ws.rs.FormParam;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
@@ -36,4 +37,11 @@ public interface FormInterface {
     @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
     @Produces(MediaType.TEXT_PLAIN)
     String form2(@FormParam("field1") String f1, @FormParam("field2") String f2);
+    
+    @Path("/form3/{id}")
+    @POST
+    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
+    @Produces(MediaType.TEXT_PLAIN)
+    String form3(@PathParam("id") String id, 
+                 @FormParam("field1") String f1, @FormParam("field2") String f2);
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java?rev=1148067&r1=1148066&r2=1148067&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
Mon Jul 18 21:46:42 2011
@@ -433,13 +433,14 @@ public class WadlGeneratorTest extends A
                          new Param("mid", "matrix", "xs:int"));
         checkDocs(resourceEls.get(5), "", "Book subresource", ""); 
         // should have 4 child resources
-        List<Element> subResourceEls = getElements(resourceEls.get(5), "resource",
4);
+        List<Element> subResourceEls = getElements(resourceEls.get(5), "resource",
5);
 
         assertEquals("/book", subResourceEls.get(0).getAttribute("path"));
         assertEquals("/form1", subResourceEls.get(1).getAttribute("path"));
         assertEquals("/form2", subResourceEls.get(2).getAttribute("path"));
-        assertEquals("/chapter/{cid}", subResourceEls.get(3).getAttribute("path"));
-        checkDocs(subResourceEls.get(3), "", "Chapter subresource", "");
+        assertEquals("/form3/{id}", subResourceEls.get(3).getAttribute("path"));
+        assertEquals("/chapter/{cid}", subResourceEls.get(4).getAttribute("path"));
+        checkDocs(subResourceEls.get(4), "", "Chapter subresource", "");
         // verify book-subresource /book resource
         // GET 
         verifyGetResourceMethod(subResourceEls.get(0), bookEl, null);
@@ -464,9 +465,9 @@ public class WadlGeneratorTest extends A
         
         
         // verify subresource /chapter/{id}
-        List<Element> chapterMethodEls = getElements(subResourceEls.get(3), "resource",
1);
+        List<Element> chapterMethodEls = getElements(subResourceEls.get(4), "resource",
1);
         assertEquals("/id", chapterMethodEls.get(0).getAttribute("path"));
-        verifyParameters(subResourceEls.get(3), 1, 
+        verifyParameters(subResourceEls.get(4), 1, 
                          new Param("cid", "template", "xs:int"));
         // GET
         verifyGetResourceMethod(chapterMethodEls.get(0), chapterEl, "Get the chapter");

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Book.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Book.java?rev=1148067&r1=1148066&r2=1148067&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Book.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Book.java
Mon Jul 18 21:46:42 2011
@@ -75,5 +75,9 @@ public class Book implements FormInterfa
     public String form2(String f1, String f2) {
         return "";
     }
+
+    public String form3(String identificator, String f1, String f2) {
+        return "";
+    }
     
 }



Mime
View raw message