コード例 #1
0
  private Blob loadVaultJson(JSONObject jsonObject, String regionId, String baseUrl)
      throws JSONException {
    String vaultName = jsonObject.getString("VaultName");
    String url;
    if (baseUrl.endsWith(vaultName)) {
      url = baseUrl;
    } else {
      url = baseUrl + "/" + vaultName;
    }

    String creationDate = jsonObject.getString("CreationDate");

    long creationTs = parseTimestamp(creationDate);

    if (jsonObject.has("SizeInBytes") && !jsonObject.isNull("SizeInBytes")) {
      Storage<Byte> storage = new Storage<Byte>(jsonObject.getLong("SizeInBytes"), Storage.BYTE);

      // somewhat dangerous: we want to specify a size for the vault, but currently
      // dasein-core only allows this specified on the Blob.getInstance() intended for
      // objects. It has a @Nonnull decorator for objectName, but we pass a null value
      // here. Currently in the implementation it does not matter.

      //noinspection ConstantConditions
      return Blob.getInstance(regionId, url, vaultName, null, creationTs, storage);
    }
    return Blob.getInstance(regionId, url, vaultName, creationTs);
  }
コード例 #2
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();
    }
  }
コード例 #3
0
 private Blob loadArchiveJson(JSONObject jsonObject, String bucket, String regionId)
     throws JSONException {
   String archiveId = jsonObject.getString("ArchiveId");
   Storage<Byte> size = new Storage<Byte>(jsonObject.getLong("Size"), Storage.BYTE);
   return Blob.getInstance(
       regionId,
       archiveId,
       bucket,
       archiveId,
       parseTimestamp(jsonObject.getString("CreationDate")),
       size);
 }