use of org.jets3t.service.acl.gs.GSAccessControlList in project alluxio by Alluxio.
the class GCSUnderFileSystem method createInstance.
/**
* Constructs a new instance of {@link GCSUnderFileSystem}.
*
* @param uri the {@link AlluxioURI} for this UFS
* @return the created {@link GCSUnderFileSystem} instance
* @throws ServiceException when a connection to GCS could not be created
*/
public static GCSUnderFileSystem createInstance(AlluxioURI uri) throws ServiceException {
String bucketName = uri.getHost();
Preconditions.checkArgument(Configuration.containsKey(PropertyKey.GCS_ACCESS_KEY), "Property " + PropertyKey.GCS_ACCESS_KEY + " is required to connect to GCS");
Preconditions.checkArgument(Configuration.containsKey(PropertyKey.GCS_SECRET_KEY), "Property " + PropertyKey.GCS_SECRET_KEY + " is required to connect to GCS");
GSCredentials googleCredentials = new GSCredentials(Configuration.get(PropertyKey.GCS_ACCESS_KEY), Configuration.get(PropertyKey.GCS_SECRET_KEY));
// TODO(chaomin): maybe add proxy support for GCS.
GoogleStorageService googleStorageService = new GoogleStorageService(googleCredentials);
String accountOwnerId = googleStorageService.getAccountOwner().getId();
// Gets the owner from user-defined static mapping from GCS account id to Alluxio user name.
String owner = CommonUtils.getValueFromStaticMapping(Configuration.get(PropertyKey.UNDERFS_GCS_OWNER_ID_TO_USERNAME_MAPPING), accountOwnerId);
// If there is no user-defined mapping, use the display name.
if (owner == null) {
owner = googleStorageService.getAccountOwner().getDisplayName();
}
String accountOwner = owner == null ? accountOwnerId : owner;
GSAccessControlList acl = googleStorageService.getBucketAcl(bucketName);
short bucketMode = GCSUtils.translateBucketAcl(acl, accountOwnerId);
return new GCSUnderFileSystem(uri, googleStorageService, bucketName, bucketMode, accountOwner);
}
use of org.jets3t.service.acl.gs.GSAccessControlList in project alluxio by Alluxio.
the class GCSUtilsTest method before.
@Before
public void before() throws Exception {
// Setup owner.
mUserGrantee = new CanonicalGrantee(ID);
mUserGrantee.setDisplayName(NAME);
// Setup the acl.
mAcl = new GSAccessControlList();
mAcl.setOwner(new StorageOwner(ID, NAME));
}
Aggregations