@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
RootResourceInformation resourceInformation = resourceInformationResolver.resolveArgument(parameter, mavContainer,
webRequest, binderFactory);
HttpServletRequest nativeRequest = webRequest.getNativeRequest(HttpServletRequest.class);
ServletServerHttpRequest request = new ServletServerHttpRequest(nativeRequest);
IncomingRequest incoming = new IncomingRequest(request);
Class<?> domainType = resourceInformation.getDomainType();
MediaType contentType = request.getHeaders().getContentType();
for (HttpMessageConverter converter : messageConverters) {
if (!converter.canRead(PersistentEntityResource.class, contentType)) {
continue;
}
Serializable id = idResolver.resolveArgument(parameter, mavContainer, webRequest, binderFactory);
Object obj = read(resourceInformation, incoming, converter, id);
if (obj == null) {
throw new HttpMessageNotReadableException(String.format(ERROR_MESSAGE, domainType));
}
return PersistentEntityResource.build(obj, resourceInformation.getPersistentEntity()).build();
}
throw new HttpMessageNotReadableException(String.format(NO_CONVERTER_FOUND, domainType, contentType));
}