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:32:01 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 730cdf2e6 -> 563ae6314


[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/563ae631
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/563ae631
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/563ae631

Branch: refs/heads/master
Commit: 563ae63147b65a632364a726f63fd66054df946a
Parents: 730cdf2
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:31:43 2014 +0300

----------------------------------------------------------------------
 .../java/org/apache/cxf/jaxrs/impl/RequestPreprocessor.java | 2 +-
 .../java/org/apache/cxf/jaxrs/utils/InjectionUtils.java     | 2 +-
 .../java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java | 9 ++-------
 .../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, 8 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/563ae631/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 7c6dadb..1a9e00f 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
@@ -148,7 +148,7 @@ public class RequestPreprocessor {
         String method = queries.getFirst(METHOD_QUERY);
         if (method == null) {
             List<String> list = headers.getRequestHeader(METHOD_HEADER);
-            if (list.size() == 1) {
+            if (list != null && list.size() == 1) {
                 method = list.get(0);
             }
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/563ae631/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 7cbfea9..bc50373 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
@@ -1221,7 +1221,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/563ae631/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
index 2f7d79d..352a7cf 100644
--- a/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
+++ b/rt/rs/description/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
@@ -1412,13 +1412,7 @@ public class WadlGenerator implements ContainerRequestFilter {
             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);
@@ -1915,4 +1909,5 @@ public class WadlGenerator implements ContainerRequestFilter {
         }
     }
 
+    
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/563ae631/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
b/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
index 0d175bd..17bb003 100644
--- a/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
+++ b/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
@@ -178,7 +178,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/563ae631/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
----------------------------------------------------------------------
diff --git a/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
b/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
index 5362003..b087da0 100644
--- a/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
+++ b/rt/rs/description/src/test/java/org/apache/cxf/jaxrs/model/wadl/WadlGeneratorTest.java
@@ -587,7 +587,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/563ae631/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 0c23b1b..e8a0060 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
@@ -551,9 +551,7 @@ public class SourceGenerator {
     
     private String firstCharToUpperCase(String name) {
         if (name.length() > 0 && Character.isLowerCase(name.charAt(0))) {
-            StringBuilder sb = new StringBuilder();
-            sb.append(Character.toUpperCase(name.charAt(0)));
-            return name.length() > 1 ? sb.append(name.substring(1)).toString() : sb.toString();
+            return StringUtils.capitalize(name);
         } else {
             return name;
         }
@@ -561,9 +559,7 @@ public class SourceGenerator {
     
     private String firstCharToLowerCase(String name) {
         if (name.length() > 0 && Character.isUpperCase(name.charAt(0))) {
-            StringBuilder sb = new StringBuilder();
-            sb.append(Character.toLowerCase(name.charAt(0)));
-            return name.length() > 1 ? sb.append(name.substring(1)).toString() : sb.toString();
+            return StringUtils.uncapitalize(name);
         } else {
             return name;
         }


Mime
View raw message