use of io.crnk.client.ResponseBodyException in project crnk-framework by crnk-project.
the class ClientResourceUpsert method setLinks.
protected void setLinks(Resource dataBody, Object instance, ResourceInformation resourceInformation) {
ResourceField linksField = resourceInformation.getLinksField();
if (dataBody.getLinks() != null && linksField != null) {
JsonNode linksNode = dataBody.getLinks();
Class<?> linksClass = linksField.getType();
ObjectReader linksMapper = objectMapper.readerFor(linksClass);
try {
Object links = linksMapper.readValue(linksNode);
linksField.getAccessor().setValue(instance, links);
} catch (IOException e) {
throw new ResponseBodyException("failed to parse links information", e);
}
}
}
use of io.crnk.client.ResponseBodyException in project crnk-framework by crnk-project.
the class ClientResourceUpsert method setMeta.
protected void setMeta(Resource dataBody, Object instance, ResourceInformation resourceInformation) {
ResourceField metaField = resourceInformation.getMetaField();
if (dataBody.getMeta() != null && metaField != null) {
JsonNode metaNode = dataBody.getMeta();
Class<?> metaClass = metaField.getType();
ObjectReader metaMapper = objectMapper.readerFor(metaClass);
try {
Object meta = metaMapper.readValue(metaNode);
metaField.getAccessor().setValue(instance, meta);
} catch (IOException e) {
throw new ResponseBodyException("failed to parse links information", e);
}
}
}
Aggregations