本文整理了Java中com.google.cloud.storage.Blob.getRetentionExpirationTime()
方法的一些代码示例,展示了Blob.getRetentionExpirationTime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Blob.getRetentionExpirationTime()
方法的具体详情如下:
包路径:com.google.cloud.storage.Blob
类名称:Blob
方法名:getRetentionExpirationTime
暂无
代码示例来源:origin: googleapis/google-cloud-java
(blob.getEventBasedHold() != null && blob.getEventBasedHold());
System.out.println("eventBasedHold: " + (eventBasedHoldIsEnabled ? "enabled" : "disabled"));
if (blob.getRetentionExpirationTime() != null) {
System.out.println("retentionExpirationTime: " + new Date(blob.getRetentionExpirationTime()));
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testAttemptObjectDeleteWithRetentionPolicy()
throws ExecutionException, InterruptedException {
String bucketName = RemoteStorageHelper.generateBucketName();
Bucket remoteBucket =
storage.create(
BucketInfo.newBuilder(bucketName).setRetentionPeriod(RETENTION_PERIOD).build());
assertEquals(RETENTION_PERIOD, remoteBucket.getRetentionPeriod());
String blobName = "test-create-with-retention-policy";
BlobInfo blobInfo = BlobInfo.newBuilder(bucketName, blobName).build();
Blob remoteBlob = storage.create(blobInfo);
assertNotNull(remoteBlob.getRetentionExpirationTime());
try {
remoteBlob.delete();
fail("Expected failure on delete from retentionPolicy");
} catch (StorageException ex) {
// expected
} finally {
Thread.sleep(RETENTION_PERIOD_IN_MILLISECONDS);
RemoteStorageHelper.forceDelete(storage, bucketName, 5, TimeUnit.SECONDS);
}
}
代码示例来源:origin: googleapis/google-cloud-java
@Test
public void testRetentionPolicyNoLock() throws ExecutionException, InterruptedException {
String bucketName = RemoteStorageHelper.generateBucketName();
Bucket remoteBucket =
storage.create(
BucketInfo.newBuilder(bucketName).setRetentionPeriod(RETENTION_PERIOD).build());
try {
assertEquals(RETENTION_PERIOD, remoteBucket.getRetentionPeriod());
assertNotNull(remoteBucket.getRetentionEffectiveTime());
assertNull(remoteBucket.retentionPolicyIsLocked());
remoteBucket =
storage.get(bucketName, Storage.BucketGetOption.fields(BucketField.RETENTION_POLICY));
assertEquals(RETENTION_PERIOD, remoteBucket.getRetentionPeriod());
assertNotNull(remoteBucket.getRetentionEffectiveTime());
assertNull(remoteBucket.retentionPolicyIsLocked());
String blobName = "test-create-with-retention-policy-hold";
BlobInfo blobInfo = BlobInfo.newBuilder(bucketName, blobName).build();
Blob remoteBlob = storage.create(blobInfo);
assertNotNull(remoteBlob.getRetentionExpirationTime());
remoteBucket = remoteBucket.toBuilder().setRetentionPeriod(null).build().update();
assertNull(remoteBucket.getRetentionPeriod());
remoteBucket = remoteBucket.toBuilder().setRetentionPeriod(null).build().update();
assertNull(remoteBucket.getRetentionPeriod());
} finally {
RemoteStorageHelper.forceDelete(storage, bucketName, 5, TimeUnit.SECONDS);
}
}
代码示例来源:origin: googleapis/google-cloud-java
assertEquals(EVENT_BASED_HOLD, blob.getEventBasedHold());
assertEquals(TEMPORARY_HOLD, blob.getTemporaryHold());
assertEquals(RETENTION_EXPIRATION_TIME, blob.getRetentionExpirationTime());
assertEquals(DELETE_TIME, blob.getDeleteTime());
assertEquals(ETAG, blob.getEtag());
assertNull(blob.getEventBasedHold());
assertNull(blob.getTemporaryHold());
assertNull(blob.getRetentionExpirationTime());
assertNull(blob.getDeleteTime());
assertNull(blob.getEtag());
内容来源于网络,如有侵权,请联系作者删除!