com.google.cloud.storage.Blob.getTemporaryHold()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(3.7k)|赞(0)|评价(0)|浏览(284)

本文整理了Java中com.google.cloud.storage.Blob.getTemporaryHold()方法的一些代码示例,展示了Blob.getTemporaryHold()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Blob.getTemporaryHold()方法的具体详情如下:
包路径:com.google.cloud.storage.Blob
类名称:Blob
方法名:getTemporaryHold

Blob.getTemporaryHold介绍

暂无

代码示例

代码示例来源:origin: googleapis/google-cloud-java

System.out.println("TimeCreated: " + new Date(blob.getCreateTime()));
System.out.println("Last Metadata Update: " + new Date(blob.getUpdateTime()));
Boolean temporaryHoldIsEnabled = (blob.getTemporaryHold() != null && blob.getTemporaryHold());
System.out.println("temporaryHold: " + (temporaryHoldIsEnabled ? "enabled" : "disabled"));
Boolean eventBasedHoldIsEnabled =

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testEnableDisableTemporaryHold() {
 String blobName = "test-create-with-temporary-hold";
 BlobInfo blobInfo = BlobInfo.newBuilder(BUCKET, blobName).setTemporaryHold(true).build();
 Blob remoteBlob = storage.create(blobInfo);
 assertTrue(remoteBlob.getTemporaryHold());
 remoteBlob =
   storage.get(remoteBlob.getBlobId(), Storage.BlobGetOption.fields(BlobField.TEMPORARY_HOLD));
 assertTrue(remoteBlob.getTemporaryHold());
 remoteBlob = remoteBlob.toBuilder().setTemporaryHold(false).build().update();
 assertFalse(remoteBlob.getTemporaryHold());
}

代码示例来源:origin: googleapis/google-cloud-java

@Override
 public void run() {
  Page<Bucket> buckets =
    storage.list(Storage.BucketListOption.prefix(BUCKET_NAME_PREFIX));
  for (Bucket bucket : buckets.iterateAll()) {
   if (bucket.getCreateTime() < olderThan) {
    try {
     for (Blob blob :
       bucket
         .list(
           BlobListOption.fields(
             Storage.BlobField.EVENT_BASED_HOLD,
             Storage.BlobField.TEMPORARY_HOLD))
         .iterateAll()) {
      if (blob.getEventBasedHold() == true || blob.getTemporaryHold() == true) {
       storage.update(
         blob.toBuilder()
           .setTemporaryHold(false)
           .setEventBasedHold(false)
           .build());
      }
     }
     forceDelete(storage, bucket.getName());
    } catch (Exception e) {
     // Ignore the exception, maybe the bucket is being deleted by someone else.
    }
   }
  }
 }
};

代码示例来源:origin: googleapis/google-cloud-java

@Test
public void testAttemptDeletionObjectTemporaryHold() {
 String blobName = "test-create-with-temporary-hold";
 BlobInfo blobInfo = BlobInfo.newBuilder(BUCKET, blobName).setTemporaryHold(true).build();
 Blob remoteBlob = storage.create(blobInfo);
 assertTrue(remoteBlob.getTemporaryHold());
 try {
  remoteBlob.delete();
  fail("Expected failure on delete from temporaryHold");
 } catch (StorageException ex) {
  // expected
 } finally {
  remoteBlob.toBuilder().setEventBasedHold(false).build().update();
 }
}

代码示例来源:origin: googleapis/google-cloud-java

assertEquals(KMS_KEY_NAME, blob.getKmsKeyName());
assertEquals(EVENT_BASED_HOLD, blob.getEventBasedHold());
assertEquals(TEMPORARY_HOLD, blob.getTemporaryHold());
assertEquals(RETENTION_EXPIRATION_TIME, blob.getRetentionExpirationTime());
assertEquals(DELETE_TIME, blob.getDeleteTime());
assertNull(blob.getKmsKeyName());
assertNull(blob.getEventBasedHold());
assertNull(blob.getTemporaryHold());
assertNull(blob.getRetentionExpirationTime());
assertNull(blob.getDeleteTime());

代码示例来源:origin: com.google.cloud/google-cloud-storage

@Override
 public void run() {
  Page<Bucket> buckets =
    storage.list(Storage.BucketListOption.prefix(BUCKET_NAME_PREFIX));
  for (Bucket bucket : buckets.iterateAll()) {
   if (bucket.getCreateTime() < olderThan) {
    try {
     for (Blob blob :
       bucket
         .list(
           BlobListOption.fields(
             Storage.BlobField.EVENT_BASED_HOLD,
             Storage.BlobField.TEMPORARY_HOLD))
         .iterateAll()) {
      if (blob.getEventBasedHold() == true || blob.getTemporaryHold() == true) {
       storage.update(
         blob.toBuilder()
           .setTemporaryHold(false)
           .setEventBasedHold(false)
           .build());
      }
     }
     forceDelete(storage, bucket.getName());
    } catch (Exception e) {
     // Ignore the exception, maybe the bucket is being deleted by someone else.
    }
   }
  }
 }
};

相关文章