cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1148079 - in /cxf/branches/2.4.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java tools/wadlto/jaxrs/src/test/resources/wadl/singleResource.xml
Date Mon, 18 Jul 2011 22:33:03 GMT
Author: sergeyb
Date: Mon Jul 18 22:33:02 2011
New Revision: 1148079

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

........
  r1148077 | sergeyb | 2011-07-18 23:30:51 +0100 (Mon, 18 Jul 2011) | 1 line
  
  [CXF-3662] Better support for multiple response elements
........

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/ext/codegen/SourceGenerator.java
    cxf/branches/2.4.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/singleResource.xml

Propchange: cxf/branches/2.4.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jul 18 22:33:02 2011
@@ -1 +1 @@
-/cxf/trunk:1144977,1145682,1146773,1147504,1148067
+/cxf/trunk:1144977,1145682,1146773,1147504,1148067,1148077

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/ext/codegen/SourceGenerator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java?rev=1148079&r1=1148078&r2=1148079&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
(original)
+++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
Mon Jul 18 22:33:02 2011
@@ -576,9 +576,29 @@ public class SourceGenerator {
     private boolean writeResponseType(List<Element> responseEls, StringBuilder sbCode,
                                    Set<String> imports, Set<String> typeClassNames,

                                    GrammarInfo gInfo) {
-        List<Element> repElements = responseEls.size() == 1 
-            ? DOMUtils.getChildrenWithName(responseEls.get(0), WadlGenerator.WADL_NS, "representation")
-            : CastUtils.cast(Collections.emptyList(), Element.class);
+        List<Element> repElements = null;
+        if (responseEls.size() >= 1) {
+            Element okResponse = null;
+            if (responseEls.size() > 1) {
+                for (int i = 0; i < responseEls.size(); i++) {
+                    String statusValue = responseEls.get(0).getAttribute("status");
+                    try {
+                        int status = statusValue.isEmpty() ? 200 : Integer.valueOf(statusValue);
+                        if (status == 200) {
+                            okResponse = responseEls.get(i);
+                            break;
+                        }
+                    } catch (NumberFormatException ex) {
+                        // ignore
+                    }
+                }
+            } else {
+                okResponse = responseEls.get(0);
+            }
+            repElements = DOMUtils.getChildrenWithName(okResponse, WadlGenerator.WADL_NS,
"representation");
+        } else {
+            repElements = CastUtils.cast(Collections.emptyList(), Element.class);
+        }
         if (repElements.size() == 0) {    
             sbCode.append("void ");
             return false;

Modified: cxf/branches/2.4.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/singleResource.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/singleResource.xml?rev=1148079&r1=1148078&r2=1148079&view=diff
==============================================================================
--- cxf/branches/2.4.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/singleResource.xml
(original)
+++ cxf/branches/2.4.x-fixes/tools/wadlto/jaxrs/src/test/resources/wadl/singleResource.xml
Mon Jul 18 22:33:02 2011
@@ -32,11 +32,14 @@
     </method>
     <resource path="/books">
      <method name="GET">
-      <response>
+      <response status="200">
        <representation mediaType="text/plain">
         <param name="result" style="plain" type="xs:string"/>
        </representation>
       </response>
+      <response status="400">
+        <representation mediaType="application/json"/>
+      </response>
     </method>
    </resource>
     



Mime
View raw message