You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2010/09/16 21:59:15 UTC
svn commit: r997902 - in /cxf/branches/2.2.x-fixes: ./
rt/core/src/main/java/org/apache/cxf/interceptor/
systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/httpget/
Author: dkulp
Date: Thu Sep 16 19:59:14 2010
New Revision: 997902
URL: http://svn.apache.org/viewvc?rev=997902&view=rev
Log:
Merged revisions 997893 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r997893 | dkulp | 2010-09-16 15:46:08 -0400 (Thu, 16 Sep 2010) | 2 lines
[CXF-2996] Fix GET requests for enums, dates, and nulls
Patch from Christian Hvid applied.
........
Added:
cxf/branches/2.2.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/httpget/
- copied from r997893, cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/httpget/
cxf/branches/2.2.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/httpget/JavaFirstHttpGetTest.java
- copied unchanged from r997893, cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/httpget/JavaFirstHttpGetTest.java
cxf/branches/2.2.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/httpget/MyEnum.java
- copied unchanged from r997893, cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/httpget/MyEnum.java
cxf/branches/2.2.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/httpget/MyImplementation.java
- copied unchanged from r997893, cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/httpget/MyImplementation.java
cxf/branches/2.2.x-fixes/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/httpget/MyInterface.java
- copied unchanged from r997893, cxf/trunk/systests/jaxws/src/test/java/org/apache/cxf/systest/jaxws/httpget/MyInterface.java
Modified:
cxf/branches/2.2.x-fixes/ (props changed)
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/URIMappingInterceptor.java
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/URIMappingInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/URIMappingInterceptor.java?rev=997902&r1=997901&r2=997902&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/URIMappingInterceptor.java (original)
+++ cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/URIMappingInterceptor.java Thu Sep 16 19:59:14 2010
@@ -20,10 +20,15 @@
package org.apache.cxf.interceptor;
import java.io.UnsupportedEncodingException;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URLDecoder;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.Arrays;
+import java.util.Calendar;
import java.util.Collection;
+import java.util.Date;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
@@ -231,9 +236,40 @@ public class URIMappingInterceptor exten
}
return parameters;
}
+
+ private Date parseDate(String value, Class<?> type) {
+ SimpleDateFormat sdf;
+
+ if (value.length() == 10) {
+ sdf = new SimpleDateFormat("yyyy-MM-dd");
+ } else if (value.length() == 19) {
+ sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
+ } else if (value.length() == 23) {
+ sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
+ } else if (value.length() == 25) {
+ value = value.substring(0, value.length() - 3)
+ + value.substring(value.length() - 2, value.length());
+ sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZZZZ");
+ } else if (value.length() == 29) {
+ value = value.substring(0, value.length() - 3)
+ + value.substring(value.length() - 2, value.length());
+ sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ");
+ } else {
+ throw new RuntimeException("Unable to create " + type + " out of '" + value + "'");
+ }
+ try {
+ return sdf.parse(value);
+ } catch (ParseException e) {
+ throw new RuntimeException("Unable to create " + type + " out of '" + value + "'");
+ }
+ }
+
private Object readType(String value, Class<?> type) {
Object ret = value;
- if (Integer.class == type) {
+
+ if (value == null) {
+ // let null be null regardless of target type
+ } else if (Integer.class == type) {
ret = Integer.valueOf(value);
} else if (Byte.class == type) {
ret = Byte.valueOf(value);
@@ -248,7 +284,22 @@ public class URIMappingInterceptor exten
} else if (Boolean.class == type) {
ret = Boolean.valueOf(value);
} else if (Character.class == type) {
- ret = value.charAt(0);
+ ret = value.charAt(0);
+ } else if (type != null && type.isEnum()) {
+ try {
+ ret = type.getMethod("valueOf", String.class).invoke(null, value);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("Unable to create " + type + " out of '" + value + "'");
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException("Unable to create " + type + " out of '" + value + "'");
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException("Unable to create " + type + " out of '" + value + "'");
+ }
+ } else if (java.util.Date.class == type) {
+ ret = parseDate(value, type);
+ } else if (Calendar.class == type) {
+ ret = Calendar.getInstance();
+ ((Calendar)ret).setTime(parseDate(value, type));
}
return ret;
}