下面列出了怎么用com.amazonaws.services.s3.model.Owner的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Maps a DBInstance into a row in our Apache Arrow response block(s).
*
* @param objectSummary The S3 ObjectSummary to map.
* @param spiller The BlockSpiller to use when we want to write a matching row to the response.
* @note The current implementation is rather naive in how it maps fields. It leverages a static
* list of fields that we'd like to provide and then explicitly filters and converts each field.
*/
private void toRow(S3ObjectSummary objectSummary,
BlockSpiller spiller)
{
spiller.writeRows((Block block, int row) -> {
boolean matched = true;
matched &= block.offerValue("bucket_name", row, objectSummary.getBucketName());
matched &= block.offerValue("e_tag", row, objectSummary.getETag());
matched &= block.offerValue("key", row, objectSummary.getKey());
matched &= block.offerValue("bytes", row, objectSummary.getSize());
matched &= block.offerValue("storage_class", row, objectSummary.getStorageClass());
matched &= block.offerValue("last_modified", row, objectSummary.getLastModified());
Owner owner = objectSummary.getOwner();
if (owner != null) {
matched &= block.offerValue("owner_name", row, owner.getDisplayName());
matched &= block.offerValue("owner_id", row, owner.getId());
}
return matched ? 1 : 0;
});
}
/**
* Maps a DBInstance into a row in our Apache Arrow response block(s).
*
* @param bucket The S3 Bucket to map.
* @param spiller The BlockSpiller to use when we want to write a matching row to the response.
* @note The current implementation is rather naive in how it maps fields. It leverages a static
* list of fields that we'd like to provide and then explicitly filters and converts each field.
*/
private void toRow(Bucket bucket,
BlockSpiller spiller)
{
spiller.writeRows((Block block, int row) -> {
boolean matched = true;
matched &= block.offerValue("bucket_name", row, bucket.getName());
matched &= block.offerValue("create_date", row, bucket.getCreationDate());
Owner owner = bucket.getOwner();
if (owner != null) {
matched &= block.offerValue("owner_name", row, bucket.getOwner().getDisplayName());
matched &= block.offerValue("owner_id", row, bucket.getOwner().getId());
}
return matched ? 1 : 0;
});
}
@Test
public void testUnknownContainerExists() {
TestExtendedS3FileSystem fs = new TestExtendedS3FileSystem();
AmazonS3 mockedS3Client = mock(AmazonS3.class);
Owner owner = new Owner();
owner.setId("2350f639447f872b12d9e2298200704aa3b70cea0e127d544748da0351f79118");
when(mockedS3Client.doesBucketExistV2(any(String.class))).thenReturn(true);
when(mockedS3Client.getS3AccountOwner()).thenReturn(owner);
AccessControlList acl = getAcl(mockedS3Client);
when(mockedS3Client.getBucketAcl(any(String.class))).thenReturn(acl);
fs.setCustomClient(mockedS3Client);
try {
assertNotNull(fs.getUnknownContainer("testunknown"));
} catch (IOException e) {
fail(e.getMessage());
}
}
/**
* Get the owner's display name
*/
public String getOwnerName() {
Owner owner = s3Summary.getOwner();
return owner != null ? owner.getDisplayName() : null;
}
/**
* Get the owner's Id.
*/
public String getOwnerId() {
Owner owner = s3Summary.getOwner();
return owner != null ? owner.getId() : null;
}
/** Unsupported Operation. */
@Override public Owner getS3AccountOwner() throws SdkClientException {
throw new UnsupportedOperationException("Operation not supported");
}
/** Unsupported Operation. */
@Override public Owner getS3AccountOwner(GetS3AccountOwnerRequest getS3AccountOwnerReq) throws SdkClientException {
throw new UnsupportedOperationException("Operation not supported");
}
@Override
public Owner getS3AccountOwner() throws AmazonClientException, AmazonServiceException {
// TODO Auto-generated method stub
return null;
}