コード例 #1
0
  @Override
  public @Nonnull Blob createBucket(@Nonnull String bucketName, boolean findFreeName)
      throws InternalException, CloudException {
    APITrace.begin(getProvider(), "Blob.createBucket");
    try {
      if (bucketName.contains("/")) {
        throw new OperationNotSupportedException("Nested buckets are not supported");
      }
      String regionId = getContext().getRegionId();

      if (regionId == null) {
        throw new InternalException("No region ID was specified for this request");
      }

      GlacierMethod method =
          GlacierMethod.build(getProvider(), GlacierAction.CREATE_VAULT)
              .vaultId(bucketName)
              .toMethod();
      method.invoke();
      String url = method.getUrl();
      return Blob.getInstance(regionId, url, bucketName, System.currentTimeMillis());
    } finally {
      APITrace.end();
    }
  }
コード例 #2
0
  @Override
  public void removeBucket(@Nonnull String bucket) throws CloudException, InternalException {
    APITrace.begin(getProvider(), "Blob.removeBucket");
    try {
      String regionId = getContext().getRegionId();

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

      GlacierMethod method =
          GlacierMethod.build(getProvider(), GlacierAction.DELETE_VAULT).vaultId(bucket).toMethod();
      method.invoke();
    } finally {
      APITrace.end();
    }
  }
コード例 #3
0
  @Override
  public boolean isSubscribed() throws CloudException, InternalException {
    APITrace.begin(getProvider(), "Blob.isSubscribed");
    try {
      final String regionId = getContext().getRegionId();

      if (regionId == null) {
        throw new CloudException("No region ID was specified");
      }
      try {
        GlacierMethod method =
            GlacierMethod.build(getProvider(), GlacierAction.LIST_VAULTS).toMethod();
        method.invoke();
        return true;
      } catch (CloudException e) {
        return false;
      }
    } finally {
      APITrace.end();
    }
  }
コード例 #4
0
  @Override
  public void removeObject(@Nullable String bucket, @Nonnull String name)
      throws CloudException, InternalException {
    APITrace.begin(getProvider(), "Blob.removeObject");
    try {
      if (bucket == null) {
        throw new CloudException("No bucket was specified for this request");
      }
      String regionId = getContext().getRegionId();

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

      GlacierMethod method =
          GlacierMethod.build(getProvider(), GlacierAction.DELETE_ARCHIVE)
              .vaultId(bucket)
              .archiveId(name)
              .toMethod();
      method.invoke();
    } finally {
      APITrace.end();
    }
  }