use of io.vertigo.vega.engines.webservice.json.UiContext in project vertigo by KleeGroup.
the class DtListJsonConverter method populateWebServiceCallContext.
/**
* {@inheritDoc}
*/
@Override
public void populateWebServiceCallContext(final Object input, final WebServiceParam webServiceParam, final WebServiceCallContext routeContext) {
final Class<?> paramClass = webServiceParam.getType();
Assertion.checkArgument(DtList.class.isAssignableFrom(paramClass), "This JsonConverter can't read the asked type {0}. Only {1} is supported", paramClass.getSimpleName(), DtList.class.getSimpleName());
Assertion.checkArgument(getSupportedInputs()[0].isInstance(input) || getSupportedInputs()[1].isInstance(input), "This JsonConverter doesn't support this input type {0}. Only {1} is supported", input.getClass().getSimpleName(), Arrays.toString(getSupportedInputs()));
// -----
final Type paramGenericType = webServiceParam.getGenericType();
final String objectPath;
final UiListModifiable<DtObject> uiList;
if (input instanceof String) {
uiList = jsonReaderEngine.uiListFromJson((String) input, paramGenericType);
objectPath = "";
} else if (input instanceof UiContext) {
uiList = (UiListModifiable<DtObject>) ((UiContext) input).get(webServiceParam.getName());
Assertion.checkNotNull(uiList, "InnerParam not found : {0}", webServiceParam);
objectPath = webServiceParam.getName();
} else {
throw new IllegalArgumentException(String.format("This JsonConverter can't read the asked type %s. Only %s is supported", paramClass.getSimpleName(), UiListDelta.class.getSimpleName()));
}
// -----
UiObjectUtil.postReadUiList(uiList, objectPath, webServiceParam);
routeContext.setParamValue(webServiceParam, uiList);
}
Aggregations