Package org.springframework.http.converter

Examples of org.springframework.http.converter.HttpMessageNotReadableException


      ImageReader imageReader = imageReaders.next();
      ImageReadParam irp = imageReader.getDefaultReadParam();
      imageReader.setInput(new MemoryCacheImageInputStream(photo), true);
      body = imageReader.read(0, irp);
    } else {
      throw new HttpMessageNotReadableException("Could not find javax.imageio.ImageReader for Content-Type ["
          + contentType + "]");
    }
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.IMAGE_JPEG);
    return new ResponseEntity<BufferedImage>(body, headers, HttpStatus.OK);
View Full Code Here


      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

    try {
      JsonPatchHandler handler = new JsonPatchHandler(mapper, reader);
      return handler.apply(request, existingObject);
    } catch (Exception e) {
      throw new HttpMessageNotReadableException(String.format(ERROR_MESSAGE, existingObject.getClass()));
    }
  }
View Full Code Here

      RootResourceInformation information) {

    try {
      return converter.read(information.getDomainType(), request.getServerHttpRequest());
    } catch (IOException e) {
      throw new HttpMessageNotReadableException(String.format(ERROR_MESSAGE, information.getDomainType()));
    }
  }
View Full Code Here

    Assert.notNull(mapper, "ObjectMapper must not be null!");

    try {
      return merge((ObjectNode) mapper.readTree(source), target, mapper);
    } catch (Exception e) {
      throw new HttpMessageNotReadableException("Could not read payload!", e);
    }
  }
View Full Code Here

      HttpMessageNotReadableException {
    JavaType javaType = getJavaType(clazz);
    try {
      return objectMapper.readValue(inputMessage.getBody(), javaType);
    } catch (JsonParseException ex) {
      throw new HttpMessageNotReadableException("Could not read JSON: " + ex.getMessage(), ex);
    }
  }
View Full Code Here

    return super.readWithMessageConverters(inputMessage, methodParam, paramType);
  }

  private Object handleEmptyBody(MethodParameter param) {
    if (param.getParameterAnnotation(RequestBody.class).required()) {
      throw new HttpMessageNotReadableException("Required request body content is missing: " + param);
    }
    return null;
  }
View Full Code Here

    try {
      Reader reader = new InputStreamReader(inputMessage.getBody(), charset);
      return (T) feedInput.build(reader);
    }
    catch (FeedException ex) {
      throw new HttpMessageNotReadableException("Could not read WireFeed: " + ex.getMessage(), ex);
    }
  }
View Full Code Here

        builder.mergeFrom(inputMessage.getBody(), this.extensionRegistry);
      }
      return builder.build();
    }
    catch (Exception e) {
      throw new HttpMessageNotReadableException("Could not read Protobuf message: " + e.getMessage(), e);
    }
  }
View Full Code Here

  private Object readJavaType(JavaType javaType, HttpInputMessage inputMessage) {
    try {
      return this.objectMapper.readValue(inputMessage.getBody(), javaType);
    }
    catch (IOException ex) {
      throw new HttpMessageNotReadableException("Could not read JSON: " + ex.getMessage(), ex);
    }
  }
View Full Code Here

TOP

Related Classes of org.springframework.http.converter.HttpMessageNotReadableException

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.