cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1178015 - /cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
Date Sat, 01 Oct 2011 15:21:13 GMT
Author: sergeyb
Date: Sat Oct  1 15:21:13 2011
New Revision: 1178015

URL: http://svn.apache.org/viewvc?rev=1178015&view=rev
Log:
[CXF-3838] Optionally linking json elements to xml schema

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.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=1178015&r1=1178014&r2=1178015&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
Sat Oct  1 15:21:13 2011
@@ -123,7 +123,7 @@ public class WadlGenerator implements Re
     private boolean ignoreForwardSlash;
     private boolean addResourceAndMethodIds;
     private boolean ignoreRequests;
-    
+    private boolean linkJsonToXmlSchema;
     private boolean useJaxbContextForQnames = true;
 
     private List<String> externalSchemasCache;
@@ -668,7 +668,7 @@ public class WadlGenerator implements Re
             
             sb.append("<representation");
             sb.append(" mediaType=\"").append(mt.toString()).append("\"");
-            if (isJson && !mt.equals(MediaType.APPLICATION_JSON_TYPE)) {
+            if (isJson && !mt.getSubtype().contains("json")) {
                 sb.append("/>");
                 continue;
             }
@@ -696,7 +696,9 @@ public class WadlGenerator implements Re
                 type = ResourceUtils.getActualJaxbType(type, opMethod, inbound);
                 if (isJson) {
                     sb.append(" element=\"").append(type.getSimpleName()).append("\"");
-                } else if (qnameResolver != null && mt.getSubtype().contains("xml")

+                } else if (qnameResolver != null 
+                        && (mt.getSubtype().contains("xml")
+                                || linkJsonToXmlSchema && mt.getSubtype().contains("json"))
                         && jaxbTypes.contains(type)) {
                     generateQName(sb, qnameResolver, clsMap, type,
                                   getBodyAnnotations(ori, inbound));
@@ -1137,6 +1139,9 @@ public class WadlGenerator implements Re
         this.useSingleSlashResource = useSingleSlashResource;
     }
 
+    public void setLinkJsonToXmlSchema(boolean link) {
+        linkJsonToXmlSchema = link;
+    }
     public void setSchemaLocations(List<String> locations) {
 
         externalQnamesMap = new HashMap<String, List<String>>();



Mime
View raw message