Package org.springframework.data.rest.webmvc

Examples of org.springframework.data.rest.webmvc.RootResourceInformation


    Class<?> domainType = resourceMetadata.getDomainType();
    RepositoryInvoker repositoryInvoker = invokerFactory.getInvokerFor(domainType);
    PersistentEntity<?, ?> persistentEntity = repositories.getPersistentEntity(domainType);

    // TODO reject if ResourceMetadata cannot be resolved
    return new RootResourceInformation(resourceMetadata, persistentEntity, repositoryInvoker);
  }
View Full Code Here


  @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));
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.rest.webmvc.RootResourceInformation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.