Package org.springframework.web.client

Examples of org.springframework.web.client.HttpClientErrorException


    }
    return message;
  }

  public static boolean isFileNotFoundForInstance(Exception e) {
    HttpClientErrorException badRequestException = getBadRequestException(e);
    if (badRequestException != null) {
      String message = getHttpErrorMessage(badRequestException);

      if (message != null) {
        message = message.toLowerCase();
View Full Code Here


   * @return determines if the given exception is a Bad Request 400 Exception.
   * If so, returns it the corresponding HttpClientErrorException. Otherwise
   * returns null.
   */
  public static HttpClientErrorException getBadRequestException(Exception t) {
    HttpClientErrorException httpException = getHttpClientError(t);
    if (httpException != null) {
      HttpStatus statusCode = httpException.getStatusCode();
      if (HttpStatus.BAD_REQUEST.equals(statusCode)) {
        return httpException;
      }
    }
    return null;
View Full Code Here

  protected static HttpClientErrorException getHttpClientError(Throwable t) {
    if (t == null) {
      return null;
    }
    HttpClientErrorException httpException = null;
    if (t instanceof HttpClientErrorException) {
      httpException = (HttpClientErrorException) t;
    }
    else {
      Throwable cause = t.getCause();
View Full Code Here

    return isHttpException(t, HttpStatus.NOT_FOUND);
  }

  public static boolean isHttpException(Throwable t, HttpStatus status) {

    HttpClientErrorException httpException = getHttpClientError(t);

    if (httpException != null) {
      HttpStatus statusCode = httpException.getStatusCode();
      return statusCode.equals(status);
    }

    return false;
  }
View Full Code Here

  // check if error is caused by wrong credentials
  public static boolean isWrongCredentialsException(CoreException e) {
    Throwable cause = e.getCause();
    if (cause instanceof HttpClientErrorException) {
      HttpClientErrorException httpException = (HttpClientErrorException) cause;
      HttpStatus statusCode = httpException.getStatusCode();
      if (statusCode.equals(HttpStatus.FORBIDDEN) && httpException instanceof CloudFoundryException) {
        return ((CloudFoundryException) httpException).getDescription().equals("Operation not permitted"); //$NON-NLS-1$
      }
    }
    return false;
View Full Code Here

    }
    return false;
  }

  public static boolean isAppStoppedStateError(Exception e) {
    HttpClientErrorException badRequestException = getBadRequestException(e);
    if (badRequestException != null) {
      String message = getHttpErrorMessage(badRequestException);

      if (message != null) {
        message = message.toLowerCase();
View Full Code Here

        schemaTO = restTemplate.getForObject(BASE_URL + "schema/user/read/authTestSchema.json", SchemaTO.class);
        assertNotNull(schemaTO);

        // 5. update the schema create above (as user) - failure
        HttpClientErrorException exception = null;
        try {
            restTemplate.postForObject(BASE_URL + "schema/role/update", schemaTO, SchemaTO.class);
        } catch (HttpClientErrorException e) {
            exception = e;
        }
        assertNotNull(exception);
        assertEquals(HttpStatus.FORBIDDEN, exception.getStatusCode());

        // reset admin credentials for restTemplate
        super.resetRestTemplate();

        userTO = restTemplate.getForObject(BASE_URL + "user/read/{userId}.json", UserTO.class, userTO.getId());
View Full Code Here

        schemaTO = restTemplate.getForObject(BASE_URL + "schema/user/read/authTestSchema.json", SchemaTO.class);
        assertNotNull(schemaTO);

        // 5. update the schema create above (as user) - failure
        HttpClientErrorException exception = null;
        try {
            restTemplate.postForObject(BASE_URL + "schema/role/update", schemaTO, SchemaTO.class);
        } catch (HttpClientErrorException e) {
            exception = e;
        }
        assertNotNull(exception);
        assertEquals(HttpStatus.FORBIDDEN, exception.getStatusCode());

        // reset admin credentials for restTemplate
        super.resetRestTemplate();

        userTO = restTemplate.getForObject(BASE_URL + "user/read/{userId}.json", UserTO.class, userTO.getId());
View Full Code Here

    }

    private String handleRequest(String path, Object[] uriVariables) {
        String url = new UriTemplate(path).expand(uriVariables).getPath();
        if (!responseMap.containsKey(url)) {
            throw new HttpClientErrorException(HttpStatus.NOT_FOUND, "no response for: " + url);
        }
        return responseMap.get(url);
    }
View Full Code Here

        schemaTO = restTemplate.getForObject(BASE_URL + "schema/user/read/authTestSchema.json", SchemaTO.class);
        assertNotNull(schemaTO);

        // 5. update the schema create above (as user) - failure
        HttpClientErrorException exception = null;
        try {
            restTemplate.postForObject(BASE_URL + "schema/role/update", schemaTO, SchemaTO.class);
        } catch (HttpClientErrorException e) {
            exception = e;
        }
        assertNotNull(exception);
        assertEquals(HttpStatus.FORBIDDEN, exception.getStatusCode());

        // reset admin credentials for restTemplate
        super.setupRestTemplate();

        userTO = restTemplate.getForObject(BASE_URL + "user/read/{userId}.json", UserTO.class, userTO.getId());
View Full Code Here

TOP

Related Classes of org.springframework.web.client.HttpClientErrorException

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.