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

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

Introduction

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

Prototype

public String getDelimiter() 

Source Link

Document

Gets the optional delimiter parameter that causes keys that contain the same string between the prefix and the first occurrence of the delimiter to be combined into a single result element in the ObjectListing#getCommonPrefixes() list.

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  w  w .  j ava2 s. co m
 */
@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 a 2  s  .c  om
    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;
}