cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r724798 - in /cxf/branches/2.1.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ rt/frontend/jaxrs/...
Date Tue, 09 Dec 2008 17:49:10 GMT
Author: sergeyb
Date: Tue Dec  9 09:49:09 2008
New Revision: 724798

URL: http://svn.apache.org/viewvc?rev=724798&view=rev
Log:
Merged revisions 723378 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r723378 | sergeyb | 2008-12-04 17:21:28 +0000 (Thu, 04 Dec 2008) | 1 line
  
  JAXRS : support for list/set of path segments
........

Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PathSegmentImpl.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
    cxf/branches/2.1.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async_noservice.wsdl
  (props changed)

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Dec  9 09:49:09 2008
@@ -1 +1 @@
-/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513,703548,704584,704937,704997,705150,705235,705274,705340,705446,705548,705614,705692,705708,706482,706631,706675,706900,706909,707034,707089,707100,707902,708035,708044,708074,708410,708417,708550,708554,709353-709354,709425,710076,710150,71015
 4,711193,711388,711410,711490,711635,711949,711975,712194,712198,712238,712272,712299,712312,712670,712893,713082,713095-713096,713099,713584,713597,713737,713804,713899,714167-714168,714245,714255,717937-717961,718281-718448,718565,718620,718640,718665,718970,719017,719210,719215-719218,719222-719273,719305,719327-719680,720053,720119-720218,720238,720293-720316,720497,721221,721241,721501,722117,722129,722412,722988,723024,723338,723716-723791,724333-724372,724433-724438,724449,724481,724485,724668
