Example usage for com.amazonaws.services.s3.model S3ObjectSummary setOwner

List of usage examples for com.amazonaws.services.s3.model S3ObjectSummary setOwner

Introduction

In this page you can find the example usage for com.amazonaws.services.s3.model S3ObjectSummary setOwner.

Prototype

public void setOwner(Owner owner) 

Source Link

Document

Sets the owner of this object.

Usage

From source file:com.upplication.s3fs.util.AmazonS3ClientMock.java

License:Open Source License

/**
 * create a new S3ObjectSummary using the S3Element
 * @param elem S3Element to parse/*from   w w  w  .  j a  v  a2 s. com*/
 * @return S3ObjectSummary
 */
private S3ObjectSummary parseToS3ObjectSummary(S3Element elem) {
    S3ObjectSummary s3ObjectSummary = new S3ObjectSummary();
    s3ObjectSummary.setBucketName(elem.getS3Object().getBucketName());
    s3ObjectSummary.setKey(elem.getS3Object().getKey());
    s3ObjectSummary.setLastModified(elem.getS3Object().getObjectMetadata().getLastModified());
    s3ObjectSummary.setOwner(owner);
    s3ObjectSummary.setETag(elem.getS3Object().getObjectMetadata().getETag());
    s3ObjectSummary.setSize(elem.getS3Object().getObjectMetadata().getContentLength());

    return s3ObjectSummary;
}

From source file:org.weakref.s3fs.util.AmazonS3ClientMock.java

License:Apache License

@Override
public ObjectListing listObjects(ListObjectsRequest listObjectsRequest)
        throws AmazonClientException, AmazonServiceException {
    ObjectListing objectListing = new ObjectListing();
    Integer capacity = listObjectsRequest.getMaxKeys();
    if (capacity == null) {
        capacity = Integer.MAX_VALUE;
    }/*  w w  w.  ja  v a2 s.  com*/

    Bucket bucket = find(listObjectsRequest.getBucketName());
    for (S3Element elem : objects.get(bucket)) {
        if (capacity > 0) {
            // TODO. add delimiter and marker support
            if (listObjectsRequest.getPrefix() != null
                    && elem.getS3Object().getKey().startsWith(listObjectsRequest.getPrefix())) {
                S3ObjectSummary s3ObjectSummary = new S3ObjectSummary();
                s3ObjectSummary.setBucketName(elem.getS3Object().getBucketName());
                s3ObjectSummary.setKey(elem.getS3Object().getKey());
                s3ObjectSummary.setLastModified(elem.getS3Object().getObjectMetadata().getLastModified());
                s3ObjectSummary.setOwner(owner);
                s3ObjectSummary.setETag(elem.getS3Object().getObjectMetadata().getETag());
                s3ObjectSummary.setSize(elem.getS3Object().getObjectMetadata().getContentLength());
                objectListing.getObjectSummaries().add(s3ObjectSummary);
                capacity--;
            }
        }

    }

    return objectListing;
}