cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1188131 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml
Date Mon, 24 Oct 2011 12:52:09 GMT
Author: sergeyb
Date: Mon Oct 24 12:52:09 2011
New Revision: 1188131

URL: http://svn.apache.org/viewvc?rev=1188131&view=rev
Log:
[CXF-3875] Checking type and default attributes better

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
    cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java?rev=1188131&r1=1188130&r2=1188131&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
Mon Oct 24 12:52:09 2011
@@ -43,6 +43,7 @@ import java.util.logging.Logger;
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
 import javax.ws.rs.FormParam;
 import javax.ws.rs.GET;
 import javax.ws.rs.HEAD;
@@ -804,6 +805,11 @@ public class SourceGenerator {
             if (writeAnnotations(info.isInterfaceGenerated())) {
                 writeAnnotation(sbCode, imports, paramAnn, name, false, false);
                 sbCode.append(" ");
+                String defaultVal = paramEl.getAttribute("default");
+                if (defaultVal.length() > 0) {
+                    writeAnnotation(sbCode, imports, DefaultValue.class, defaultVal, false,
false);
+                    sbCode.append(" ");    
+                }
             }
             boolean isRepeating = Boolean.valueOf(paramEl.getAttribute("repeating"));
             String type = getPrimitiveType(paramEl);
@@ -869,7 +875,7 @@ public class SourceGenerator {
     
     private String getPrimitiveType(Element paramEl) {
         String type = paramEl.getAttribute("type");
-        if (type == null) {
+        if (type.length() == 0) {
             return "String";
         }
         String[] pair = type.split(":");

Modified: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml?rev=1188131&r1=1188130&r2=1188131&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml (original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml Mon Oct 24 12:52:09
2011
@@ -56,6 +56,11 @@
         <param name="c.a" style="query" type="xs:int"/>
         <param name="c.b" style="query" type="xs:int"/>
         <param name="c.d.a" style="query" type="xs:int"/>
+        <param name="option"  default="A" style="query"
+required="true">
+     <option value="A"/>
+     <option value="B"/>
+   </param> 
       </request>
       <response>
        <representation mediaType="text/plain">



Mime
View raw message