本文整理了Java中com.google.cloud.storage.Blob.getEventBasedHold()
方法的一些代码示例,展示了Blob.getEventBasedHold()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Blob.getEventBasedHold()
方法的具体详情如下:
包路径:com.google.cloud.storage.Blob
类名称:Blob
方法名:getEventBasedHold
暂无
代码示例来源:origin: googleapis/google-cloud-java
System.out.println("temporaryHold: " + (temporaryHoldIsEnabled ? "enabled" : "disabled"));
Boolean eventBasedHoldIsEnabled =
(blob.getEventBasedHold() != null && blob.getEventBasedHold());
System.out.println("eventBasedHold: " + (eventBasedHoldIsEnabled ? "enabled" : "disabled"));
if (blob.getRetentionExpirationTime() != null) {
代码示例来源: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 testAttemptObjectDeleteWithEventBasedHold() {
String blobName = "test-create-with-event-based-hold";
BlobInfo blobInfo = BlobInfo.newBuilder(BUCKET, blobName).setEventBasedHold(true).build();
Blob remoteBlob = storage.create(blobInfo);
assertTrue(remoteBlob.getEventBasedHold());
try {
remoteBlob.delete();
fail("Expected failure on delete from eventBasedHold");
} catch (StorageException ex) {
// expected
} finally {
remoteBlob.toBuilder().setEventBasedHold(false).build().update();
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testEnableDisableBucketDefaultEventBasedHold()
throws ExecutionException, InterruptedException {
String bucketName = RemoteStorageHelper.generateBucketName();
Bucket remoteBucket =
storage.create(BucketInfo.newBuilder(bucketName).setDefaultEventBasedHold(true).build());
try {
assertTrue(remoteBucket.getDefaultEventBasedHold());
remoteBucket =
storage.get(
bucketName, Storage.BucketGetOption.fields(BucketField.DEFAULT_EVENT_BASED_HOLD));
assertTrue(remoteBucket.getDefaultEventBasedHold());
String blobName = "test-create-with-event-based-hold";
BlobInfo blobInfo = BlobInfo.newBuilder(bucketName, blobName).build();
Blob remoteBlob = storage.create(blobInfo);
assertTrue(remoteBlob.getEventBasedHold());
remoteBlob =
storage.get(
blobInfo.getBlobId(), Storage.BlobGetOption.fields(BlobField.EVENT_BASED_HOLD));
assertTrue(remoteBlob.getEventBasedHold());
remoteBlob = remoteBlob.toBuilder().setEventBasedHold(false).build().update();
assertFalse(remoteBlob.getEventBasedHold());
remoteBucket = remoteBucket.toBuilder().setDefaultEventBasedHold(false).build().update();
assertFalse(remoteBucket.getDefaultEventBasedHold());
} finally {
RemoteStorageHelper.forceDelete(storage, bucketName, 5, TimeUnit.SECONDS);
}
}
代码示例来源:origin: googleapis/google-cloud-java
assertEquals(CUSTOMER_ENCRYPTION, blob.getCustomerEncryption());
assertEquals(KMS_KEY_NAME, blob.getKmsKeyName());
assertEquals(EVENT_BASED_HOLD, blob.getEventBasedHold());
assertEquals(TEMPORARY_HOLD, blob.getTemporaryHold());
assertEquals(RETENTION_EXPIRATION_TIME, blob.getRetentionExpirationTime());
assertNull(blob.getCustomerEncryption());
assertNull(blob.getKmsKeyName());
assertNull(blob.getEventBasedHold());
assertNull(blob.getTemporaryHold());
assertNull(blob.getRetentionExpirationTime());
代码示例来源: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.
}
}
}
}
};
内容来源于网络,如有侵权,请联系作者删除!