cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r756426 - in /cxf/branches/2.1.x-fixes: ./ common/common/src/main/java/org/apache/cxf/common/util/ common/common/src/test/java/org/apache/cxf/common/util/ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/ rt/databinding/jaxb/src/test/j...
Date Fri, 20 Mar 2009 12:05:19 GMT
Author: sergeyb
Date: Fri Mar 20 12:05:18 2009
New Revision: 756426

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

........
  r752435 | sergeyb | 2009-03-11 13:11:24 +0000 (Wed, 11 Mar 2009) | 1 line
  
  Fix for CXF-2098, update to ServletController for last segment matrix parameters handled correctly
........

Added:
    cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/UrlUtils.java
      - copied unchanged from r752435, cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/UrlUtils.java
    cxf/branches/2.1.x-fixes/common/common/src/test/java/org/apache/cxf/common/util/UrlUtilsTest.java
      - copied unchanged from r752435, cxf/trunk/common/common/src/test/java/org/apache/cxf/common/util/UrlUtilsTest.java
Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java   (props changed)
    cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBWrapperHelperTest.java   (props changed)
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
    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/impl/UriBuilderImpl.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.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/impl/UriBuilderImplTest.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/FormEncodingProviderTest.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/HttpUtilsTest.java
    cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 20 12:05:18 2009
@@ -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,723378,723716-723791,724333-724372,724433-724438,724449,724481,724485,724668,724780,724782,724785,724793,724795,724940,725071,725316,725332,725335,725348,725364,725418,725425-725426,725455,725506,725554,725562,725651,725671,725688,725754,725773,725799,725839,726342,726524,726631,726634,726637,726639,726692,726724,726769,726992,727096,727445,727521,727568,727692,727754,727781,727792,728070,728087,728696,728897,729051,729430,729449,729460,729863,730082,730139,730889,730891,731598,731604,731615,731631,731635,732036,732050,732320,732363,732411,732450,
 732710,732773,732827,732829,733512,733582,733901,734367,734462,734666,734762,734772,734812,734836,734965,735113,735252,735722-735723,735729,735734,735751,735782,735787,735987,736332,736343,736352,736358-736362,736408,736423,736448,736491,736621,736726,736736,736738-736739,736766,736825,736852,737032,737046,737061,737069,737124,737237,737246,737299,737356,737494,737498,737761,737817,737849,737855,737994,738166,738178,738201,738210,738242,738244,738265,738516,738583,738863,738937,738983,739366-739367,739451-739452,739799-739800,739867,739876-739877,739922,739937,739990,740045,740108,740154,740186,740197,740255,740706,740730,740810,740844,740886,740902,740923,740994,741058,741124,741152,741188,741521,741529,741879,742914,743087,743439,743441,743459,743469,743825,743965,743967,744104-744138,744175,744195,744237,744756,745214,745243,745472,745474,745560,745578,745586,745592,745638,745950,746012,746019-746020,746256,746266,746306,746357,746373-746374,746947,747026,747070,747217,74
 7386,747390,747406-747407,747454,747649,747766,747806-747846,747986,748159,748192-748193,748223,748305,748313,748597,748603-748604,748768,749420,749449,749454-749456,749505,749511,749513,749584,749596,749767,749771,749799,749890,749963,750010,750059-750060,750302,750522,750591,750663,750689,750935,750948,751067-751110,751233,751527,751567,751576,751607,751732,751740,751787,751828,751840,751972-751974,752099,752122,752132,752136,752280,752558,752613,752680,752728,752753,752849,752880-752881,752883,752961,752992,753205,753293,753335,753338,753388,755153,755514,755806
