cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5916] Better support for camel case properties
Date Thu, 31 Jul 2014 09:45:50 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 6601affb8 -> 9fa56fc02


[CXF-5916] Better support for camel case properties


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

Branch: refs/heads/2.7.x-fixes
Commit: 9fa56fc02bff80bee850dd88df01cb7b62807268
Parents: 6601aff
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Thu Jul 31 12:31:43 2014 +0300
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Thu Jul 31 12:45:28 2014 +0300

----------------------------------------------------------------------
 .../java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java  | 6 +++---
 .../java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java  | 8 +-------
 .../main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java | 2 +-
 .../test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java | 2 +-
 .../org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java   | 2 +-
 .../org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java   | 8 +++-----
 6 files changed, 10 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/9fa56fc0/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
index bd90dc2..c5de097 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java
@@ -157,9 +157,9 @@ public class RequestPreprocessor {
                               HttpHeaders headers) {
         String method = queries.getFirst(METHOD_QUERY);
         if (method == null) {
-            List<String> values = headers.getRequestHeader(METHOD_HEADER);
-            if (values.size() == 1) {
-                method = values.get(0);
+            List<String> list = headers.getRequestHeader(METHOD_HEADER);
+            if (list != null && list.size() == 1) {
+                method = list.get(0);
             }
         }
         if (method != null) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/9fa56fc0/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
index fff8bf9..ca52361 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
@@ -1330,13 +1330,7 @@ public class WadlGenerator implements RequestHandler {
             return null;
         }
         if (JAXB_DEFAULT_NAME.equals(name)) {
-            name = type.getSimpleName();
-            StringBuilder sb = new StringBuilder();
-            sb.append(Character.toLowerCase(name.charAt(0)));
-            if (name.length() > 1) {
-                sb.append(name.substring(1));
-            }
-            name = sb.toString();
+            name = StringUtils.uncapitalize(type.getSimpleName());
         }
         String prefix = getPrefix(namespace, clsMap);
         return new QName(namespace, name, prefix);

http://git-wip-us.apache.org/repos/asf/cxf/blob/9fa56fc0/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
index fdf4dd6..95f629e 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
@@ -1196,7 +1196,7 @@ public final class InjectionUtils {
                 if (methodName.length() <= minLen) {
                     continue;
                 }
-                String propertyName = methodName.substring(minLen).toLowerCase();
+                String propertyName = StringUtils.uncapitalize(methodName.substring(minLen));
                 if (m.getReturnType() == Class.class
                     || checkIgnorable && canPropertyBeIgnored(m, propertyName)) {
                     continue;

http://git-wip-us.apache.org/repos/asf/cxf/blob/9fa56fc0/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
index f22d365..acd365a 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
@@ -176,7 +176,7 @@ public class BookStore implements BookDescription {
         private int b;
         private QueryBean2 bean;
         
-        public int getA() {
+        public int getAProp() {
             return a;
         }
         

http://git-wip-us.apache.org/repos/asf/cxf/blob/9fa56fc0/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
index abe1bd0..8343494 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
@@ -586,7 +586,7 @@ public class WadlGeneratorTest extends Assert {
         
         // 4 parameters are expected
         verifyParameters(requestEls.get(0), 5, 
-                         new Param("a", "query", "xs:int"),
+                         new Param("aProp", "query", "xs:int"),
                          new Param("c.a", "query", "xs:int"),
                          new Param("c.b", "query", "xs:int"),
                          new Param("c.d.a", "query", "xs:boolean"),

http://git-wip-us.apache.org/repos/asf/cxf/blob/9fa56fc0/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 8045810..bf4c372 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
@@ -550,12 +550,10 @@ public class SourceGenerator {
     }
     
     private String firstCharToUpperCase(String name) {
-        StringBuilder sb = new StringBuilder();
-        if (name.length() > 0) {
-            sb.append(Character.toUpperCase(name.charAt(0)));
-            return name.length() > 1 ? sb.append(name.substring(1)).toString() : sb.toString();
+        if (name.length() > 0 && Character.isLowerCase(name.charAt(0))) {
+            return StringUtils.capitalize(name);
         } else {
-            return sb.toString();
+            return name;
         }
     }
     


Mime
View raw message