Package org.springframework.web

Examples of org.springframework.web.HttpMediaTypeNotAcceptableException


      if (jafMediaType != null && !MediaType.APPLICATION_OCTET_STREAM.equals(jafMediaType)) {
        return jafMediaType;
      }
    }
    if (!this.ignoreUnknownExtensions) {
      throw new HttpMediaTypeNotAcceptableException(getAllMediaTypes());
    }
    return null;
  }
View Full Code Here


        MediaType.sortBySpecificityAndQuality(mediaTypes);
        return mediaTypes;
      }
    }
    catch (InvalidMediaTypeException ex) {
      throw new HttpMediaTypeNotAcceptableException(
          "Could not parse accept header [" + acceptHeader + "]: " + ex.getMessage());
    }
    return Collections.emptyList();
  }
View Full Code Here

        }
      }
    }
    if (compatibleMediaTypes.isEmpty()) {
      if (returnValue != null) {
        throw new HttpMediaTypeNotAcceptableException(producibleMediaTypes);
      }
      return;
    }

    List<MediaType> mediaTypes = new ArrayList<MediaType>(compatibleMediaTypes);
    MediaType.sortBySpecificityAndQuality(mediaTypes);

    MediaType selectedMediaType = null;
    for (MediaType mediaType : mediaTypes) {
      if (mediaType.isConcrete()) {
        selectedMediaType = mediaType;
        break;
      }
      else if (mediaType.equals(MediaType.ALL) || mediaType.equals(MEDIA_TYPE_APPLICATION)) {
        selectedMediaType = MediaType.APPLICATION_OCTET_STREAM;
        break;
      }
    }

    if (selectedMediaType != null) {
      selectedMediaType = selectedMediaType.removeQualityValue();
      for (HttpMessageConverter<?> messageConverter : this.messageConverters) {
        if (messageConverter.canWrite(returnValueClass, selectedMediaType)) {
          returnValue = this.adviceChain.invoke(returnValue, returnType, selectedMediaType,
              (Class<HttpMessageConverter<?>>) messageConverter.getClass(), inputMessage, outputMessage);
          if (returnValue != null) {
            ((HttpMessageConverter<T>) messageConverter).write(returnValue, selectedMediaType, outputMessage);
            if (logger.isDebugEnabled()) {
              logger.debug("Written [" + returnValue + "] as \"" + selectedMediaType + "\" using [" +
                  messageConverter + "]");
            }
          }
          return;
        }
      }
    }

    if (returnValue != null) {
      throw new HttpMediaTypeNotAcceptableException(this.allSupportedMediaTypes);
    }
  }
View Full Code Here

        }
        for (HttpMessageConverter messageConverter : messageConverters) {
          allSupportedMediaTypes.addAll(messageConverter.getSupportedMediaTypes());
        }
      }
      throw new HttpMediaTypeNotAcceptableException(allSupportedMediaTypes);
    }
View Full Code Here

        }
      }
      throw new HttpMediaTypeNotSupportedException(contentType, new ArrayList<MediaType>(consumableMediaTypes));
    }
    else if (!producibleMediaTypes.isEmpty()) {
      throw new HttpMediaTypeNotAcceptableException(new ArrayList<MediaType>(producibleMediaTypes));
    }
    else if (!CollectionUtils.isEmpty(paramConditions)) {
      String[] params = paramConditions.toArray(new String[paramConditions.size()]);
      throw new UnsatisfiedServletRequestParameterException(params, request.getParameterMap());
    }
View Full Code Here

    assertEquals(acceptable, responseEntity.getHeaders().getAccept());
  }

  @Test
  public void httpMediaTypeNotAcceptable() {
    Exception ex = new HttpMediaTypeNotAcceptableException("");
    testException(ex);
  }
View Full Code Here

              return;
            }
          }
        }
      }
      throw new HttpMediaTypeNotAcceptableException(allSupportedMediaTypes);
    }
View Full Code Here

        }
        for (HttpMessageConverter messageConverter : messageConverters) {
          allSupportedMediaTypes.addAll(messageConverter.getSupportedMediaTypes());
        }
      }
      throw new HttpMediaTypeNotAcceptableException(allSupportedMediaTypes);
    }
View Full Code Here

TOP

Related Classes of org.springframework.web.HttpMediaTypeNotAcceptableException

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.