+/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,724780,724782,724785,724793,724795,724940,725071,725316,725332,725335,725348,725364,725418,725425-725426,725455,725506,725554,725562,725651,725671,725688,725754,725773,725799,725839,726342,726524,726631,726634,726637,726639,726692,726724,726769,726992,727096,727445,727521,727568,727692,727754,727781,727792,728070,728087,728696,728897,729051,729430,729449,729460,729863,730082,730139,730889,730891,731598,731604,731615,731631,731635,732036,732050,732320,732363,732411,732450,
 732710,732773,732827,732829,733512,733582,733901,734367,734462,734666,734762,734772,734812,734836,734965,735113,735252,735722-735723,735729,735734,735751,735782,735787,735987,736332,736343,736352,736358-736362,736408,736423,736448,736491,736621,736726,736736,736738-736739,736766,736825,736852,737032,737046,737061,737069,737124,737237,737246,737299,737356,737494,737498,737761,737817,737849,737855,737994,738166,738178,738201,738210,738242,738244,738265,738516,738583,738863,738937,738983,739366-739367,739451-739452,739799-739800,739867,739876-739877,739922,739937,739990,740045,740108,740154,740186,740197,740255,740706,740730,740810,740844,740886,740902,740923,740994,741058,741124,741152,741188,741521,741529,741879,742914,743087,743439,743441,743459,743469,743825,743965,743967,744104-744138,744175,744195,744237,744756,745214,745243,745472,745474,745560,745578,745586,745592,745638,745950,746012,746019-746020,746256,746266,746306,746357,746373-746374,746947,747026,747070,747217,74
 7386,747390,747406-747407,747454,747649,747766,747806-747846,747986,748159,748192-748193,748223,748305,748313,748597,748603-748604,748768,749420,749449,749454-749456,749505,749511,749513,749584,749596,749767,749771,749799,749890,749963,750010,750059-750060,750302,750522,750591,750663,750689,750935,750948,751067-751110,751233,751527,751567,751576,751607,751732,751740,751787,751828,751840,751972-751974,752099,752122,752132,752136,752280,752435,752558,752613,752680,752728,752753,752849,752880-752881,752883,752961,752992,753205,753293,753335,753338,753388,755153,755514,755806

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

Propchange: cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 20 12:05:18 2009
@@ -1 +1 @@
-/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java:743825,744104-744138,745472,745474,746947,747026,747070,747390,747407,747806-747846,748193,748597,749596,749963,750010,750522,750663,750948,752099,752280,755514,755806
+/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java:743825,744104-744138,745472,745474,746947,747026,747070,747390,747407,747806-747846,748193,748597,749596,749963,750010,750522,750663,750948,752099,752280,752435,755514,755806

Propchange: cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBWrapperHelperTest.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 20 12:05:18 2009
@@ -1 +1 @@
-/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBWrapperHelperTest.java:743825,744104-744138,745472,745474,746947,747026,747070,747390,747407,747806-747846,748193,748597,749596,749963,750010,750522,750663,750948,752099,752280,755514,755806
+/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBWrapperHelperTest.java:743825,744104-744138,745472,745474,746947,747026,747070,747390,747407,747806-747846,748193,748597,749596,749963,750010,750522,750663,750948,752099,752280,752435,755514,755806

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java?rev=756426&r1=756425&r2=756426&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java Fri Mar 20 12:05:18 2009
@@ -116,9 +116,10 @@
         }
 
         Object result = null;
-        ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
+        ClassLoader contextLoader = null;
         try {
             if (setServiceLoaderAsContextLoader(exchange.getInMessage())) {
+                contextLoader = Thread.currentThread().getContextClassLoader();
                 Thread.currentThread().setContextClassLoader(resourceObject.getClass().getClassLoader());
             }
             result = invoke(exchange, resourceObject, methodToInvoke, params);
@@ -137,7 +138,9 @@
             }
             return new MessageContentsList(excResponse);
         } finally {
-            Thread.currentThread().setContextClassLoader(contextLoader);
+            if (contextLoader != null) {
+                Thread.currentThread().setContextClassLoader(contextLoader);
+            }
         }
 
         if (ori.isSubResourceLocator()) {

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=756426&r1=756425&r2=756426&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java Fri Mar 20 12:05:18 2009
@@ -87,7 +87,7 @@
 
     protected AbstractClient(URI baseURI, URI currentURI) {
         this.baseURI = baseURI;
-        this.currentBuilder = new UriBuilderImpl(currentURI);
+        this.currentBuilder = new UriBuilderImpl(currentURI).encode(true);
     }
     
     public Client header(String name, Object... values) {

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=756426&r1=756425&r2=756426&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java Fri Mar 20 12:05:18 2009
@@ -52,8 +52,8 @@
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
 import org.apache.cxf.jaxrs.utils.AnnotationUtils;
+import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
-import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.jaxrs.utils.ParameterType;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageContentsList;
@@ -241,7 +241,7 @@
         List<Parameter> indexList =  getParameters(map, key);
         List<Object> list = new ArrayList<Object>(indexList.size());
         for (Parameter p : indexList) {
-            list.add(JAXRSUtils.encode(p.isEncoded(), params[p.getIndex()].toString()));
+            list.add(encode(p, params[p.getIndex()].toString()));
         }
         return list;
     }
@@ -258,8 +258,7 @@
         List<Parameter> qs = getParameters(map, ParameterType.QUERY);
         for (Parameter p : qs) {
             if (params[p.getIndex()] != null) {
-                ub.queryParam(p.getValue(), 
-                               JAXRSUtils.encode(p.isEncoded(), params[p.getIndex()].toString()));
+                ub.queryParam(p.getValue(), encode(p, params[p.getIndex()].toString()));
             }
         }
     }
