cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1388010 - /cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
Date Thu, 20 Sep 2012 13:01:40 GMT
Author: sergeyb
Date: Thu Sep 20 13:01:40 2012
New Revision: 1388010

URL: http://svn.apache.org/viewvc?rev=1388010&view=rev
Log:
Minor update to the wadl generator to avoid adding full class names for custom media type
class names

Modified:
    cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java

Modified: cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java?rev=1388010&r1=1388009&r2=1388010&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
(original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
Thu Sep 20 13:01:40 2012
@@ -1096,23 +1096,28 @@ public class SourceGenerator {
                 String clsName = getSchemaClassName(packageName, gInfo, actualValue, 
                                                     info.getTypeClassNames());
                 
-                if (clsName == null) {
+                if (clsName != null) {
                     clsName = schemaTypeMap.get("{" + namespace + "}" + actualValue);
                 }
                 if (clsName != null) {
-                    addImport(imports, clsName);
-                    int index = clsName.lastIndexOf(".");
-                    
-                    if (index != -1) {
-                        clsName = clsName.substring(index + 1);
-                    } 
-                    return clsName;      
+                    return addImportsAndGetSimpleName(imports, clsName);
                 }
+                
             }
         }
         return defaultValue;
     }
     
+    private String addImportsAndGetSimpleName(Set<String> imports, String clsName)
{
+        addImport(imports, clsName);
+        int index = clsName.lastIndexOf(".");
+        
+        if (index != -1) {
+            clsName = clsName.substring(index + 1);
+        }
+        return clsName;
+    }
+    
     private String getElementRefName(Element repElement,
                                      ContextInfo info, 
                                      Set<String> imports) {
@@ -1130,7 +1135,7 @@ public class SourceGenerator {
             // try mediaTypesMap first
             String mediaType = repElement.getAttribute("mediaType");
             if (!StringUtils.isEmpty(mediaType) && mediaTypesMap.containsKey(mediaType))
{
-                return mediaTypesMap.get(mediaType);
+                return addImportsAndGetSimpleName(imports, mediaTypesMap.get(mediaType));
             }
             
             Element param = DOMUtils.getFirstChildWithName(repElement, getWadlNamespace(),
"param");



Mime
View raw message