Package org.springframework.web

Examples of org.springframework.web.HttpMediaTypeNotSupportedException


      String paramName = methodParam.getParameterName();
      if (paramName != null) {
        builder.append(' ');
        builder.append(paramName);
      }
      throw new HttpMediaTypeNotSupportedException(
          "Cannot extract parameter (" + builder.toString() + "): no Content-Type found");
    }

    List<MediaType> allSupportedMediaTypes = new ArrayList<MediaType>();
    if (this.messageConverters != null) {
      for (HttpMessageConverter<?> messageConverter : this.messageConverters) {
        allSupportedMediaTypes.addAll(messageConverter.getSupportedMediaTypes());
        if (messageConverter.canRead(paramType, contentType)) {
          if (logger.isDebugEnabled()) {
            logger.debug("Reading [" + paramType.getName() + "] as \"" + contentType
                +"\" using [" + messageConverter + "]");
          }
          return messageConverter.read(paramType, inputMessage);
        }
      }
    }
    throw new HttpMediaTypeNotSupportedException(contentType, allSupportedMediaTypes);
  }
View Full Code Here


            }
            return ((HttpMessageConverter<T>) messageConverter).read(paramType, inputMessage);
          }
        }
     
        throw new HttpMediaTypeNotSupportedException(contentType, allSupportedMediaTypes);
      }
View Full Code Here

    else if (!consumableMediaTypes.isEmpty()) {
      MediaType contentType = null;
      if (StringUtils.hasLength(request.getContentType())) {
        contentType = MediaType.parseMediaType(request.getContentType());
      }
      throw new HttpMediaTypeNotSupportedException(contentType, new ArrayList<MediaType>(consumableMediaTypes));
    }
    else if (!producibleMediaTypes.isEmpty()) {
      throw new HttpMediaTypeNotAcceptableException(new ArrayList<MediaType>(producibleMediaTypes));
    }
    else {
View Full Code Here

            MediaType.parseMediaType(request.getContentType()) :
            MediaType.APPLICATION_OCTET_STREAM;
            return getMediaType().includes(contentType);
      }
      catch (IllegalArgumentException ex) {
        throw new HttpMediaTypeNotSupportedException(
            "Can't parse Content-Type [" + request.getContentType() + "]: " + ex.getMessage());
      }
    }
View Full Code Here

    if (!consumableMediaTypes.isEmpty()) {
      MediaType contentType = null;
      if (StringUtils.hasLength(request.getContentType())) {
        contentType = MediaType.parseMediaType(request.getContentType());
      }
      throw new HttpMediaTypeNotSupportedException(contentType, new ArrayList<MediaType>(consumableMediaTypes));
    }
    else if (!producibleMediaTypes.isEmpty()) {
      throw new HttpMediaTypeNotAcceptableException(new ArrayList<MediaType>(producibleMediaTypes));
    }
    else {
View Full Code Here

              return ((HttpMessageConverter<T>) converter).read(targetClass, inputMessage);
            }
          }
        }

        throw new HttpMediaTypeNotSupportedException(contentType, allSupportedMediaTypes);
      }
View Full Code Here

  /********** Exception 6 ***************/
  @RequestMapping(value = "http/exception6", method = RequestMethod.GET)
  public String exception6() throws HttpMediaTypeNotSupportedException
  {
    throw new HttpMediaTypeNotSupportedException("Test for DefaultHandlerExceptionResolver");
  }
View Full Code Here

    MediaType contentType;
    try {
      contentType = inputMessage.getHeaders().getContentType();
    }
    catch (InvalidMediaTypeException ex) {
      throw new HttpMediaTypeNotSupportedException(ex.getMessage());
    }
    if (contentType == null) {
      contentType = MediaType.APPLICATION_OCTET_STREAM;
    }

    Class<?> contextClass = methodParam.getContainingClass();

    for (HttpMessageConverter<?> converter : this.messageConverters) {
      if (converter instanceof GenericHttpMessageConverter) {
        GenericHttpMessageConverter<?> genericConverter = (GenericHttpMessageConverter<?>) converter;
        if (genericConverter.canRead(targetType, contextClass, contentType)) {
          if (logger.isDebugEnabled()) {
            logger.debug("Reading [" + targetType + "] as \"" +
                contentType + "\" using [" + converter + "]");
          }
          return genericConverter.read(targetType, contextClass, inputMessage);
        }
      }
      Class<T> targetClass = (Class<T>)
          ResolvableType.forMethodParameter(methodParam, targetType).resolve(Object.class);
      if (converter.canRead(targetClass, contentType)) {
        if (logger.isDebugEnabled()) {
          logger.debug("Reading [" + targetClass.getName() + "] as \"" +
              contentType + "\" using [" + converter + "]");
        }
        return ((HttpMessageConverter<T>) converter).read(targetClass, inputMessage);
      }
    }

    throw new HttpMediaTypeNotSupportedException(contentType, this.allSupportedMediaTypes);
  }
View Full Code Here

      String paramName = methodParam.getParameterName();
      if (paramName != null) {
        builder.append(' ');
        builder.append(paramName);
      }
      throw new HttpMediaTypeNotSupportedException(
          "Cannot extract parameter (" + builder.toString() + "): no Content-Type found");
    }

    List<MediaType> allSupportedMediaTypes = new ArrayList<MediaType>();
    if (this.messageConverters != null) {
      for (HttpMessageConverter<?> messageConverter : this.messageConverters) {
        allSupportedMediaTypes.addAll(messageConverter.getSupportedMediaTypes());
        if (messageConverter.canRead(paramType, contentType)) {
          if (logger.isDebugEnabled()) {
            logger.debug("Reading [" + paramType.getName() + "] as \"" + contentType
                +"\" using [" + messageConverter + "]");
          }
          return messageConverter.read((Class) paramType, inputMessage);
        }
      }
    }
    throw new HttpMediaTypeNotSupportedException(contentType, allSupportedMediaTypes);
  }
View Full Code Here

            MediaType.parseMediaType(request.getContentType()) :
            MediaType.APPLICATION_OCTET_STREAM;
            return getMediaType().includes(contentType);
      }
      catch (InvalidMediaTypeException ex) {
        throw new HttpMediaTypeNotSupportedException(
            "Can't parse Content-Type [" + request.getContentType() + "]: " + ex.getMessage());
      }
    }
View Full Code Here

TOP

Related Classes of org.springframework.web.HttpMediaTypeNotSupportedException

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.