本文整理汇总了Java中com.google.api.services.storage.model.Bucket.setDefaultObjectAcl方法的典型用法代码示例。如果您正苦于以下问题:Java Bucket.setDefaultObjectAcl方法的具体用法?Java Bucket.setDefaultObjectAcl怎么用?Java Bucket.setDefaultObjectAcl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.services.storage.model.Bucket
的用法示例。
在下文中一共展示了Bucket.setDefaultObjectAcl方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRetryOn401
import com.google.api.services.storage.model.Bucket; //导入方法依赖的package包/类
@Test
public void testRetryOn401() throws Exception {
final boolean sharedPublicly = false;
final boolean forFailedJobs = true;
final boolean showInline = false;
final String pathPrefix = null;
Bucket bucket = new Bucket();
bucket.setName(BUCKET_NAME);
bucket.setDefaultObjectAcl(Lists.newArrayList(new ObjectAccessControl()));
final AbstractUpload.UploadSpec uploads =
new AbstractUpload.UploadSpec(workspace,
ImmutableList.of(workspaceFile, workspaceFile2));
FakeUpload underTest = new FakeUpload(BUCKET_URI,
sharedPublicly, forFailedJobs, showInline, pathPrefix,
new MockUploadModule(executor), /* no retries */
FAKE_DETAILS,
uploads);
executor.throwWhen(Storage.Buckets.Get.class, notFoundException);
executor.passThruWhen(Storage.Buckets.Insert.class,
MockUploadModule.checkBucketName(BUCKET_NAME));
executor.passThruWhen(Storage.Objects.Insert.class,
MockUploadModule.checkObjectName(FILENAME));
executor.throwWhen(Storage.Objects.Insert.class,
httpResponseException,
MockUploadModule.checkObjectName(FILENAME2));
executor.when(Storage.Buckets.Get.class, bucket);
executor.passThruWhen(Storage.Objects.Insert.class,
MockUploadModule.checkObjectName(FILENAME2));
underTest.perform(CREDENTIALS_ID, build, TaskListener.NULL);
}
示例2: testRetryOn401StillFails
import com.google.api.services.storage.model.Bucket; //导入方法依赖的package包/类
@Test(expected = UploadException.class)
public void testRetryOn401StillFails() throws Exception {
final boolean sharedPublicly = false;
final boolean forFailedJobs = true;
final boolean showInline = false;
final String pathPrefix = null;
Bucket bucket = new Bucket();
bucket.setName(BUCKET_NAME);
bucket.setDefaultObjectAcl(Lists.newArrayList(new ObjectAccessControl()));
final AbstractUpload.UploadSpec uploads =
new AbstractUpload.UploadSpec(workspace,
ImmutableList.of(workspaceFile));
FakeUpload underTest = new FakeUpload(BUCKET_URI,
sharedPublicly, forFailedJobs, showInline, pathPrefix,
new MockUploadModule(executor), /* no retries */
FAKE_DETAILS,
uploads);
int maxRetriesPlus1 =
RetryStorageOperation.MAX_REMOTE_CREDENTIAL_EXPIRED_RETRIES + 1;
for (int i = 0; i < maxRetriesPlus1; i++) {
executor.when(Storage.Buckets.Get.class, bucket);
executor.throwWhen(Storage.Objects.Insert.class,
httpResponseException,
MockUploadModule.checkObjectName(FILENAME));
}
underTest.perform(CREDENTIALS_ID, build, TaskListener.NULL);
}
示例3: testBucketConflict
import com.google.api.services.storage.model.Bucket; //导入方法依赖的package包/类
@Test
public void testBucketConflict() throws Exception {
final boolean sharedPublicly = false;
final boolean forFailedJobs = true;
final boolean showInline = false;
final String pathPrefix = null;
final AbstractUpload.UploadSpec uploads =
new AbstractUpload.UploadSpec(workspace, ImmutableList.<FilePath>of());
FakeUpload underTest = new FakeUpload(BUCKET_URI,
sharedPublicly, forFailedJobs, showInline, pathPrefix,
new MockUploadModule(executor),
FAKE_DETAILS,
uploads);
Bucket bucket = new Bucket();
bucket.setName(BUCKET_NAME);
bucket.setDefaultObjectAcl(Lists.newArrayList(new ObjectAccessControl()));
executor.throwWhen(Storage.Buckets.Get.class, notFoundException);
executor.throwWhen(Storage.Buckets.Insert.class, conflictException,
MockUploadModule.checkBucketName(BUCKET_NAME));
executor.when(Storage.Buckets.Get.class, bucket);
underTest.perform(CREDENTIALS_ID, build, TaskListener.NULL);
}
示例4: testNotShared
import com.google.api.services.storage.model.Bucket; //导入方法依赖的package包/类
@Test
public void testNotShared() throws Exception {
final boolean sharedPublicly = false;
final boolean forFailedJobs = true;
final boolean showInline = false;
final String pathPrefix = null;
final AbstractUpload.UploadSpec uploads =
new AbstractUpload.UploadSpec(workspace,
ImmutableList.of(workspaceFile));
FakeUpload underTest = new FakeUpload(BUCKET_URI,
sharedPublicly, forFailedJobs, showInline, pathPrefix,
new MockUploadModule(executor),
FAKE_DETAILS,
uploads);
Bucket bucket = new Bucket();
bucket.setName(BUCKET_NAME);
bucket.setDefaultObjectAcl(Lists.newArrayList(new ObjectAccessControl()));
executor.when(Storage.Buckets.Get.class, bucket);
executor.passThruWhen(Storage.Objects.Insert.class,
new Predicate<Storage.Objects.Insert>() {
@Override
public boolean apply(Storage.Objects.Insert operation) {
StorageObject object = (StorageObject) operation.getJsonContent();
assertNull(object.getAcl());
return true;
}
});
underTest.perform(CREDENTIALS_ID, build, TaskListener.NULL);
}
示例5: testSharedPublicly
import com.google.api.services.storage.model.Bucket; //导入方法依赖的package包/类
@Test
public void testSharedPublicly() throws Exception {
final boolean sharedPublicly = true;
final boolean forFailedJobs = true;
final boolean showInline = false;
final String pathPrefix = null;
final AbstractUpload.UploadSpec uploads =
new AbstractUpload.UploadSpec(workspace,
ImmutableList.of(workspaceFile));
FakeUpload underTest = new FakeUpload(BUCKET_URI,
sharedPublicly, forFailedJobs, showInline, pathPrefix,
new MockUploadModule(executor),
FAKE_DETAILS,
uploads);
final Bucket bucket = new Bucket();
bucket.setName(BUCKET_NAME);
bucket.setDefaultObjectAcl(Lists.newArrayList(new ObjectAccessControl()));
executor.when(Storage.Buckets.Get.class, bucket);
executor.passThruWhen(Storage.Objects.Insert.class,
new Predicate<Storage.Objects.Insert>() {
@Override
public boolean apply(Storage.Objects.Insert operation) {
StorageObject object = (StorageObject) operation.getJsonContent();
assertTrue(object.getAcl().containsAll(
bucket.getDefaultObjectAcl()));
List<ObjectAccessControl> addedAcl =
Lists.newArrayList(Iterables.filter(
object.getAcl(), not(in(bucket.getDefaultObjectAcl()))));
Set<String> addedEntities = Sets.newHashSet();
for (ObjectAccessControl access : addedAcl) {
assertEquals("READER", access.getRole());
addedEntities.add(access.getEntity());
}
assertTrue(addedEntities.contains("allUsers"));
return true;
}
});
underTest.perform(CREDENTIALS_ID, build, TaskListener.NULL);
}