cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5952, CXF-5953] Fixing few issues related to the processing of representation params
Date Fri, 15 Aug 2014 12:52:46 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 7bfa54afe -> 24af7fa6b


[CXF-5952, CXF-5953] Fixing few issues related to the processing of representation params


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/24af7fa6
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/24af7fa6
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/24af7fa6

Branch: refs/heads/3.0.x-fixes
Commit: 24af7fa6bd1fa1f99ec1056a8509e05e4eff54c0
Parents: 7bfa54a
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Fri Aug 15 13:51:09 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Fri Aug 15 13:52:22 2014 +0100

----------------------------------------------------------------------
 .../cxf/tools/wadlto/jaxrs/SourceGenerator.java | 32 ++++++++++++--------
 .../jaxrs/src/test/resources/wadl/test.xml      | 20 +++++-------
 2 files changed, 28 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/24af7fa6/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
----------------------------------------------------------------------
diff --git a/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
b/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
index 194e25e..f5e9ff7 100644
--- a/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
+++ b/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
@@ -745,7 +745,7 @@ public class SourceGenerator {
                     }
                     genMethodName += firstCharToUpperCase(sb.toString());
                 }
-                sbCode.append(genMethodName);
+                sbCode.append(genMethodName.replace("-", ""));
             } else {
                 boolean expandedQName = id.startsWith("{");
                 QName qname = convertToQName(id, expandedQName);
@@ -926,11 +926,11 @@ public class SourceGenerator {
             }
         }
         
-        String elementName = responseRequired ? null : getElementRefName(
+        String elementType = responseRequired ? null : getElementRefName(
                 getActualRepElement(repElements, getXmlReps(repElements, info.getGrammarInfo()).get(0)),

-                info, imports);
-        if (elementName != null) {
-            sbCode.append(elementName + " ");
+                info, imports, true);
+        if (elementType != null) {
+            sbCode.append(elementType + " ");
         } else {
             writeJaxrResponse(sbCode, imports);
         }
@@ -1049,13 +1049,19 @@ public class SourceGenerator {
         String elementParamName = null;
         if (!form) {
             if (!jaxpRequired) {    
-                elementParamType = getElementRefName(repElement, info, imports);
+                elementParamType = getElementRefName(repElement, info, imports, false);
                 if (elementParamType != null) {
                     int lastIndex = elementParamType.lastIndexOf('.');
                     if (lastIndex != -1) {
                         elementParamType = elementParamType.substring(lastIndex + 1);
                     }
                     elementParamName = elementParamType.toLowerCase();
+                } else if (repElement != null) {
+                    Element param = DOMUtils.getFirstChildWithName(repElement, getWadlNamespace(),
"param");
+                    if (param != null) {
+                        elementParamType = getPrimitiveType(param, info, imports);
+                        elementParamName = param.getAttribute("name");
+                    }
                 }
             } else {
                 addImport(imports, Source.class.getName());
@@ -1218,7 +1224,7 @@ public class SourceGenerator {
             String value = pair[1].replaceAll("[\\-\\_]", "");
             return convertRefToClassName(pair[0], value, defaultValue, info, imports);
         } else {
-            return type;
+            return addImportsAndGetSimpleName(imports, type);
         }
         
     }
@@ -1274,7 +1280,8 @@ public class SourceGenerator {
     
     private String getElementRefName(Element repElement,
                                      ContextInfo info, 
-                                     Set<String> imports) {
+                                     Set<String> imports,
+                                     boolean checkPrimitive) {
         if (repElement == null) {
             return null;
         }
@@ -1294,10 +1301,11 @@ public class SourceGenerator {
             if (!StringUtils.isEmpty(mediaType) && mediaTypesMap.containsKey(mediaType))
{
                 return addImportsAndGetSimpleName(imports, mediaTypesMap.get(mediaType));
             }
-            
-            Element param = DOMUtils.getFirstChildWithName(repElement, getWadlNamespace(),
"param");
-            if (param != null) {
-                return getPrimitiveType(param, info, imports);
+            if (checkPrimitive) {
+                Element param = DOMUtils.getFirstChildWithName(repElement, getWadlNamespace(),
"param");
+                if (param != null) {
+                    return getPrimitiveType(param, info, imports);
+                }
             }
         }
         return null;

http://git-wip-us.apache.org/repos/asf/cxf/blob/24af7fa6/tools/wadlto/jaxrs/src/test/resources/wadl/test.xml
----------------------------------------------------------------------
diff --git a/tools/wadlto/jaxrs/src/test/resources/wadl/test.xml b/tools/wadlto/jaxrs/src/test/resources/wadl/test.xml
index 1d62211..6ee4988 100644
--- a/tools/wadlto/jaxrs/src/test/resources/wadl/test.xml
+++ b/tools/wadlto/jaxrs/src/test/resources/wadl/test.xml
@@ -9,8 +9,9 @@
 				</response>
 			</method>
 
-			<resource path="{name}">
-				<param name="name" style="template" type="xs:string"/>
+			<resource path="{the-name}">
+				<param name="the-name" style="template" type="xs:string"/>
+				
 				<method name="PUT" id="createRepository" >
 					<request>
 					</request>
@@ -19,17 +20,12 @@
 				</method>
 				<method name="DELETE" id="deleteRepository">
 				</method>
-                <method name="GET" id="getName">
+					
+                <method name="POST">
 	                <request>
-	                    <param name="a" style="query" type="xs:int"/>
-	                    <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:dateTime"/>
-	                    <param name="option" default="A" style="query" required="true">
-	                        <option value="A"/>
-	                        <option value="B"/>
-	                    </param>
-	                    <param name="If-Modified-Since" style="header" type="xsd:date"/>
+	                    <representation mediaType="text/plain">
+	                        <param name="id" style="plain" type="java.util.Date"/>
+	                    </representation>
 	                </request>
 	                <response>
 	                    <representation mediaType="text/plain">


Mime
View raw message