Java 类com.amazonaws.services.s3.model.Owner 实例源码

项目:S3Mock    文件:AmazonClientUploadIT.java   
/**
 * Verify that buckets can be created and listed
 */
@Test
public void shouldCreateBucketAndListAllBuckets() {
  // the returned creation date might strip off the millisecond-part, resulting in rounding down
  // and account for a clock-skew in the Docker container of up to a minute.
  final Date creationDate = new Date((System.currentTimeMillis() / 1000) * 1000 - 60000);

  final Bucket bucket = s3Client.createBucket(BUCKET_NAME);
  assertThat(
      String.format("Bucket name should match '%s'!", BUCKET_NAME), bucket.getName(),
      equalTo(BUCKET_NAME));

  final List<Bucket> buckets =
      s3Client.listBuckets().stream().filter(b -> BUCKET_NAME.equals(b.getName()))
          .collect(Collectors.toList());

  assertThat("Expecting one bucket", buckets, hasSize(1));
  final Bucket createdBucket = buckets.get(0);

  assertThat(createdBucket.getCreationDate(), greaterThanOrEqualTo(creationDate));
  final Owner bucketOwner = createdBucket.getOwner();
  assertThat(bucketOwner.getDisplayName(), equalTo("s3-mock-file-store"));
  assertThat(bucketOwner.getId(), equalTo("123"));
}
项目:aws-java-sdk    文件:AmazonS3FakeServiceTest.java   
@Test
public void checkNewlyAddedBuckets() {
    Instant addedTime1 = LocalDateTime.of(2015, 10, 15, 12, 25).toInstant(ZoneOffset.UTC);
    Instant addedTime2 = LocalDateTime.of(2015, 10, 15, 13, 30).toInstant(ZoneOffset.UTC);
    when(clock.instant()).thenReturn(addedTime1, addedTime2);

    s3.createBucket("new_bucket_1");
    s3.createBucket("new_bucket_2");
    List<Bucket> buckets = s3.listBuckets();

    assertThat(buckets).hasSize(2);
    assertThat(getBucketWithName("new_bucket_1", buckets).getCreationDate()).isEqualTo(Date.from(addedTime1));
    assertThat(getBucketWithName("new_bucket_2", buckets).getCreationDate()).isEqualTo(Date.from(addedTime2));

    buckets.forEach(bucket -> {
        Owner owner = bucket.getOwner();
        assertThat(owner.getDisplayName()).isEqualTo("test");
        assertThat(owner.getId()).isNotEmpty();
    });
}
项目:alfred-mpi    文件:S3ObjectSummaryWritable.java   
@Override
public void readFields(DataInput in) throws IOException {
    this.setBucketName(Text.readString(in));
    this.setKey(Text.readString(in));
    this.setETag(Text.readString(in));
    this.setStorageClass(Text.readString(in));

    // Set owner
    Owner owner = new Owner();
    owner.setId(Text.readString(in));
    owner.setDisplayName(Text.readString(in));

    this.setOwner(owner);
    this.setSize(in.readLong());
    this.setLastModified(new Date(in.readLong()));
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public List<Bucket> listBuckets() throws AmazonClientException, AmazonServiceException {
    ArrayList<Bucket> list = new ArrayList<Bucket>();
    Bucket bucket = new Bucket("camel-bucket");
    bucket.setOwner(new Owner("Camel", "camel"));
    bucket.setCreationDate(new Date());
    list.add(bucket);
    return list;
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public Bucket createBucket(CreateBucketRequest createBucketRequest) throws AmazonClientException, AmazonServiceException {
    if ("nonExistingBucket".equals(createBucketRequest.getBucketName())) {
        nonExistingBucketCreated = true; 
    }

    Bucket bucket = new Bucket();
    bucket.setName(createBucketRequest.getBucketName());
    bucket.setCreationDate(new Date());
    bucket.setOwner(new Owner("c2efc7302b9011ba9a78a92ac5fd1cd47b61790499ab5ddf5a37c31f0638a8fc ", "Christian Mueller"));
    return bucket;
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public List<Bucket> listBuckets() throws AmazonClientException, AmazonServiceException {
    ArrayList<Bucket> list = new ArrayList<Bucket>();
    Bucket bucket = new Bucket("camel-bucket");
    bucket.setOwner(new Owner("Camel", "camel"));
    bucket.setCreationDate(new Date());
    list.add(bucket);
    return list;
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public Bucket createBucket(CreateBucketRequest createBucketRequest) throws AmazonClientException, AmazonServiceException {
    if ("nonExistingBucket".equals(createBucketRequest.getBucketName())) {
        nonExistingBucketCreated = true; 
    }

    Bucket bucket = new Bucket();
    bucket.setName(createBucketRequest.getBucketName());
    bucket.setCreationDate(new Date());
    bucket.setOwner(new Owner("c2efc7302b9011ba9a78a92ac5fd1cd47b61790499ab5ddf5a37c31f0638a8fc ", "Christian Mueller"));
    return bucket;
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public List<Bucket> listBuckets() throws AmazonClientException, AmazonServiceException {
    ArrayList<Bucket> list = new ArrayList<Bucket>();
    Bucket bucket = new Bucket("camel-bucket");
    bucket.setOwner(new Owner("Camel", "camel"));
    bucket.setCreationDate(new Date());
    list.add(bucket);
    return list;
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public Bucket createBucket(CreateBucketRequest createBucketRequest) throws AmazonClientException, AmazonServiceException {
    if ("nonExistingBucket".equals(createBucketRequest.getBucketName())) {
        nonExistingBucketCreated = true; 
    }

    Bucket bucket = new Bucket();
    bucket.setName(createBucketRequest.getBucketName());
    bucket.setCreationDate(new Date());
    bucket.setOwner(new Owner("c2efc7302b9011ba9a78a92ac5fd1cd47b61790499ab5ddf5a37c31f0638a8fc ", "Christian Mueller"));
    return bucket;
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public List<Bucket> listBuckets() throws AmazonClientException, AmazonServiceException {
    ArrayList<Bucket> list = new ArrayList<Bucket>();
    Bucket bucket = new Bucket("camel-bucket");
    bucket.setOwner(new Owner("Camel", "camel"));
    bucket.setCreationDate(new Date());
    list.add(bucket);
    return list;
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public Bucket createBucket(CreateBucketRequest createBucketRequest) throws AmazonClientException, AmazonServiceException {
    if ("nonExistingBucket".equals(createBucketRequest.getBucketName())) {
        nonExistingBucketCreated = true; 
    }

    Bucket bucket = new Bucket();
    bucket.setName(createBucketRequest.getBucketName());
    bucket.setCreationDate(new Date());
    bucket.setOwner(new Owner("c2efc7302b9011ba9a78a92ac5fd1cd47b61790499ab5ddf5a37c31f0638a8fc ", "Christian Mueller"));
    return bucket;
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public List<Bucket> listBuckets() throws AmazonClientException, AmazonServiceException {
    ArrayList<Bucket> list = new ArrayList<Bucket>();
    Bucket bucket = new Bucket("camel-bucket");
    bucket.setOwner(new Owner("Camel", "camel"));
    bucket.setCreationDate(new Date());
    list.add(bucket);
    return list;
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public Bucket createBucket(CreateBucketRequest createBucketRequest) throws AmazonClientException, AmazonServiceException {
    if ("nonExistingBucket".equals(createBucketRequest.getBucketName())) {
        nonExistingBucketCreated = true; 
    }

    Bucket bucket = new Bucket();
    bucket.setName(createBucketRequest.getBucketName());
    bucket.setCreationDate(new Date());
    bucket.setOwner(new Owner("c2efc7302b9011ba9a78a92ac5fd1cd47b61790499ab5ddf5a37c31f0638a8fc ", "Christian Mueller"));
    return bucket;
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public List<Bucket> listBuckets() throws AmazonClientException, AmazonServiceException {
    ArrayList<Bucket> list = new ArrayList<Bucket>();
    Bucket bucket = new Bucket("camel-bucket");
    bucket.setOwner(new Owner("Camel", "camel"));
    bucket.setCreationDate(new Date());
    list.add(bucket);
    return list;
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public Bucket createBucket(CreateBucketRequest createBucketRequest) throws AmazonClientException, AmazonServiceException {
    if ("nonExistingBucket".equals(createBucketRequest.getBucketName())) {
        nonExistingBucketCreated = true; 
    }

    Bucket bucket = new Bucket();
    bucket.setName(createBucketRequest.getBucketName());
    bucket.setCreationDate(new Date());
    bucket.setOwner(new Owner("c2efc7302b9011ba9a78a92ac5fd1cd47b61790499ab5ddf5a37c31f0638a8fc ", "Christian Mueller"));
    return bucket;
}
项目:ibm-cos-sdk-java    文件:AmazonS3Client.java   
@Override
public Owner getS3AccountOwner(GetS3AccountOwnerRequest getS3AccountOwnerRequest)
        throws SdkClientException, AmazonServiceException {
    getS3AccountOwnerRequest = beforeClientExecution(getS3AccountOwnerRequest);
    rejectNull(getS3AccountOwnerRequest, "The request object parameter getS3AccountOwnerRequest must be specified.");
    Request<GetS3AccountOwnerRequest> request = createRequest(null, null, getS3AccountOwnerRequest, HttpMethodName.GET);
    return invoke(request, new Unmarshallers.ListBucketsOwnerUnmarshaller(), null, null);
}
项目:ibm-cos-sdk-java    文件:AclXmlFactory.java   
/**
 * Converts the specified AccessControlList object to an XML fragment that
 * can be sent to Amazon S3.
 *
 * @param acl
 *            The AccessControlList to convert to XML.
 *
 * @return an XML representation of the Access Control List object, suitable
 *         to send in a request to Amazon S3.
 */
public byte[] convertToXmlByteArray(AccessControlList acl) throws SdkClientException {
    Owner owner = acl.getOwner();
    if (owner == null) {
        throw new SdkClientException("Invalid AccessControlList: missing an S3Owner");
    }

    XmlWriter xml = new XmlWriter();
    xml.start("AccessControlPolicy", "xmlns", Constants.XML_NAMESPACE);
    xml.start("Owner");
    if (owner.getId() != null) {
        xml.start("ID").value(owner.getId()).end();
    }
    if (owner.getDisplayName() != null) {
        xml.start("DisplayName").value(owner.getDisplayName()).end();
    }
    xml.end();
    xml.start("AccessControlList");
    for (Grant grant : acl.getGrantsAsList()) {
        xml.start("Grant");
        convertToXml(grant.getGrantee(), xml);
        xml.start("Permission").value(grant.getPermission().toString()).end();
        xml.end();
    }
    xml.end();
    xml.end();

    return xml.getBytes();
}
项目:Camel    文件:AmazonS3ClientMock.java   
@Override
public Bucket createBucket(CreateBucketRequest createBucketRequest) throws AmazonClientException, AmazonServiceException {
    if ("nonExistingBucket".equals(createBucketRequest.getBucketName())) {
        nonExistingBucketCreated = true; 
    }

    Bucket bucket = new Bucket();
    bucket.setName(createBucketRequest.getBucketName());
    bucket.setCreationDate(new Date());
    bucket.setOwner(new Owner("c2efc7302b9011ba9a78a92ac5fd1cd47b61790499ab5ddf5a37c31f0638a8fc ", "Christian Mueller"));
    return bucket;
}
项目:gocd-s3-poller    文件:PackageRepositoryPollerTest.java   
private List<S3ObjectSummary> getObjectsInBucket(Date... dates) {
    List<S3ObjectSummary> list = new ArrayList<S3ObjectSummary>();
    for (Date date : dates) {
        S3ObjectSummary s3Object = new S3ObjectSummary();
        s3Object.setKey("dummy-key");
        s3Object.setLastModified(date);
        s3Object.setOwner(new Owner("123", "username"));
        list.add(s3Object);
    }
    return list;
}
项目:wildlife-camera-machine    文件:S3ImageStore.java   
public S3ImageStore(String accessKey, String secretKey, String bucketName) {
    this.bucketName = bucketName;
    this.myAccessKeyID = accessKey;
    this.mySecretKey = secretKey;
    AWSCredentials myCredentials = new BasicAWSCredentials( myAccessKeyID, mySecretKey);
    s3Client = new AmazonS3Client(myCredentials);        
    Owner o = s3Client.getS3AccountOwner();
    log.info("using S3 as "+o.getDisplayName());
    List<Bucket> bl =s3Client.listBuckets();
    for(Bucket b : bl) {
        log.info("  bucket:"+b.getName());
    }

}
项目:elasticsearch_my    文件:AmazonS3Wrapper.java   
@Override
public Owner getS3AccountOwner() throws AmazonClientException, AmazonServiceException {
    return delegate.getS3AccountOwner();
}
项目:elasticsearch_my    文件:AmazonS3Wrapper.java   
@Override
public Owner getS3AccountOwner(GetS3AccountOwnerRequest getS3AccountOwnerRequest) throws AmazonClientException, AmazonServiceException {
    return delegate.getS3AccountOwner(getS3AccountOwnerRequest);
}
项目:ats-framework    文件:S3ObjectInfo.java   
/**
 * Get the owner's display name
 */
public String getOwnerName() {
    Owner owner = s3Summary.getOwner();
    return owner != null ? owner.getDisplayName() : null;
}
项目:ats-framework    文件:S3ObjectInfo.java   
/**
 * Get the owner's Id.
 */
public String getOwnerId() {
    Owner owner = s3Summary.getOwner();
    return owner != null ? owner.getId() : null;
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public Owner getS3AccountOwner() throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public Owner getS3AccountOwner() throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:syndesis    文件:AmazonS3ClientMock.java   
@Override
public Owner getS3AccountOwner() throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public Owner getS3AccountOwner() throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public Owner getS3AccountOwner() throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:connectors    文件:AmazonS3ClientMock.java   
@Override
public Owner getS3AccountOwner() throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:ibm-cos-sdk-java    文件:AmazonS3Client.java   
@Override
public Owner getS3AccountOwner()
        throws SdkClientException, AmazonServiceException {
    return getS3AccountOwner(new GetS3AccountOwnerRequest());
}
项目:S3Decorators    文件:S3Decorator.java   
@Override
public Owner getS3AccountOwner() throws SdkClientException, AmazonServiceException {
  return call(() -> getDelegate().getS3AccountOwner());
}
项目:S3Decorators    文件:S3Decorator.java   
@Override
public Owner getS3AccountOwner(GetS3AccountOwnerRequest getS3AccountOwnerRequest) throws SdkClientException, AmazonServiceException {
  return call(() -> getDelegate().getS3AccountOwner(getS3AccountOwnerRequest));
}
项目:Camel    文件:AmazonS3ClientMock.java   
@Override
public Owner getS3AccountOwner() throws AmazonClientException, AmazonServiceException {
    throw new UnsupportedOperationException();
}
项目:aws-java-sdk    文件:OwnerAssert.java   
protected OwnerAssert(Owner actual) {
    super(actual, OwnerAssert.class);
}
项目:aws-java-sdk    文件:AssertionsTest.java   
@Test
public void incorrectOwnerDisplayName() {
    assertThatThrownBy(() -> assertThat(mock(Owner.class)).hasDisplayName("test"))
            .hasMessageContaining("have displayName");
}
项目:presto    文件:MockAmazonS3.java   
@Override
public Owner getS3AccountOwner()
        throws AmazonClientException
{
    return null;
}
项目:Scribengin    文件:AmazonS3Mock.java   
@Override
public Owner getS3AccountOwner() throws AmazonClientException, AmazonServiceException {
  // TODO Auto-generated method stub
  return null;
}
项目:alfred-mpi    文件:S3ObjectSummaryWritableTest.java   
/**
 * Tests S3Object serialization and deserialization
 */
@Test
public void testReadWrite() {
    S3ObjectSummaryWritable objIn = new S3ObjectSummaryWritable();
    S3ObjectSummaryWritable objOut = new S3ObjectSummaryWritable();

    // serialized object
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);

    // serialized object reader
    ByteArrayInputStream bais = null;
    DataInputStream dis = null;

    //Date
    Date date = new Date();

    //Owner
    Owner owner = new Owner("id", "displayName");

    objIn.setBucketName("bucketName");
    objIn.setKey("key");
    objIn.setETag("eTag");
    objIn.setLastModified(date);
    objIn.setSize(12345);
    objIn.setStorageClass("storageClass");
    objIn.setOwner(owner);

    try {
        objIn.write(dos);

        // create input reader
        bais = new ByteArrayInputStream(baos.toByteArray());
        dis = new DataInputStream(bais);

        objOut.readFields(dis);

        Assert.assertEquals(objIn.getBucketName(), objOut.getBucketName());
        Assert.assertEquals(objIn.getETag(), objOut.getETag());
        Assert.assertEquals(objIn.getLastModified(), objOut.getLastModified());
        Assert.assertEquals(objIn.getSize(), objOut.getSize());
        Assert.assertEquals(objIn.getStorageClass(), objOut.getStorageClass());
        Assert.assertEquals(objIn.getOwner(), objOut.getOwner());

    } catch (IOException e) {
        e.printStackTrace();
        fail("Exeception while writing data to out stream.");
    }
}