+/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513,703548,704584,704937,704997,705150,705235,705274,705340,705446,705548,705614,705692,705708,706482,706631,706675,706900,706909,707034,707089,707100,707902,708035,708044,708074,708410,708417,708550,708554,709353-709354,709425,710076,710150,71015
 4,711193,711388,711410,711490,711635,711949,711975,712194,712198,712238,712272,712299,712312,712670,712893,713082,713095-713096,713099,713584,713597,713737,713804,713899,714167-714168,714245,714255,717937-717961,718281-718448,718565,718620,718640,718665,718970,719017,719210,719215-719218,719222-719273,719305,719327-719680,720053,720119-720218,720238,720293-720316,720497,721221,721241,721501,722117,722129,722412,722988,723024,723338,723378,723716-723791,724333-724372,724433-724438,724449,724481,724485,724668

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-blocked' - no diff available.

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PathSegmentImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PathSegmentImpl.java?rev=724798&r1=724797&r2=724798&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PathSegmentImpl.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PathSegmentImpl.java
Tue Dec  9 09:49:09 2008
@@ -44,7 +44,11 @@
 
     public String getPath() {
         int index = path.indexOf(';');
-        return index != -1 ? path.substring(0, index) : path;
+        String value = index != -1 ? path.substring(0, index) : path;
+        if (value.startsWith("/")) {
+            value = value.length() == 1 ? "" : value.substring(1);
+        }
+        return value; 
     }
     
     public String getOriginalPath() {

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java?rev=724798&r1=724797&r2=724798&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
Tue Dec  9 09:49:09 2008
@@ -113,6 +113,7 @@
     }
     
     private static String escapeCharacters(String expression) {
+        
         StringBuilder sb = new StringBuilder();
         for (int i = 0; i < expression.length(); i++) {
             char ch = expression.charAt(i);
@@ -145,11 +146,10 @@
                 StringBuilder sb = new StringBuilder();
                 for (int i = 0; i < uList.size(); i++) {
                     sb.append('/');
-                    if (pList.size() > i && pList.get(i).getPath().indexOf('{')
!= -1) {
-                        // if it's URI template variable then keep the original value
-                        sb.append(HttpUtils.fromPathSegment(uList.get(i)));
-                    } else {
+                    if (pList.size() > i && pList.get(i).getPath().indexOf('{')
== -1) {
                         sb.append(uList.get(i).getPath());
+                    } else {
+                        sb.append(HttpUtils.fromPathSegment(uList.get(i)));
                     }
                 }
                 uri = sb.toString();

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=724798&r1=724797&r2=724798&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
Tue Dec  9 09:49:09 2008
@@ -226,6 +226,7 @@
     public static Object injectIntoList(Type genericType, List<String> values,
                                         boolean decoded, boolean pathParam) {
         Class<?> realType = InjectionUtils.getActualType(genericType);
+        values = checkPathSegment(values, realType, pathParam);
         List theValues = new ArrayList();
         for (String r : values) {
             if (decoded) {
@@ -245,6 +246,9 @@
     public static Object injectIntoSet(Type genericType, List<String> values, 
                                        boolean sorted, boolean decoded, boolean pathParam)
{
         Class<?> realType = InjectionUtils.getActualType(genericType);
+        
+        values = checkPathSegment(values, realType, pathParam);
+        
         Set theValues = sorted ? new TreeSet() : new HashSet();
         for (String r : values) {
             if (decoded) {
@@ -258,6 +262,25 @@
         return theValues;
     }
     
+    private static List<String> checkPathSegment(List<String> values, Class<?>
type, boolean pathParam) {
+        if (!pathParam || !PathSegment.class.isAssignableFrom(type)) {
+            return values;
+        }
+        List<String> newValues = new ArrayList<String>();
+        for (String v : values) {
+            String[] segments = v.split("/");
+            for (String s : segments) {
+                if (s.length() != 0) {
+                    newValues.add(s);
+                }
+            }
+            if (v.endsWith("/")) {
+                newValues.add("");
+            }
+        }
+        return newValues;
+    }
+    
     public static Object createParameterObject(List<String> paramValues,
                                                Class<?> paramType,
                                                Type genericType,

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=724798&r1=724797&r2=724798&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
Tue Dec  9 09:49:09 2008
@@ -126,7 +126,7 @@
                                                : new String[]{"*/*"};
                 }
             } catch (Exception ex) {
-                System.out.println();
+                // ignore
             }
         }
         return values;

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java?rev=724798&r1=724797&r2=724798&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
Tue Dec  9 09:49:09 2008
@@ -88,6 +88,14 @@
     }
     
     @Test
+    public void testMatchWithMatrixOnClearPath4() throws Exception {
+        URITemplate uriTemplate = new URITemplate("/customers");
+        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
+        
+        assertTrue(uriTemplate.match("/customers;123456/123/orders;456/3", values));
+    }
+    
+    @Test
     public void testMatchBasicTwoParametersVariation1() throws Exception {
         URITemplate uriTemplate = new URITemplate("/customers/{name}/{department}");
         MultivaluedMap<String, String> values = new MetadataMap<String, String>();

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=724798&r1=724797&r2=724798&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
(original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
Tue Dec  9 09:49:09 2008
@@ -100,7 +100,7 @@
     @GET
     @Path("/segment/{pathsegment}/")
     public Book getBookBySegment(@PathParam("pathsegment") PathSegment segment) throws Exception
{
-        if (!"matrix".equals(segment.getPath())) {
+        if (!"matrix2".equals(segment.getPath())) {
             throw new RuntimeException();
         }
         MultivaluedMap<String, String> map = segment.getMatrixParameters();
@@ -110,6 +110,15 @@
     }
     
     @GET
+    @Path("/segment/list/{pathsegment:.+}/")
+    public Book getBookBySegment(@PathParam("pathsegment") List<PathSegment> list)

+        throws Exception {
+        return doGetBook(list.get(0).getPath()
+                         + list.get(1).getPath()
+                         + list.get(2).getPath());
+    }
+    
+    @GET
     @Path("/segment/matrix")
     public Book getBookByMatrixParams(@MatrixParam("first") String s1,
                                       @MatrixParam("second") String s2) throws Exception
{

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=724798&r1=724797&r2=724798&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Tue Dec  9 09:49:09 2008
@@ -216,18 +216,18 @@
     
     @Test
     public void testGetBookBySegment() throws Exception {
-        getAndCompareAsStrings("http://localhost:9080/bookstore/segment/matrix;first=12;second=3",
+        getAndCompareAsStrings("http://localhost:9080/bookstore/segment/matrix2;first=12;second=3",
                                "resources/expected_get_book123.txt",
                                "application/xml", 200);
         getAndCompareAsStrings("http://localhost:9080/bookstore;bar/segment;foo/"
-                               + "matrix;first=12;second=3;third",
+                               + "matrix2;first=12;second=3;third",
                                "resources/expected_get_book123.txt",
                                "application/xml", 200);
     }
     
     @Test
-    public void testGetBookByHeader() throws Exception {
-        getAndCompareAsStrings("http://localhost:9080/bookstore/bookheaders",
+    public void testGetBookByListOfSegments() throws Exception {
+        getAndCompareAsStrings("http://localhost:9080/bookstore/segment/list/1/2/3",
                                "resources/expected_get_book123.txt",
                                "application/xml", 200);
     }
@@ -237,8 +237,15 @@
         getAndCompareAsStrings("http://localhost:9080/bookstore/segment/matrix;first=12;second=3",
                                "resources/expected_get_book123.txt",
                                "application/xml", 200);
-        getAndCompareAsStrings("http://localhost:9080/bookstore;bar/segment;foo;"
-                               + "first=12;second=3/matrix;third",
+        getAndCompareAsStrings("http://localhost:9080/bookstore;bar;first=12/segment;foo;"
+                               + "second=3/matrix;third",
+                               "resources/expected_get_book123.txt",
+                               "application/xml", 200);
+    }
+    
+    @Test
+    public void testGetBookByHeader() throws Exception {
+        getAndCompareAsStrings("http://localhost:9080/bookstore/bookheaders",
                                "resources/expected_get_book123.txt",
                                "application/xml", 200);
     }

Propchange: cxf/branches/2.1.x-fixes/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async_noservice.wsdl
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Dec  9 09:49:09 2008
@@ -1 +1 @@
-/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async_noservice.wsdl:722412,722988,724485,724668
+/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/hello_world_async_noservice.wsdl:722412,722988,723378,724485,724668



Mime
View raw message