Examples of ResponseErrorHandler


Examples of org.springframework.web.client.ResponseErrorHandler

    try {
        ClientHttpRequest request = getRestTemplate().getRequestFactory().createRequest(uri, HttpMethod.PUT);
        request.getBody().write(file);
       
        ClientHttpResponse response = request.execute();
        ResponseErrorHandler errorHandler = new DefaultResponseErrorHandler();
        if (errorHandler.hasError(response)) {
          errorHandler.handleError(response);
          return null;
        }
        else {
          InputStream stream = response.getBody();
          return objectMapper.readValue(stream, Metadata.class);
View Full Code Here

Examples of org.springframework.web.client.ResponseErrorHandler

  }

  @Test
  public void testCustomHandler() throws Exception {

    OAuth2ErrorHandler handler = new OAuth2ErrorHandler(new ResponseErrorHandler() {

      public boolean hasError(ClientHttpResponse response) throws IOException {
        return true;
      }
View Full Code Here

Examples of org.springframework.web.client.ResponseErrorHandler

  }

  @Test
  public void testBodyCanBeUsedByCustomHandler() throws Exception {
    final String appSpecificBodyContent = "{\"some_status\":\"app error\"}";
    OAuth2ErrorHandler handler = new OAuth2ErrorHandler(new ResponseErrorHandler() {
      public boolean hasError(ClientHttpResponse response) throws IOException {
        return true;
      }

      public void handleError(ClientHttpResponse response) throws IOException {
View Full Code Here

Examples of org.springframework.web.client.ResponseErrorHandler

      protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
        super.prepareConnection(connection, httpMethod);
        connection.setInstanceFollowRedirects(false);
      }
    });
    client.setErrorHandler(new ResponseErrorHandler() {
      // Pass errors through in response entity for status code analysis
      public boolean hasError(ClientHttpResponse response) throws IOException {
        return false;
      }
View Full Code Here

Examples of org.springframework.web.client.ResponseErrorHandler

  }

  private RestTemplate createRestTemplate(final StringBuilder buffer) {
    RestTemplate restTemplate = new RestTemplate();

    restTemplate.setErrorHandler(new ResponseErrorHandler() {
      @Override
      public boolean hasError(ClientHttpResponse response) throws IOException {
        HttpStatus status = response.getStatusCode();
        return (status == HttpStatus.BAD_GATEWAY || status == HttpStatus.GATEWAY_TIMEOUT || status == HttpStatus.INTERNAL_SERVER_ERROR);
      }
View Full Code Here

Examples of org.springframework.web.client.ResponseErrorHandler

    String authenticationChallenge = "http://localhost:" + this.context.getEmbeddedServletContainer().getPort() +
        "/repository/process-definitions" ;

    final AtomicBoolean received401 = new AtomicBoolean();
    received401.set(false);
    restTemplate.setErrorHandler(new ResponseErrorHandler() {
        @Override
        public boolean hasError(ClientHttpResponse clientHttpResponse) throws IOException {
          return true;
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.