CcmNG: Fix

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5664 8810af33-2d31-482b-a856-94f89814c4df
ccm-docs
jensp 2018-08-08 17:18:28 +00:00
parent 50ccf39227
commit 997644d119
1 changed files with 33 additions and 20 deletions

View File

@ -296,11 +296,12 @@ public class Components {
final ComponentModel componentModel) {
final Class<? extends ComponentModel> clazz = Objects
.requireNonNull(componentModel.getClass());
.requireNonNull(componentModel)
.getClass();
final ComponentModelJsonConverter jsonConverter
= findJsonConverter(clazz)
.orElseThrow(() -> new WebApplicationException(String.format(
= findJsonConverter(clazz)
.orElseThrow(() -> new WebApplicationException(String.format(
"No JSON converter available for component model \"%s\".",
clazz.getName())));
@ -394,9 +395,9 @@ public class Components {
try {
componentModel = clazz.getConstructor().newInstance();
} catch (IllegalAccessException
| InstantiationException
| InvocationTargetException
| NoSuchMethodException ex) {
| InstantiationException
| InvocationTargetException
| NoSuchMethodException ex) {
throw new WebApplicationException(ex);
}
@ -453,19 +454,31 @@ public class Components {
final JsonObject data,
final ComponentModel componentModel) {
final BeanInfo beanInfo;
try {
beanInfo = Introspector.getBeanInfo(componentModel.getClass());
} catch (IntrospectionException ex) {
throw new WebApplicationException(ex);
}
final Class<? extends ComponentModel> clazz = Objects
.requireNonNull(componentModel)
.getClass();
Arrays
.stream(beanInfo.getPropertyDescriptors())
.forEach(
propertyDesc -> setComponentPropertyFromJson(componentModel,
propertyDesc,
data));
final ComponentModelJsonConverter jsonConverter
= findJsonConverter(clazz)
.orElseThrow(() -> new WebApplicationException(String.format(
"No JSON converter available for component model \"%s\".",
clazz.getName())));
jsonConverter.fromJson(data, componentModel);
// final BeanInfo beanInfo;
// try {
// beanInfo = Introspector.getBeanInfo(componentModel.getClass());
// } catch (IntrospectionException ex) {
// throw new WebApplicationException(ex);
// }
//
// Arrays
// .stream(beanInfo.getPropertyDescriptors())
// .forEach(
// propertyDesc -> setComponentPropertyFromJson(componentModel,
// propertyDesc,
// data));
}
/**
@ -561,7 +574,7 @@ public class Components {
}
} catch (IllegalAccessException
| InvocationTargetException ex) {
| InvocationTargetException ex) {
throw new WebApplicationException(ex);
}
}