use of org.springframework.data.rest.webmvc.IncomingRequest in project CzechIdMng by bcvsolutions.
the class RequestResourceResolver method resolve.
@SuppressWarnings({ "unchecked", "rawtypes" })
public <T> T resolve(HttpServletRequest nativeRequest, Class<T> domainType, T objectToUpdate) throws HttpMessageNotReadableException {
ServletServerHttpRequest request = new ServletServerHttpRequest(nativeRequest);
IncomingRequest incoming = new IncomingRequest(request);
MediaType contentType = request.getHeaders().getContentType();
for (HttpMessageConverter converter : messageConverters) {
if (!converter.canRead(PersistentEntityResource.class, contentType)) {
continue;
}
T obj = (T) read(domainType, incoming, converter, objectToUpdate);
if (obj == null) {
throw new HttpMessageNotReadableException(String.format(ERROR_MESSAGE, domainType));
}
return obj;
}
throw new HttpMessageNotReadableException(String.format(NO_CONVERTER_FOUND, domainType, contentType));
}
Aggregations