@@ -269,8 +268,7 @@
         List<Parameter> mx = getParameters(map, ParameterType.MATRIX);
         for (Parameter p : mx) {
             if (params[p.getIndex()] != null) {
-                ub.matrixParam(p.getValue(), 
-                                JAXRSUtils.encode(p.isEncoded(), params[p.getIndex()].toString()));
+                ub.matrixParam(p.getValue(), encode(p, params[p.getIndex()].toString()));
             }
         }
     }
@@ -350,6 +348,17 @@
         
     }
     
+    private static String encode(Parameter p, String value) {
+        if (p.isEncoded()) {
+            return value;
+        }
+        if (p.getType() == ParameterType.PATH || p.getType() == ParameterType.MATRIX) {
+            return HttpUtils.pathEncode(value);
+        } else {
+            return HttpUtils.urlEncode(value); 
+        }
+    }
+    
     private Object doChainedInvocation(URI uri, MultivaluedMap<String, String> headers, 
                           OperationResourceInfo ori, Object[] params, int bodyIndex, 
                           MultivaluedMap<ParameterType, Parameter> types) throws Throwable {
@@ -474,5 +483,6 @@
         }
         
     }
+
     
 }

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=756426&r1=756425&r2=756426&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 Fri Mar 20 12:05:18 2009
@@ -23,6 +23,7 @@
 import javax.ws.rs.core.PathSegment;
 import javax.ws.rs.ext.Provider;
 
+import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 
 @Provider
