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

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

Introduction

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

Prototype

public void setName(String name) 

Source Link

Document

Sets the name of the bucket.

Usage

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

License:Open Source License

public AmazonS3ClientMock(Path base) throws IOException {
    super(null);/*from  w  w  w .ja  v  a 2s  . com*/
    // 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.jav  a  2s  .  co  m

    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: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;
    }//  w ww  .  j  a  v  a 2 s  .  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);//w  w w. ja  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 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);
        }
    }
}