cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dieter Freismuth (JIRA)" <j...@apache.org>
Subject [jira] Created: (CXF-2698) REST type conversion to Byte, Integer, ... (non primitives) not working
Date Mon, 08 Mar 2010 14:50:27 GMT
REST type conversion to Byte, Integer, ... (non primitives) not working
-----------------------------------------------------------------------

                 Key: CXF-2698
                 URL: https://issues.apache.org/jira/browse/CXF-2698
             Project: CXF
          Issue Type: Bug
          Components: JAX-WS Runtime
    Affects Versions: 2.2.5
         Environment: using JAXD Databinding, JAX-WS with REST 
            Reporter: Dieter Freismuth


methods like 
public String sayHi(@WebParam(name="number") Byte number)
taking java.lang.Number can not be called via REST HTTP GET methods since there is not type
conversion from String to Byte.
This works using primitive types like byte!

The root cause can be found at the end of URIMappingInterceptor.getParameters(...) method:
           
if (type != null && type.isPrimitive() && queries.get(key) != null) {
  param = PrimitiveUtils.read(queries.get(key), type);
} else {
  param = queries.get(key);
}

either PrimitiveUtils.read(..) should also work for Integer, Byte,.. types or there should
be an extra method like:
         public Object readNullableTypes(String value, Class type) {
            Object ret = value;
            if (Integer.class == type) {
                ret = Integer.valueOf(value);
            }
            if (Byte.class == type) {
                ret = Byte.valueOf(value);
            }
            if (Short.class == type) {
                ret = Short.valueOf(value);
            }
            if (Long.class == type) {
                ret = Long.valueOf(value);
            }
            if (Float.class == type) {
                ret = Float.valueOf(value);
            }
            if (Double.class == type) {
                ret = Double.valueOf(value);
            }
            if (Boolean.class == type) {
                ret = Boolean.valueOf(value);
            }
            if (Character.class == type) {
                ret = value.charAt(0);
            }
            return ret;
        }


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message