Example usage for com.amazonaws.services.s3.model ListObjectsRequest getMarker

List of usage examples for com.amazonaws.services.s3.model ListObjectsRequest getMarker

Introduction

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

Prototype

public String getMarker() 

Source Link

Document

Gets the optional marker parameter indicating where in the bucket to begin listing.

Usage

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

License:Open Source License

/**
 * list all objects without and return ObjectListing with all elements
 * and with truncated to false//from   w ww.  j  a  va2 s .c  om
 */
@Override
public ObjectListing listObjects(ListObjectsRequest listObjectsRequest) throws AmazonClientException {

    ObjectListing objectListing = new ObjectListing();
    objectListing.setBucketName(listObjectsRequest.getBucketName());
    objectListing.setPrefix(listObjectsRequest.getPrefix());
    objectListing.setMarker(listObjectsRequest.getMarker());
    objectListing.setDelimiter(listObjectsRequest.getDelimiter());

    Bucket bucket = find(listObjectsRequest.getBucketName());
    Iterator<S3Element> iterator = objects.get(bucket).iterator();

    int i = 0;

    while (iterator.hasNext()) {

        S3Element elem = iterator.next();

        // TODO. add delimiter and marker support
        if (listObjectsRequest.getPrefix() != null
                && elem.getS3Object().getKey().startsWith(listObjectsRequest.getPrefix())) {

            S3ObjectSummary s3ObjectSummary = parseToS3ObjectSummary(elem);
            objectListing.getObjectSummaries().add(s3ObjectSummary);

            if (i + 1 == LIMIT_AWS_MAX_ELEMENTS && iterator.hasNext()) {
                objectListing.setTruncated(true);
                objectListing.setNextMarker(iterator.next().getS3Object().getKey());
                return objectListing;
            } else {
                objectListing.setTruncated(false);
            }

            i++;
        }

    }

    return objectListing;
}

From source file:fi.yle.tools.aws.maven.matchers.ListObjectsRequestMatcher.java

License:Apache License

@Override
public boolean matches(Object obj) {
    if (this.listObjectsRequest == obj) {
        return true;
    }//  w  w  w  .j  a  v a2  s. co  m
    if (obj == null) {
        return false;
    }
    if (ListObjectsRequest.class != obj.getClass()) {
        return false;
    }
    ListObjectsRequest other = (ListObjectsRequest) obj;
    if (this.listObjectsRequest.getBucketName() == null) {
        if (other.getBucketName() != null) {
            return false;
        }
    } else if (!this.listObjectsRequest.getBucketName().equals(other.getBucketName())) {
        return false;
    }
    if (this.listObjectsRequest.getPrefix() == null) {
        if (other.getPrefix() != null) {
            return false;
        }
    } else if (!this.listObjectsRequest.getPrefix().equals(other.getPrefix())) {
        return false;
    }
    if (this.listObjectsRequest.getDelimiter() == null) {
        if (other.getDelimiter() != null) {
            return false;
        }
    } else if (!this.listObjectsRequest.getDelimiter().equals(other.getDelimiter())) {
        return false;
    }
    if (this.listObjectsRequest.getMarker() == null) {
        if (other.getMarker() != null) {
            return false;
        }
    } else if (!this.listObjectsRequest.getMarker().equals(other.getMarker())) {
        return false;
    }
    if (this.listObjectsRequest.getMaxKeys() == null) {
        if (other.getMaxKeys() != null) {
            return false;
        }
    } else if (!this.listObjectsRequest.getMaxKeys().equals(other.getMaxKeys())) {
        return false;
    }
    return true;
}