Package org.cloudfoundry.client.lib

Examples of org.cloudfoundry.client.lib.CloudFoundryException


    Throwable cause = ce.getCause();

    assertTrue("Expected " + CloudFoundryException.class.getName() + " but got " + cause.getClass().getName(),
        cause instanceof CloudFoundryException);

    CloudFoundryException cfe = (CloudFoundryException) cause;

    assertTrue(CloudErrorUtil.getCloudFoundryErrorMessage(cfe).contains("403"));
  }
View Full Code Here


            return CloudFoundryPlugin.getStatus(Messages.CloudFoundryEditorAction_TEXT_NO_OP_EXECUTE, IStatus.WARNING);
          }
          operation.run(monitor);
        }
        catch (CoreException e) {
          CloudFoundryException cfe = e.getCause() instanceof CloudFoundryException ? (CloudFoundryException) e
              .getCause() : null;
          if (cfe instanceof NotFinishedStagingException) {
            status = new Status(IStatus.WARNING, CloudFoundryServerUiPlugin.PLUGIN_ID,
                Messages.CloudFoundryEditorAction_WARNING_RESTART_APP);
View Full Code Here

      // a row.
      attemptsRemaining = getMaximumErrorCount();
      return content;
    }
    catch (CoreException ce) {
      CloudFoundryException cfe = ce.getCause() instanceof CloudFoundryException ? (CloudFoundryException) ce
          .getCause() : null;

      // Do not log error if is is due to range not satisfied, or file is
      // not
      // found for instance
View Full Code Here

    }
  }

  private static CloudFoundryException getException(ClientHttpResponse response) throws IOException {
    HttpStatus statusCode = response.getStatusCode();
    CloudFoundryException cloudFoundryException = null;

    String description = "Client error";
    String statusText = response.getStatusText();

    ObjectMapper mapper = new ObjectMapper(); // can reuse, share globally

    if (response.getBody() != null) {
      try {
        @SuppressWarnings("unchecked")
        Map<String, Object> map = mapper.readValue(response.getBody(), Map.class);
        description = CloudUtil.parse(String.class, map.get("description"));

        int cloudFoundryErrorCode = CloudUtil.parse(Integer.class, map.get("code"));

        if (cloudFoundryErrorCode >= 0) {
          switch (cloudFoundryErrorCode) {
            case StagingErrorException.ERROR_CODE:
              cloudFoundryException = new StagingErrorException(
                  statusCode, statusText);
              break;
            case NotFinishedStagingException.ERROR_CODE:
              cloudFoundryException = new NotFinishedStagingException(
                  statusCode, statusText);
              break;
          }
        }
      } catch (JsonParseException e) {
        // Fall through. Handled below.
      } catch (IOException e) {
        // Fall through. Handled below.
      }
    }

    if (cloudFoundryException == null) {
      cloudFoundryException = new CloudFoundryException(statusCode,
          statusText);
    }
    cloudFoundryException.setDescription(description);

    return cloudFoundryException;
  }
View Full Code Here

  }

  @Override
  protected boolean hasError(HttpStatus statusCode) {
    if (expectedStatusCodes.contains(statusCode)) {
      throw new CloudFoundryException(statusCode);
    }
    return super.hasError(statusCode);
  }
View Full Code Here

    try {
      return provider.obtainAccessToken(resource, request);
    }
    catch (OAuth2AccessDeniedException oauthEx) {
      HttpStatus status = HttpStatus.valueOf(oauthEx.getHttpErrorCode());
      CloudFoundryException cfEx = new CloudFoundryException(status, oauthEx.getMessage());
      cfEx.setDescription(oauthEx.getSummary());
      throw cfEx;
    }
  }
View Full Code Here

      } else {
        if (start >= response.length()) {
          if (response.length() == 0) {
            return "";
          }
          throw new CloudFoundryException(HttpStatus.REQUESTED_RANGE_NOT_SATISFIABLE,
              "The starting position " + start + " is past the end of the file content.");
        }
        if (end != -1) {
          if (end >= response.length()) {
            end = response.length() - 1;
View Full Code Here

  @Override
  public CloudApplication getApplication(String appName) {
    Map<String, Object> resource = findApplicationResource(appName, true);
    if (resource == null) {
      throw new CloudFoundryException(HttpStatus.NOT_FOUND, "Not Found", "Application not found");
    }
    return mapCloudApplication(resource);
  }
View Full Code Here

  @Override
  public CloudApplication getApplication(UUID appGuid) {
    Map<String, Object> resource = findApplicationResource(appGuid, true);
    if (resource == null) {
      throw new CloudFoundryException(HttpStatus.NOT_FOUND, "Not Found", "Application not found");
    }
    return mapCloudApplication(resource);
  }
View Full Code Here

        CloudService cloudService = getService(serviceName);
        if (cloudService != null) {
          addServices.add(cloudService.getMeta().getGuid());
        }
        else {
          throw new CloudFoundryException(HttpStatus.NOT_FOUND, "Service with name " + serviceName +
              " not found in current space " + sessionSpace.getName());
        }
      }
    }
    // services to delete
View Full Code Here

TOP

Related Classes of org.cloudfoundry.client.lib.CloudFoundryException

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.