@@ -35,7 +36,7 @@
     }
     
     public PathSegmentImpl(String path, boolean decode) {
-        this.path = decode ? JAXRSUtils.uriDecode(path) : path;
+        this.path = decode ? HttpUtils.pathDecode(path) : path;
     }
     
     public MultivaluedMap<String, String> getMatrixParameters() {

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java?rev=756426&r1=756425&r2=756426&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java Fri Mar 20 12:05:18 2009
@@ -31,6 +31,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import javax.ws.rs.Path;
 import javax.ws.rs.core.MultivaluedMap;
@@ -39,10 +41,14 @@
 import javax.ws.rs.core.UriBuilderException;
 
 import org.apache.cxf.jaxrs.model.URITemplate;
+import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 
 public class UriBuilderImpl extends UriBuilder {
-
+    
+    private static final Pattern DECODE_PATTERN = Pattern.compile("%[0-9a-fA-F][0-9a-fA-F]");
+    
+    private boolean encode;
     private String scheme;
     private String userInfo;
     private int port;
@@ -70,35 +76,34 @@
 
     @Override
     public URI build() throws UriBuilderException {
-        try {
-            return new URI(scheme, userInfo, host, port, buildPath(), buildQuery(), fragment);
-        } catch (URISyntaxException ex) {
-            throw new UriBuilderException("URI can not be built", ex);
-        }
+        return build(new Object[]{});
     }
 
     @Override
     public URI build(Map<String, Object> map) throws IllegalArgumentException, UriBuilderException {
-        try {
-            String path = buildPath();
-            path = substituteMapped(path, map);
-            return new URI(scheme, userInfo, host, port, path, buildQuery(), fragment);
-        } catch (URISyntaxException ex) {
-            throw new UriBuilderException("URI can not be built", ex);
-        }
+        return buildFromMap(map);
     }
 
     @Override
     public URI build(Object... values) throws IllegalArgumentException, UriBuilderException {
+        if (encode) {
+            for (int i = 0; i < values.length; i++) {
+                values[i] = decodePartiallyEncoded(values[i].toString());
+            }
+        }
+        return doBuild(encode, values);
+    }
+
+    private URI doBuild(boolean fromEncoded, Object... values) {
         try {
-            String path = buildPath();
+            String path = buildPath(fromEncoded);
             path = substituteVarargs(path, values);
             return new URI(scheme, userInfo, host, port, path, buildQuery(), fragment);
         } catch (URISyntaxException ex) {
             throw new UriBuilderException("URI can not be built", ex);
         }
     }
-
+    
     private String substituteVarargs(String path, Object... values) {
         Map<String, String> varValueMap = new HashMap<String, String>();
         URITemplate templ = new URITemplate(path);
@@ -117,6 +122,30 @@
         return templ.substitute(varValueMap);
     }
 
+    private URI buildFromMap(Map<String, ? extends Object> map) throws IllegalArgumentException,
+        UriBuilderException {
+        if (encode) {
+            Map<String, String> decodedMap = new HashMap<String, String>(map.size());
+            for (Map.Entry<String, ? extends Object> entry : map.entrySet()) {
+                decodedMap.put(entry.getKey(), decodePartiallyEncoded(entry.getValue().toString()));
+            }
+            return doBuildFromMap(decodedMap, encode);
+        } else {
+            return doBuildFromMap(map, encode);
+        }
+    }
+
+    private URI doBuildFromMap(Map<String, ? extends Object> map, boolean fromEncoded) 
+        throws IllegalArgumentException, UriBuilderException {
+        try {
+            String path = buildPath(fromEncoded);
+            path = substituteMapped(path, map);
+            return new URI(scheme, userInfo, host, port, path, buildQuery(), fragment);
+        } catch (URISyntaxException ex) {
+            throw new UriBuilderException("URI can not be built", ex);
+        }
+    }
+    
     private String substituteMapped(String path, Map<String, ? extends Object> varValueMap) {
         URITemplate templ = new URITemplate(path);
         Set<String> uniqueVars = new HashSet<String>(templ.getVariables());
@@ -131,14 +160,24 @@
     // CHECKSTYLE:OFF
     @Override
     public UriBuilder clone() {
-        return new UriBuilderImpl(build());
+        UriBuilderImpl builder = new UriBuilderImpl();
+        builder.scheme = scheme;
+        builder.userInfo = userInfo;
+        builder.port = port;
+        builder.host = host;
+        builder.paths = new ArrayList<PathSegment>(paths);
+        builder.fragment = fragment;
+        builder.query = new MetadataMap<String, String>(query);
+        builder.matrix = new MetadataMap<String, String>(matrix);
+        builder.encode = encode;
+        return builder;
     }
 
     // CHECKSTYLE:ON
 
     @Override
     public UriBuilder encode(boolean enable) {
-        //this.encode = enable;
+        this.encode = enable;
         return this;
     }
 
@@ -368,27 +407,46 @@
         }
     }
     
-    private String buildPath() {
+    private String buildPath(boolean fromEncoded) {
         StringBuilder sb = new StringBuilder();
         Iterator<PathSegment> iter = paths.iterator();
         while (iter.hasNext()) {
-            String p = iter.next().getPath();
+            PathSegment ps = iter.next();
+            String p = ps.getPath();
             if (p.length() != 0 || !iter.hasNext()) {
                 if (!p.startsWith("/")) {
                     sb.append('/');
                 }
                 sb.append(p);
+                if (iter.hasNext()) {
+                    buildMatrix(sb, ps.getMatrixParameters(), fromEncoded);
+                }
             }
         }
-        if (!matrix.isEmpty()) {
-            sb.append(';');
-            sb.append(buildParams(matrix, ';'));
-        }
+        buildMatrix(sb, matrix, fromEncoded);
         return sb.toString();
     }
 
     private String buildQuery() {
-        return buildParams(query, '&');
+        return buildParams(query, '&', false);
+    }
+
+    /**
+     * Decode partially encoded string. Decode only values that matches patter "percent char followed by two
+     * hexadecimal digits".
+     * 
+     * @param encoded fully or partially encoded string.
+     * @return decoded string
+     */
+    private String decodePartiallyEncoded(String encoded) {
+        Matcher m = DECODE_PATTERN.matcher(encoded);
+        StringBuffer sb = new StringBuffer();
+        while (m.find()) {
+            String found = m.group();
+            m.appendReplacement(sb, HttpUtils.pathDecode(found));
+        }
+        m.appendTail(sb);
+        return sb.toString();
     }
 
     /**
@@ -396,14 +454,19 @@
      * 
      * @param map query or matrix multivalued map
      * @param separator params separator, '&' for query ';' for matrix
+     * @param fromEncoded if true then values will be decoded 
      * @return stringified params.
      */
-    private String buildParams(MultivaluedMap<String, String> map, char separator) {
+    private String buildParams(MultivaluedMap<String, String> map, char separator,
+                                      boolean fromEncoded) {
         StringBuilder b = new StringBuilder();
         for (Iterator<Map.Entry<String, List<String>>> it = map.entrySet().iterator(); it.hasNext();) {
             Map.Entry<String, List<String>> entry = it.next();
             for (Iterator<String> sit = entry.getValue().iterator(); sit.hasNext();) {
                 String val = sit.next();
+                if (fromEncoded) {
+                    val = decodePartiallyEncoded(val);
+                }
                 b.append(entry.getKey()).append('=').append(val);
                 if (sit.hasNext() || it.hasNext()) {
                     b.append(separator);
@@ -413,5 +476,17 @@
         return b.length() > 0 ? b.toString() : null;
     }
     
-    
+    /**
+     * Builds param string for matrix part of URI.
+     * 
+     * @param sb buffer to add the matrix part to, will get ';' added if map is not empty 
+     * @param map matrix multivalued map
+     */    
+    private void buildMatrix(StringBuilder sb, MultivaluedMap<String, String> map,
+                                    boolean fromEncoded) {
+        if (!map.isEmpty()) {
+            sb.append(';');
+            sb.append(buildParams(map, ';', fromEncoded));
+        }
+    }
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java?rev=756426&r1=756425&r2=756426&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java Fri Mar 20 12:05:18 2009
@@ -122,7 +122,7 @@
             if (entry.getKey().equals(URITemplate.FINAL_MATCH_GROUP)) {
                 continue;
             }
-            values.add(entry.getKey(), decode ? JAXRSUtils.uriDecode(entry.getValue().get(0)) : entry
+            values.add(entry.getKey(), decode ? HttpUtils.pathDecode(entry.getValue().get(0)) : entry
                 .getValue().get(0));
         }
         return values;
@@ -160,7 +160,7 @@
                 for (Path p : paths) {
                     if (p != null) {
                         String v = p.value();
-                        sum += "/" + (decode ? JAXRSUtils.uriDecode(v) : v);
+                        sum += "/" + (decode ? HttpUtils.pathDecode(v) : v);
                     }
                 }
                 UriBuilder ub = UriBuilder.fromPath(sum);
@@ -186,7 +186,7 @@
 
     private String doGetPath(boolean decode, boolean addSlash) {
         String path = HttpUtils.getPathToMatch(message, addSlash);
-        return decode ? JAXRSUtils.uriDecode(path) : path;
+        return decode ? HttpUtils.pathDecode(path) : path;
     }
 
     private String getAbsolutePathAsString() {

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java?rev=756426&r1=756425&r2=756426&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingProvider.java Fri Mar 20 12:05:18 2009
@@ -44,7 +44,7 @@
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.utils.AnnotationUtils;
 import org.apache.cxf.jaxrs.utils.FormUtils;
-import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.multipart.AttachmentUtils;
 
 @ProduceMime("application/x-www-form-urlencoded")
@@ -148,7 +148,8 @@
             for (String value : entry.getValue()) {
                 os.write(entry.getKey().getBytes("UTF-8"));
                 os.write('=');
-                os.write(JAXRSUtils.encode(encoded, value).getBytes("UTF-8"));
+                String data = encoded ? value : HttpUtils.urlEncode(value); 
+                os.write(data.getBytes("UTF-8"));
                 if (it.hasNext()) {
                     os.write('&');
                 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java?rev=756426&r1=756425&r2=756426&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/FormUtils.java Fri Mar 20 12:05:18 2009
@@ -62,7 +62,7 @@
                 if (keyValue.length == 2) {
                     if (decode) {
                         params.add(keyValue[0], 
-                            JAXRSUtils.uriDecode(keyValue[1]));
+                            HttpUtils.urlDecode(keyValue[1]));
                     } else {
                         params.add(keyValue[0], keyValue[1]);
                     }
@@ -86,7 +86,7 @@
             String name = cd.getParameter("name").replace("\"", "").replace("'", "");
             try {
                 String value = IOUtils.toString(a.getDataHandler().getInputStream());
-                params.add(name, decode ? JAXRSUtils.uriDecode(value) : value);
+                params.add(name, decode ? HttpUtils.urlDecode(value) : value);
             } catch (IOException ex) {
                 throw new WebApplicationException(415);
             }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java?rev=756426&r1=756425&r2=756426&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java Fri Mar 20 12:05:18 2009
@@ -19,9 +19,11 @@
 
 package org.apache.cxf.jaxrs.utils;
 
+import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
+import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.List;
 import java.util.Locale;
@@ -32,6 +34,7 @@
 import javax.ws.rs.core.PathSegment;
 import javax.ws.rs.core.Response;
 
+import org.apache.cxf.common.util.UrlUtils;
 import org.apache.cxf.jaxrs.impl.PathSegmentImpl;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.transport.Destination;
@@ -39,6 +42,7 @@
 import org.apache.cxf.transport.servlet.ServletDestination;
 
 public final class HttpUtils {
+    
     private static final String LOCAL_IP_ADDRESS = "127.0.0.1";
     private static final String LOCAL_HOST = "localhost";
     
@@ -46,6 +50,35 @@
     private HttpUtils() {
     }
     
+    public static String urlDecode(String value) {
+        return UrlUtils.urlDecode(value);
+    }
+    
+    public static String pathDecode(String value) {
+        return UrlUtils.pathDecode(value);
+    }
+    
+    public static String urlEncode(String value) {
+            
+        try {
+            value = URLEncoder.encode(value, "UTF-8");
+        } catch (UnsupportedEncodingException ex) {
+            // unlikely to happen
+        }
+        
+        return value;
+    }
+    
+    public static String pathEncode(String value) {
+        
+        String result = urlEncode(value);
+        // URLEncoder will encode '+' to %2B but will turn ' ' into '+'
+        if (result.indexOf('+') != -1) {
+            result = result.replace("+", "%20");
+        }
+        return result;
+    }
+    
     public static SimpleDateFormat getHttpDateFormat() {
         SimpleDateFormat dateFormat = 
             new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);

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=756426&r1=756425&r2=756426&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 Fri Mar 20 12:05:18 2009
@@ -310,10 +310,9 @@
         values = checkPathSegment(values, realType, pathParam);
         List theValues = new ArrayList();
         for (String r : values) {
-            if (decoded) {
-                r = JAXRSUtils.uriDecode(r);
-            }
-            Object o = InjectionUtils.handleParameter(r, realType, pathParam, basePath);
+            String value = decodeValue(r, decoded, pathParam);
+            
+            Object o = InjectionUtils.handleParameter(value, realType, pathParam, basePath);
             if (o != null) {
                 theValues.add(o);
             }
@@ -334,10 +333,8 @@
         
         Set theValues = sorted ? new TreeSet() : new HashSet();
         for (String r : values) {
-            if (decoded) {
-                r = JAXRSUtils.uriDecode(r);
-            }
-            Object o = InjectionUtils.handleParameter(r, realType, pathParam, basePath);
+            String value = decodeValue(r, decoded, pathParam);
+            Object o = InjectionUtils.handleParameter(value, realType, pathParam, basePath);
             if (o != null) {
                 theValues.add(o);
             }
@@ -403,9 +400,7 @@
                                 : paramValues.get(0);
             }
             if (result != null) {
-                if (decoded) {
-                    result = JAXRSUtils.uriDecode(result);
-                }
+                result = decodeValue(result, decoded, pathParam);
                 return InjectionUtils.handleParameter(result, paramType, pathParam, basePath);
             } else {
                 return null;
@@ -528,4 +523,15 @@
             || Boolean.class.isAssignableFrom(type)
             || String.class == type;
     }
+    
+    private static String decodeValue(String value, boolean decode, ParameterType param) {
+        if (!decode) {
+            return value;
+        }
+        if (param == ParameterType.PATH || param == ParameterType.MATRIX) {
+            return HttpUtils.pathDecode(value);
+        } else {
+            return HttpUtils.urlDecode(value);
+        }
+    }
 }

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=756426&r1=756425&r2=756426&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 Fri Mar 20 12:05:18 2009
@@ -21,14 +21,11 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -719,22 +716,21 @@
             List<String> parts = Arrays.asList(query.split(sep));
             for (String part : parts) {
                 String[] values = part.split("=");
-                queries.add(values[0], values.length == 1 ? "" 
-                    : decode ? uriDecode(values[1]) : values[1]);
+                String value = null;
+                if (values.length == 1) {
+                    value = "";
+                } else if (decode) {
+                    value = "&".equals(sep) ? HttpUtils.urlDecode(values[1]) 
+                                            : HttpUtils.pathDecode(values[1]); 
+                } else {
+                    value = values[1];
+                }
+                queries.add(values[0], value);
             }
         }
         return queries;
     }
 
-    public static String uriDecode(String query) {
-        try {
-            query = URLDecoder.decode(query, "UTF-8");
-        } catch (UnsupportedEncodingException e) {
-            //Swallow unsupported decoding exception          
-        }
-        return query;
-    }
-
     @SuppressWarnings("unchecked")
     private static <T> Object readFromMessageBody(Class<T> targetTypeClass,
                                                   Type parameterType,
@@ -930,15 +926,6 @@
         
     }
     
-    public static String encode(boolean encoded, String value) {
-        if (!encoded) {
-            try {
-                value = URLEncoder.encode(value, "UTF-8");
-            } catch (UnsupportedEncodingException ex) {
-                // unlikely to happen
-            }
-        }
-        return value;
-    }
+    
         
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java?rev=756426&r1=756425&r2=756426&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java Fri Mar 20 12:05:18 2009
@@ -121,14 +121,35 @@
         assertEquals("URI is not built correctly", new URI("http://zzz/foo%2525/bar%25"), newUri);
     }
 
-    
+
+    @Test
+    public void testBuildValuesPctEncoded() throws Exception {
+        URI uri = new URI("http://zzz");
+        URI newUri = new UriBuilderImpl(uri).encode(true).path("/{a}/{b}/{c}")
+            .build("foo%25", "bar%", "baz%20");
+        assertEquals("URI is not built correctly", new URI("http://zzz/foo%25/bar%25/baz%20"), newUri);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testBuildFromMapValues() throws Exception {
+        URI uri = new URI("http://zzz");
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("b", "foo");
+        map.put("a", "bar");
+        Map<String, String> immutable = Collections.unmodifiableMap(map);
+        URI newUri = new UriBuilderImpl(uri).path("/{b}/{a}/{b}").build((Map)immutable);
+        assertEquals("URI is not built correctly", new URI("http://zzz/foo/bar/foo"), newUri);
+    }
+
+    @SuppressWarnings("unchecked")
     @Test(expected = IllegalArgumentException.class)
     public void testBuildFromMapMissingValues() throws Exception {
         URI uri = new URI("http://zzz");
         Map<String, String> map = new HashMap<String, String>();
         map.put("b", "foo");
         Map<String, String> immutable = Collections.unmodifiableMap(map);
-        new UriBuilderImpl(uri).path("/{b}/{a}/{b}").build(immutable);
+        new UriBuilderImpl(uri).path("/{b}/{a}/{b}").build((Map)immutable);
     }
 
 
@@ -308,7 +329,14 @@
     }
 
     
+    
     @Test
+    public void testPctEncodedMatrixParam() throws Exception {
+        URI uri = new URI("http://foo/bar");
+        URI newUri = new UriBuilderImpl(uri).matrixParam("p1", "v1%20").encode(true).build();
+        assertEquals("URI is not built correctly", new URI("http://foo/bar;p1=v1%20"), newUri);
+    }
+
     public void testReplaceMatrixParamExisting() throws Exception {
         URI uri = new URI("http://foo/bar;p1=v1");
         URI newUri = new UriBuilderImpl(uri).replaceMatrixParams("p1=nv1").build();
@@ -322,11 +350,6 @@
         assertEquals("URI is not built correctly", new URI("http://foo/bar;p1=nv1;p1=nv2;p2=v2"), newUri);
     }
 
-    @Test
-    public void testMatrixNonFinalPathSegment() throws Exception {
-        URI uri = new URI("http://blah/foo;p1=v1/bar");
-        URI newUri = new UriBuilderImpl(uri).build();
-        assertEquals("URI is not built correctly", new URI("http://blah/foo/bar"), newUri);
-    }
+    
     
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/FormEncodingProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/FormEncodingProviderTest.java?rev=756426&r1=756425&r2=756426&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/FormEncodingProviderTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/FormEncodingProviderTest.java Fri Mar 20 12:05:18 2009
@@ -31,7 +31,7 @@
 import javax.ws.rs.core.MultivaluedMap;
 
 import org.apache.cxf.jaxrs.impl.MetadataMap;
-import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.jaxrs.utils.HttpUtils;
 
 import org.junit.Assert;
 import org.junit.Before;
@@ -121,7 +121,7 @@
         assertEquals(1,  mvMap.get("baz").size());
         assertEquals("Wrong entry for foo", "1 2", mvMap.getFirst("foo"));
         assertEquals("Wrong entry line for bar", 
-            JAXRSUtils.uriDecode("line1%0D%0Aline+2"), mvMap.get("bar").get(0));
+            HttpUtils.urlDecode("line1%0D%0Aline+2"), mvMap.get("bar").get(0));
         assertEquals("Wrong entry for baz", "4", mvMap.getFirst("baz"));
 
     }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/HttpUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/HttpUtilsTest.java?rev=756426&r1=756425&r2=756426&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/HttpUtilsTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/HttpUtilsTest.java Fri Mar 20 12:05:18 2009
@@ -31,6 +31,31 @@
 public class HttpUtilsTest extends Assert {
 
     @Test
+    public void testUrlDecode() {
+        assertEquals("+ ", HttpUtils.urlDecode("%2B+"));
+    }
+    
+    @Test
+    public void testUrlEncode() {
+        assertEquals("%2B+", HttpUtils.urlEncode("+ "));
+    }
+     
+    @Test
+    public void testPathEncode() {
+        assertEquals("%2B%20", HttpUtils.pathEncode("+ "));
+    }
+    
+    @Test
+    public void testUrlDecodeReserved() {
+        assertEquals("!$&'()*,;=", HttpUtils.urlDecode("!$&'()*,;="));
+    }
+    
+    @Test
+    public void testPathDecode() {
+        assertEquals("+++", HttpUtils.pathDecode("+%2B+"));
+    }
+    
+    @Test
     public void testPathToMatch() {
         assertEquals("/", HttpUtils.getPathToMatch("/", "/", true));
         assertEquals("/", HttpUtils.getPathToMatch("/", "/bar", true));

Modified: cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java?rev=756426&r1=756425&r2=756426&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java (original)
+++ cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java Fri Mar 20 12:05:18 2009
@@ -21,7 +21,6 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.net.URL;
-import java.net.URLDecoder;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.LinkedList;
@@ -39,6 +38,7 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.common.util.UrlUtils;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.OperationInfo;
@@ -307,15 +307,16 @@
         //fix for CXF-898
         if (!"/".equals(pathInfo) || reqPrefix.endsWith("/")) {
             // needs to be done given that pathInfo is decoded
-            // TODO :
-            // it's unlikely servlet path will contain encoded values so we're most likely safe
-            // however we need to ensure if it happens then thsi code works propely too
-            try {
-                reqPrefix = URLDecoder.decode(reqPrefix, "UTF-8");
-            } catch (Exception ex) {
-                // unlikey to happen
+            // TODO : it's unlikely servlet path will contain encoded values so we're most 
+            // likely safe however we need to ensure if it happens then this code works properly too
+            reqPrefix = UrlUtils.pathDecode(reqPrefix);
+            // pathInfo drops matrix parameters attached to a last path segment
+            int offset = 0;
+            int index = reqPrefix.lastIndexOf(';');
+            if (index >= pathInfo.length()) {
+                offset = reqPrefix.length() - index;
             }
-            reqPrefix = reqPrefix.substring(0, reqPrefix.length() - pathInfo.length());
+            reqPrefix = reqPrefix.substring(0, reqPrefix.length() - pathInfo.length() - offset);
         }
         return reqPrefix;
     }

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java?rev=756426&r1=756425&r2=756426&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java Fri Mar 20 12:05:18 2009
@@ -23,6 +23,7 @@
 import javax.ws.rs.CookieParam;
 import javax.ws.rs.GET;
 import javax.ws.rs.HeaderParam;
+import javax.ws.rs.MatrixParam;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
@@ -45,7 +46,7 @@
     @ProduceMime("application/xml")
     Book getTheBook2(@PathParam("n1") String name1,
                      @QueryParam("n2") String name2,
-                     @QueryParam("n3") String name3,
+                     @MatrixParam("n3") String name3,
                      @HeaderParam("N4") String name4,
                      @CookieParam("n5") String name5,
                      String name6) throws BookNotFoundFault;

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java?rev=756426&r1=756425&r2=756426&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java Fri Mar 20 12:05:18 2009
@@ -94,6 +94,13 @@
     }
     
     @Test
+    public void testGetBookWithEncodedPathValue2() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/the/bookstore/id=12+3"; 
+        getBook(endpointAddress, "resources/expected_get_book123json.txt"); 
+    }
+    
+    @Test
     public void testGetDefaultBook() throws Exception {
         String endpointAddress =
             "http://localhost:9080/the/bookstore"; 

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java?rev=756426&r1=756425&r2=756426&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java Fri Mar 20 12:05:18 2009
@@ -105,7 +105,7 @@
         WebClient client = WebClient.create(baseAddress);
         client.path("/bookstore/123").accept(MediaType.APPLICATION_XML_TYPE);
         Book b = client.get(Book.class);
-        assertEquals(123, b.getId());
+        assertEquals(123L, b.getId());
         assertEquals("CXF in Action", b.getName());
     }
     



Mime
View raw message