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

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

Introduction

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

Prototype

public void setOwner(Owner owner) 

Source Link

Document

For internal use only.

Usage

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

License:Open Source License

public AmazonS3ClientMock(Path base) throws IOException {
    super(null);//  w ww.j  a  va 2  s . c  o m
    // construimos el bucket
    // 1 level: buckets
    try (DirectoryStream<Path> dir = Files.newDirectoryStream(base)) {
        for (final Path bucketPath : dir) {
            BasicFileAttributes attr = Files.readAttributes(bucketPath, BasicFileAttributes.class);
            final Bucket bucket = new Bucket();
            bucket.setCreationDate(new Date(attr.creationTime().toMillis()));
            bucket.setName(bucketPath.getFileName().toString());
            bucket.setOwner(owner);
            final LinkedHashSet<S3Element> elemnts = new LinkedHashSet<>();
            // all s3object
            Files.walkFileTree(bucketPath, new SimpleFileVisitor<Path>() {
                @Override
                public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
                        throws IOException {
                    if (Files.newDirectoryStream(dir).iterator().hasNext()) {
                        // add only last elements
                        return FileVisitResult.CONTINUE;
                    } else {
                        S3Element obj = parse(dir, bucketPath);

                        elemnts.add(obj);
                    }

                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                    S3Element obj = parse(file, bucketPath);
                    elemnts.add(obj);
                    return FileVisitResult.CONTINUE;
                }
            });
            objects.put(bucket, elemnts);
        }
    }
}

From source file:edu.si.services.beans.cameratrap.AmazonS3ClientMock.java

License:Apache License

@Override
public Bucket createBucket(CreateBucketRequest createBucketRequest)
        throws AmazonClientException, AmazonServiceException {
    if ("nonExistingBucket".equals(createBucketRequest.getBucketName())) {
        nonExistingBucketCreated = true;
    }/*from  w  ww . j ava  2 s. com*/

    Bucket bucket = new Bucket();
    bucket.setName(createBucketRequest.getBucketName());
    bucket.setCreationDate(new Date());
    bucket.setOwner(new Owner("c2efc7302b9011ba9a78a92ac5fd1cd47b61790499ab5ddf5a37c31f0638a8fc ",
            "Christian Mueller"));
    buckets.add(bucket);
    return bucket;
}

From source file:eu.openg.aws.s3.internal.AmazonS3Fake.java

License:Apache License

private void addBucket(String bucketName) {
    Bucket bucket = new Bucket(bucketName);
    bucket.setOwner(OWNER);
    bucket.setCreationDate(Date.from(clock.instant()));
    buckets.put(bucketName, new FakeBucketsContainer(bucket, clock));
}

From source file:org.apache.camel.component.aws.s3.AmazonS3ClientMock.java

License:Apache License

@Override
public Bucket createBucket(CreateBucketRequest createBucketRequest)
        throws AmazonClientException, AmazonServiceException {
    if ("nonExistingBucket".equals(createBucketRequest.getBucketName())) {
        nonExistingBucketCreated = true;
    }/*from   w ww  . j av  a 2s. c o  m*/

    Bucket bucket = new Bucket();
    bucket.setName(createBucketRequest.getBucketName());
    bucket.setCreationDate(new Date());
    bucket.setOwner(new Owner("c2efc7302b9011ba9a78a92ac5fd1cd47b61790499ab5ddf5a37c31f0638a8fc ",
            "Christian Mueller"));
    return bucket;
}

From source file:org.apache.camel.itest.osgi.aws.AmazonS3ClientMock.java

License:Apache License

@Override
public Bucket createBucket(CreateBucketRequest createBucketRequest)
        throws AmazonClientException, AmazonServiceException {
    Bucket bucket = new Bucket();
    bucket.setName(createBucketRequest.getBucketName());
    bucket.setCreationDate(new Date());
    bucket.setOwner(new Owner("c2efc7302b9011ba9a78a92ac5fd1cd47b61790499ab5ddf5a37c31f0638a8fc ",
            "Christian Mueller"));
    return bucket;
}

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

License:Apache License

public AmazonS3ClientMock(Path base) throws IOException {
    super(null);/*ww  w.  java  2 s . c o m*/
    // construimos el bucket
    // 1 level: buckets
    try (DirectoryStream<Path> dir = Files.newDirectoryStream(base)) {
        for (final Path bucketPath : dir) {
            BasicFileAttributes attr = Files.readAttributes(bucketPath, BasicFileAttributes.class);
            final Bucket bucket = new Bucket();
            bucket.setCreationDate(new Date(attr.creationTime().toMillis()));
            bucket.setName(bucketPath.getFileName().toString());
            bucket.setOwner(owner);
            final List<S3Element> elemnts = new ArrayList<>();
            // all s3object
            Files.walkFileTree(bucketPath, new SimpleFileVisitor<Path>() {
                @Override
                public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
                        throws IOException {
                    if (Files.newDirectoryStream(dir).iterator().hasNext()) {
                        // add only last elements
                        return FileVisitResult.CONTINUE;
                    } else {
                        S3Element obj = parse(dir, bucketPath);

                        elemnts.add(obj);
                    }

                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                    S3Element obj = parse(file, bucketPath);
                    elemnts.add(obj);
                    return FileVisitResult.CONTINUE;
                }
            });
            objects.put(bucket, elemnts);
        }
    }
}