You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2013/07/10 18:00:33 UTC
svn commit: r1501814 - in /cxf/branches/2.7.x-fixes: ./
rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/
systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Author: sergeyb
Date: Wed Jul 10 16:00:32 2013
New Revision: 1501814
URL: http://svn.apache.org/r1501814
Log:
Merged revisions 1501756 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1501756 | sergeyb | 2013-07-10 14:12:01 +0100 (Wed, 10 Jul 2013) | 1 line
[CXF-5108] Ignoring Maps with complex values and better support for Maps with simple values when dealing with parameter extensions
........
Added:
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookBean.java
- copied unchanged from r1501756, cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookBean.java
Modified:
cxf/branches/2.7.x-fixes/ (props changed)
cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresourceImpl.java
cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Merged /cxf/trunk:r1501756
Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=1501814&r1=1501813&r2=1501814&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java (original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java Wed Jul 10 16:00:32 2013
@@ -613,23 +613,41 @@ public final class InjectionUtils {
ParameterType pathParam, Message message) {
// CHECKSTYLE:ON
ParameterizedType paramType = (ParameterizedType) genericType;
- ParameterizedType valueParamType = (ParameterizedType) InjectionUtils
- .getType(paramType.getActualTypeArguments(), 1);
- Class<?> valueType = (Class<?>) InjectionUtils.getType(valueParamType
- .getActualTypeArguments(), 0);
-
- MultivaluedMap<String, Object> theValues = new MetadataMap<String, Object>();
-
- Set<Map.Entry<String, List<String>>> processedValuesEntrySet = processedValues.entrySet();
- for (Map.Entry<String, List<String>> processedValuesEntry : processedValuesEntrySet) {
- List<String> valuesList = processedValuesEntry.getValue();
- for (String value : valuesList) {
- Object o = InjectionUtils.handleParameter(value,
- decoded, valueType, paramAnns, pathParam, message);
- theValues.add(processedValuesEntry.getKey(), o);
+ Class<?> keyType = (Class<?>)paramType.getActualTypeArguments()[0];
+ Type secondType = InjectionUtils.getType(paramType.getActualTypeArguments(), 1);
+
+ if (secondType instanceof ParameterizedType) {
+ MultivaluedMap<Object, Object> theValues = new MetadataMap<Object, Object>();
+ ParameterizedType valueParamType = (ParameterizedType) secondType;
+ Class<?> valueType = (Class<?>) InjectionUtils.getType(valueParamType
+ .getActualTypeArguments(), 0);
+
+ for (Map.Entry<String, List<String>> processedValuesEntry : processedValues.entrySet()) {
+ List<String> valuesList = processedValuesEntry.getValue();
+ for (String value : valuesList) {
+ Object o = InjectionUtils.handleParameter(value,
+ decoded, valueType, paramAnns, pathParam, message);
+ theValues.add(convertStringToPrimitive(processedValuesEntry.getKey(), keyType), o);
+ }
+ }
+ return theValues;
+ } else {
+ Map<Object, Object> theValues = new HashMap<Object, Object>();
+ Class<?> valueType =
+ (Class<?>) InjectionUtils.getType(paramType.getActualTypeArguments(), 1);
+ for (Map.Entry<String, List<String>> processedValuesEntry : processedValues.entrySet()) {
+ List<String> valuesList = processedValuesEntry.getValue();
+ for (String value : valuesList) {
+ Object o = InjectionUtils.handleParameter(value,
+ decoded, valueType, paramAnns, pathParam, message);
+ theValues.put(
+ convertStringToPrimitive(processedValuesEntry.getKey(), keyType),
+ o);
+ }
}
+ return theValues;
}
- return theValues;
+
}
@@ -640,19 +658,25 @@ public final class InjectionUtils {
if (paramType.getActualTypeArguments().length == 2) {
Class<?> firstType = getRawType(getType(paramType.getActualTypeArguments(), 0));
Type secondType = getType(paramType.getActualTypeArguments(), 1);
- if (secondType instanceof ParameterizedType) {
- Class<?> secondRawType = getRawType(secondType);
- if (String.class == firstType && List.class.isAssignableFrom(secondRawType)) {
- Class<?> listtype = getRawType(
- getType(((ParameterizedType)secondType).getActualTypeArguments(), 0));
- return InjectionUtils.isPrimitive(listtype);
- }
- }
+ Class<?> secondRawType = getRawType(secondType);
+
+ return InjectionUtils.isPrimitive(firstType)
+ && (InjectionUtils.isPrimitive(secondRawType)
+ || allowedMapListValue(secondRawType, secondType));
}
}
return false;
}
+ private static boolean allowedMapListValue(Class<?> cls, Type type) {
+ if (List.class.isAssignableFrom(cls)) {
+ Class<?> listtype = getRawType(
+ getType(((ParameterizedType)type).getActualTypeArguments(), 0));
+ return InjectionUtils.isPrimitive(listtype);
+ }
+ return false;
+ }
+
private static List<MultivaluedMap<String, String>> processValues(Class<?> type, Type genericType,
MultivaluedMap<String, String> values,
boolean isbean) {
@@ -1074,6 +1098,14 @@ public final class InjectionUtils {
theValues = CastUtils.cast((List<?>)value);
}
values.put(propertyName, theValues);
+ } else if (Map.class.isAssignableFrom(value.getClass())) {
+ if (isSupportedMap(m.getGenericReturnType())) {
+ Map<Object, Object> map = CastUtils.cast((Map<?, ?>)value);
+ for (Map.Entry<Object, Object> entry : map.entrySet()) {
+ values.add(propertyName + "." + entry.getKey().toString(),
+ entry.getValue().toString());
+ }
+ }
} else {
fillInValuesFromBean(value, propertyName, values);
}
Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java?rev=1501814&r1=1501813&r2=1501814&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java (original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.java Wed Jul 10 16:00:32 2013
@@ -94,7 +94,7 @@ public interface BookSubresource {
@GET
@Path("/thebook5")
@Produces("application/xml")
- Book getTheBookQueryBean(@QueryParam("") Book book) throws BookNotFoundFault;
+ BookBean getTheBookQueryBean(@QueryParam("") BookBean book) throws BookNotFoundFault;
}
Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresourceImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresourceImpl.java?rev=1501814&r1=1501813&r2=1501814&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresourceImpl.java (original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresourceImpl.java Wed Jul 10 16:00:32 2013
@@ -20,6 +20,7 @@
package org.apache.cxf.systest.jaxrs;
import java.util.List;
+import java.util.Map;
import javax.ws.rs.core.UriInfo;
@@ -111,8 +112,15 @@ public class BookSubresourceImpl impleme
return new Book(name, bookid);
}
- public Book getTheBookQueryBean(Book book) throws BookNotFoundFault {
- return book;
+ public BookBean getTheBookQueryBean(BookBean book) throws BookNotFoundFault {
+ Map<Long, String> comments = book.getComments();
+ String comment1 = comments.get(1L);
+ String comment2 = comments.get(2L);
+ if ("Good".equals(comment1) && "Good".equals(comment2)) {
+ return book;
+ } else {
+ return null;
+ }
}
}
Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java?rev=1501814&r1=1501813&r2=1501814&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java (original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java Wed Jul 10 16:00:32 2013
@@ -548,8 +548,10 @@ public class JAXRSSoapBookTest extends A
BookStoreJaxrsJaxws.class);
WebClient.getConfig(proxy).getOutInterceptors().add(new LoggingOutInterceptor());
BookSubresource bs = proxy.getBookSubresource("139");
- Book bean = new Book("CXF Rocks", 139L);
- Book b = bs.getTheBookQueryBean(bean);
+ BookBean bean = new BookBean("CXF Rocks", 139L);
+ bean.getComments().put(1L, "Good");
+ bean.getComments().put(2L, "Good");
+ BookBean b = bs.getTheBookQueryBean(bean);
assertEquals(139, b.getId());
assertEquals("CXF Rocks", b.getName());
}