Esempio n. 1
0
  private void ensureCompatibleAcceptHeader(final RepresentationType representationType) {
    if (representationType == null) {
      return;
    }
    final MediaType producedType = representationType.getMediaType();

    final List<MediaType> acceptedMediaTypes = acceptedMediaTypes();

    if (Iterables.tryFind(acceptedMediaTypes, accepts(producedType)).isPresent()) {
      return;
    }
    throw RestfulObjectsApplicationException.create(
        HttpStatusCode.NOT_ACCEPTABLE,
        "Resource produces %s media type",
        representationType.getMediaType());
  }
Esempio n. 2
0
 private boolean compatible(
     final MediaType acceptedMediaType, final RepresentationType representationType) {
   final MediaType producedJaxRsMediaType = representationType.getMediaType();
   final String profile = acceptedMediaType.getParameters().get("profile");
   return profile == null
       ? acceptedMediaType.isCompatible(producedJaxRsMediaType)
       : acceptedMediaType.equals(producedJaxRsMediaType);
 }