cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1057900 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
Date Tue, 11 Jan 2011 22:43:16 GMT
Author: sergeyb
Date: Tue Jan 11 22:43:15 2011
New Revision: 1057900

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

........
  r1057891 | sergeyb | 2011-01-11 22:07:26 +0000 (Tue, 11 Jan 2011) | 1 line
  
  [CXF-3242] Better handling of primitive response/request types
........

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/WadlGeneratorTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 11 22:43:15 2011
@@ -1 +1 @@
-/cxf/trunk:1057393,1057629,1057666,1057860
+/cxf/trunk:1057393,1057629,1057666,1057860,1057891

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=1057900&r1=1057899&r2=1057900&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
Tue Jan 11 22:43:15 2011
@@ -460,12 +460,10 @@ public class WadlGenerator implements Re
     }
     
     protected void doWriteParam(StringBuilder sb, Parameter pm, Class<?> type, String
paramName) {
-        if (ParameterType.REQUEST_BODY == pm.getType()) {
-            return;
-        }
         sb.append("<param name=\"").append(paramName).append("\" ");
         String style = ParameterType.PATH == pm.getType() ? "template" 
                        : ParameterType.FORM == pm.getType() ? "query"
+                       : ParameterType.REQUEST_BODY == pm.getType() ? "plain"    
                        : pm.getType().toString().toLowerCase();
         sb.append("style=\"").append(style).append("\"");
         if (pm.getDefaultValue() != null) {
@@ -488,25 +486,40 @@ public class WadlGenerator implements Re
         } else if (isWildcard(types)) {
             types = Collections.singletonList(MediaType.APPLICATION_OCTET_STREAM_TYPE);
         } 
+        
+        boolean isPrimitive = InjectionUtils.isPrimitive(type);
         for (MediaType mt : types) {
-            if (InjectionUtils.isPrimitive(type)) {
-                String rep = XmlSchemaPrimitiveUtils.getSchemaRepresentation(type);
-                String value = rep == null ? type.getSimpleName() : rep;
-                sb.append("<!-- Primitive type : " + value + " -->");
-            }
+            
             sb.append("<representation");
             sb.append(" mediaType=\"").append(mt.toString()).append("\"");
 
-            type = getActualJaxbType(type, ori.getAnnotatedMethod(), inbound);
-            if (qnameResolver != null && mt.getSubtype().contains("xml") &&
jaxbTypes.contains(type)) {
-                generateQName(sb, qnameResolver, clsMap, type,
-                              getBodyAnnotations(ori, inbound));
+            if (isPrimitive) {
+                sb.append(">");    
+                Parameter p = inbound ? getRequestBodyParam(ori) 
+                    : new Parameter(ParameterType.REQUEST_BODY, 0, "result"); 
+                doWriteParam(sb, p, type, p.getName() == null ? "request" : p.getName());
+                sb.append("</representation>");
+            } else  { 
+                type = getActualJaxbType(type, ori.getAnnotatedMethod(), inbound);
+                if (qnameResolver != null && mt.getSubtype().contains("xml") &&
jaxbTypes.contains(type)) {
+                    generateQName(sb, qnameResolver, clsMap, type,
+                                  getBodyAnnotations(ori, inbound));
+                }
+                sb.append("/>");
             }
-            sb.append("/>");
         }
         
     }
     
+    private Parameter getRequestBodyParam(OperationResourceInfo ori) {
+        for (Parameter p : ori.getParameters()) {
+            if (p.getType() == ParameterType.REQUEST_BODY) {
+                return p;
+            }
+        }
+        throw new IllegalStateException();
+    }
+    
     private boolean isWildcard(List<MediaType> types) {
         return types.size() == 1 && types.get(0).equals(MediaType.WILDCARD_TYPE);
     }

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=1057900&r1=1057899&r2=1057900&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
Tue Jan 11 22:43:15 2011
@@ -524,6 +524,10 @@ public class WadlGeneratorTest extends A
                     WadlGenerator.WADL_NS, "representation"); 
         assertEquals(1, representationEls.size());
         verifyMediTypeAndElementValue(representationEls.get(0), mediaType, elementValue);
+        if ("text/plain".equals(mediaType)) { 
+            String pName = "request".equals(name) ? "request" : "result";
+            verifyParameters(representationEls.get(0), 1, new Param(pName, "plain", "xs:string"));
+        }
     }
     
     private void verifyXmlJsonRepresentations(Element element, String type) {



Mime
View raw message