}
if (!value.startsWith(ProtocolConstants.INBOUND_MAP_START) || !value.endsWith(ProtocolConstants.INBOUND_MAP_END))
{
log.warn("Expected object while converting data for " + paramType.getName() + " in " + data.getContext().getCurrentProperty() + ". Passed: " + value);
throw new ConversionException(paramType, "Data conversion error. See logs for more details.");
}
value = value.substring(1, value.length() - 1);
try
{
if (instanceType != null)
{
LocalUtil.classForName(instanceType.getName());
}
else
{
LocalUtil.classForName(paramType.getName());
}
Class<?>[] innerClasses = paramType.getClasses();
Class<?> factory = null;
for (Class<?> aClass : innerClasses)
{
if (aClass.getName().endsWith("Factory"))
{
factory = aClass;
}
}
if (factory == null)
{
log.error("XmlObject.Factory method not found for Class [" + paramType.toString() + "]");
throw new ConversionException(paramType, "XmlObject.Factory method not found");
}
Class<?>[] emptyArglist = new Class[0];
Method newInstance = factory.getMethod("newInstance", emptyArglist);
Object bean = newInstance.invoke(null, (Object[]) emptyArglist);
if (instanceType != null)
{
data.getContext().addConverted(data, instanceType, bean);
}
else
{
data.getContext().addConverted(data, paramType, bean);
}
Map<String, Property> properties = getPropertyMapFromClass(paramType, false, true);
// Loop through the properties passed in
Map<String, String> tokens = extractInboundTokens(paramType, value);
for (Entry<String, String> entry : tokens.entrySet())
{
String key = entry.getKey();
String val = entry.getValue();
log.debug("token entry (" + key + ") with value (" + val + ")");
Property property = properties.get(key);
if (property == null)
{
log.warn("Missing java bean property to match javascript property: " + key + ". For causes see debug level logs:");
log.debug("- The javascript may be refer to a property that does not exist");
log.debug("- You may be missing the correct setter: set" + Character.toTitleCase(key.charAt(0)) + key.substring(1) + "()");
log.debug("- The property may be excluded using include or exclude rules.");
StringBuffer all = new StringBuffer();
for (Iterator<String> pit = properties.keySet().iterator(); pit.hasNext();)
{
all.append(pit.next());
if (pit.hasNext())
{
all.append(',');
}
}
log.debug("Fields exist for (" + all + ").");
continue;
}
Class<?> propType = property.getPropertyType();
Object output = convert(val, propType, data.getContext(), property);
property.setValue(bean, output);
}
return bean;
}
catch (ConversionException ex)
{
throw ex;
}
catch (Exception ex)
{
throw new ConversionException(paramType, ex);
}
}