Ejemplo n.º 1
0
  @Nullable
  @Override
  public OfflineStoreRequest getRequest(@Nonnull String bucket, @Nonnull String requestId)
      throws CloudException, InternalException {
    APITrace.begin(getProvider(), "Blob.getRequest");
    try {

      final GlacierMethod method =
          GlacierMethod.build(getProvider(), GlacierAction.DESCRIBE_JOB)
              .vaultId(bucket)
              .jobId(requestId)
              .toMethod();

      try {
        final JSONObject jsonObject = method.invokeJson();
        return loadRequestJson(jsonObject, bucket);

      } catch (GlacierException e) {
        if (e.getHttpCode() == 404) {
          return null;
        }
        throw e;
      } catch (JSONException e) {
        throw new CloudException(e);
      }
    } finally {
      APITrace.end();
    }
  }
Ejemplo n.º 2
0
  @Override
  public Blob getBucket(@Nonnull String bucketName) throws InternalException, CloudException {
    APITrace.begin(getProvider(), "Blob.getBucket");
    try {
      if (bucketName.contains("/")) {
        return null;
      }

      String regionId = getContext().getRegionId();
      if (regionId == null) {
        throw new CloudException("No region was set for this request");
      }

      try {
        GlacierMethod method =
            GlacierMethod.build(getProvider(), GlacierAction.DESCRIBE_VAULT)
                .vaultId(bucketName)
                .toMethod();
        JSONObject jsonObject = method.invokeJson();
        if (jsonObject == null) {
          return null;
        }
        return loadVaultJson(jsonObject, regionId, method.getUrl());

      } catch (GlacierException e) {
        if (e.getHttpCode() == 404) {
          return null;
        }
        throw e;
      } catch (JSONException e) {
        throw new CloudException(e);
      }
    } finally {
      APITrace.end();
    }
  }