Example usage for org.springframework.web HttpMediaTypeNotSupportedException getContentType

List of usage examples for org.springframework.web HttpMediaTypeNotSupportedException getContentType

Introduction

In this page you can find the example usage for org.springframework.web HttpMediaTypeNotSupportedException getContentType.

Prototype

@Nullable
public MediaType getContentType() 

Source Link

Document

Return the HTTP request content type method that caused the failure.

Usage

From source file:business.CustomResponseEntityExceptionHandler.java

@Override
protected ResponseEntity<Object> handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex,
        HttpHeaders headers, HttpStatus status, WebRequest request) {
    String unsupported = "Unsupported content type: " + ex.getContentType();
    String supported = "Supported content types: " + MediaType.toString(ex.getSupportedMediaTypes());
    ErrorMessage errorMessage = new ErrorMessage(unsupported, supported);
    return new ResponseEntity<Object>(errorMessage, headers, status);
}

From source file:com.garyclayburg.persistence.repository.CustomResponseEntityExceptionHandler.java

@Override
protected ResponseEntity<Object> handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex,
        HttpHeaders headers, HttpStatus status, WebRequest request) {
    String unsupported = "Unsupported content type: " + ex.getContentType();
    String supported = "Supported content types: " + MediaType.toString(ex.getSupportedMediaTypes());
    ErrorMessage errorMessage = new ErrorMessage(unsupported, supported);
    return new ResponseEntity(errorMessage, headers, status);
}

From source file:com.ns.retailmgr.controller.exception.RestControllerExceptionHandler.java

@Override
protected ResponseEntity<Object> handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex,
        HttpHeaders headers, HttpStatus status, WebRequest request) {
    String unsupported = "Unsupported content type: " + ex.getContentType();
    String supported = "Supported content types: " + MediaType.toString(ex.getSupportedMediaTypes());
    RestErrorMessage RestErrorMessage = new RestErrorMessage(unsupported, supported);
    return new ResponseEntity(RestErrorMessage, headers, status);
}

From source file:br.com.modoagil.asr.rest.support.RESTErrorHandler.java

/**
 * Manipula exceo para status HTTP {@code 415}
 *
 * @param ex/*  w ww. j a  v a 2s .  c om*/
 *            {@link HttpMediaTypeNotSupportedException}
 * @return resposta ao cliente
 */
@ResponseBody
@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
public Response<E> processHttpMediaTypeNotSupportedException(final HttpMediaTypeNotSupportedException ex) {
    this.logger.info("handleHttpMediaTypeNotSupportedException - Catching: " + ex.getClass().getSimpleName(),
            ex);
    return new ResponseBuilder<E>().success(false).message(ex.getContentType().getType() + " not supported")
            .status(HttpStatus.UNSUPPORTED_MEDIA_TYPE).build();
}