cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1435223 - in /cxf/trunk/tools/wadlto/jaxrs/src: main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java test/resources/wadl/bookstore.xml
Date Fri, 18 Jan 2013 16:15:20 GMT
Author: sergeyb
Date: Fri Jan 18 16:15:19 2013
New Revision: 1435223

URL: http://svn.apache.org/viewvc?rev=1435223&view=rev
Log:
[CXF-4766] Stripping custom regular expressions from method names

Modified:
    cxf/trunk/tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
    cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml

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=1435223&r1=1435222&r2=1435223&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
Fri Jan 18 16:15:19 2013
@@ -60,6 +60,7 @@ import javax.ws.rs.container.AsyncRespon
 import javax.ws.rs.container.Suspended;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.PathSegment;
 import javax.ws.rs.core.Response;
 import javax.xml.namespace.QName;
 import javax.xml.transform.Source;
@@ -699,8 +700,17 @@ public class SourceGenerator {
                 responseTypeAvailable = writeResponseType(responseEls, sbCode, imports, info,
suspendedAsync);
                 String genMethodName = id + suffixName;
                 if (methodNameLowerCase.equals(genMethodName)) {
-                    genMethodName += firstCharToUpperCase(
-                        currentPath.replaceAll("/", "").replaceAll("\\{", "").replaceAll("\\}",
""));
+                    List<PathSegment> segments = JAXRSUtils.getPathSegments(currentPath,
true, true);
+                    StringBuilder sb = new StringBuilder();
+                    for (PathSegment ps : segments) {
+                        String pathSeg = ps.getPath().replaceAll("\\{", "").replaceAll("\\}",
"");
+                        int index = pathSeg.indexOf(":");
+                        if (index > 0) {
+                            pathSeg = pathSeg.substring(0, index);
+                        }
+                        sb.append(pathSeg);
+                    }
+                    genMethodName += firstCharToUpperCase(sb.toString());
                 }
                 sbCode.append(genMethodName);
             } else {

Modified: cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml?rev=1435223&r1=1435222&r2=1435223&view=diff
==============================================================================
--- cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml (original)
+++ cxf/trunk/tools/wadlto/jaxrs/src/test/resources/wadl/bookstore.xml Fri Jan 18 16:15:19
2013
@@ -97,13 +97,18 @@ required="true">
     
     <method name="DELETE"/>
     
-    <resource path="/book2">
+    <resource path="/book2/{bookid:.*}">
      <method name="GET" id="getBook2">
       <response>
        <representation mediaType="application/xml" element="prefix1:theBook2"/>
        <representation mediaType="application/json"/>
       </response>
      </method>
+     <method name="GET">
+      <response>
+        <representation mediaType="application/pdf"/>
+      </response>
+     </method>
     </resource>
 
     <resource path="/books/{bookid}">



Mime
View raw message