Example usage for com.amazonaws.services.s3.model CannedAccessControlList LogDeliveryWrite

List of usage examples for com.amazonaws.services.s3.model CannedAccessControlList LogDeliveryWrite

Introduction

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

Prototype

CannedAccessControlList LogDeliveryWrite

To view the source code for com.amazonaws.services.s3.model CannedAccessControlList LogDeliveryWrite.

Click Source Link

Document

Specifies the owner is granted Permission#FullControl and the GroupGrantee#LogDelivery group grantee is granted Permission#Write access so that access logs can be delivered.

Usage

From source file:com.mindtree.maven.S3Mojo.java

License:Apache License

private void createBucketAndUploadFiles() throws MojoExecutionException {
    for (int i = 0; i < bucketNames.length; i++) {
        String path = bucketNames[i];
        int index = path.indexOf("/");
        logger.debug("Got index of / : " + index);
        logger.debug("Trying upload for files with path : " + path);
        // The path to upload can have subdirectories hence only the first
        // directory (root) is required
        String rootBucket = path;
        if (index == 0) {
            logger.debug("Unique name bucket creation is required");
            rootBucket = UNIQUE;/*from  w  w  w . jav  a  2  s  .c  o  m*/
        } else if (index != -1) {
            logger.debug("Given name bucket creation is required");
            rootBucket = rootBucket.substring(0, index);
        }
        Bucket bucket = createS3Bucket(rootBucket);
        if (bucket != null) {
            List<File> fileList = mapFiles.get(path);
            logger.debug("Got fileList as null :: " + (fileList == null));
            if (fileList != null) {
                logger.debug("Size of fileList :" + fileList.size());
            }
            CannedAccessControlList cacl = CannedAccessControlList.Private;
            if (accessControls[i].equalsIgnoreCase(CannedAccessControlList.AuthenticatedRead.toString())) {
                cacl = CannedAccessControlList.AuthenticatedRead;
            } else if (accessControls[i]
                    .equalsIgnoreCase(CannedAccessControlList.BucketOwnerFullControl.toString())) {
                cacl = CannedAccessControlList.BucketOwnerFullControl;
            } else if (accessControls[i].equalsIgnoreCase(CannedAccessControlList.BucketOwnerRead.toString())) {
                cacl = CannedAccessControlList.BucketOwnerRead;
            } else if (accessControls[i]
                    .equalsIgnoreCase(CannedAccessControlList.LogDeliveryWrite.toString())) {
                cacl = CannedAccessControlList.LogDeliveryWrite;
            } else if (accessControls[i].equalsIgnoreCase(CannedAccessControlList.Private.toString())) {
                cacl = CannedAccessControlList.Private;
            } else if (accessControls[i].equalsIgnoreCase(CannedAccessControlList.PublicRead.toString())) {
                cacl = CannedAccessControlList.PublicRead;
            } else if (accessControls[i].equalsIgnoreCase(CannedAccessControlList.PublicReadWrite.toString())) {
                cacl = CannedAccessControlList.PublicReadWrite;
            }
            String bucketName = bucket.getName() + bucketNames[i].substring(bucketNames[i].indexOf("/"));
            logger.debug("File to upload to :" + bucketName);
            if (fileList != null && fileList.size() > 0) {
                if (!retainFolderStructure) {
                    logger.debug("Not retaining folder structure and uploadinf files");
                    System.out.println(cacl.toString());
                    List<PutObjectResult> fileUploadResults = S3Helper.uploadFiles(fileList, bucketName, s3,
                            cacl);
                } else {
                    logger.debug("Uploading with retained dir structure");
                    List<PutObjectResult> fileUploadResults = S3Helper.uploadFiles(fileList, bucketName, s3,
                            cacl, root);
                }
            }
        }
    }
}

From source file:org.alanwilliamson.amazon.AmazonKey.java

License:Open Source License

/**
 * private | public-read | public-read-write | authenticated-read | bucket-owner-read | bucket-owner-full-control | log-delivery-write
 *
 * @param acl/*w w  w. ja va2s  .  co m*/
 * @return
 */
public CannedAccessControlList getAmazonCannedAcl(String acl) {
    if (acl.equalsIgnoreCase("private"))
        return CannedAccessControlList.Private;
    else if (acl.equalsIgnoreCase("public-read") || acl.equalsIgnoreCase("publicread"))
        return CannedAccessControlList.PublicRead;
    else if (acl.equalsIgnoreCase("public-read-write") || acl.equalsIgnoreCase("publicreadwrite"))
        return CannedAccessControlList.PublicReadWrite;
    else if (acl.equalsIgnoreCase("authenticated-read") || acl.equalsIgnoreCase("authenticatedread"))
        return CannedAccessControlList.AuthenticatedRead;
    else if (acl.equalsIgnoreCase("bucket-owner-read") || acl.equalsIgnoreCase("bucketownerread"))
        return CannedAccessControlList.BucketOwnerRead;
    else if (acl.equalsIgnoreCase("bucket-owner-full-control")
            || acl.equalsIgnoreCase("bucketownerfullcontrol"))
        return CannedAccessControlList.BucketOwnerFullControl;
    else if (acl.equalsIgnoreCase("log-delivery-write") || acl.equalsIgnoreCase("logdeliverywrite"))
        return CannedAccessControlList.LogDeliveryWrite;
    else
        return CannedAccessControlList.Private;
}

From source file:org.entando.entando.plugins.jps3awsclient.aps.system.services.storage.AmazonS3StorageManager.java

License:Open Source License

public void checkForAndCreateBucket(String bucketName, AmazonS3Client client) {
    // Make sure it's lower case to comply with Amazon S3 recommendations
    bucketName = bucketName.toLowerCase();
    if (this._bucketMap.get(bucketName) == null) {
        if (client.doesBucketExist(bucketName)) {
            this._bucketMap.put(bucketName, true);
        } else {//from   w w w . ja  v a2  s .  co  m
            // Bucket hasn't been created yet so we create it
            CreateBucketRequest request = new CreateBucketRequest(bucketName);
            request.withCannedAcl(CannedAccessControlList.LogDeliveryWrite);
            client.createBucket(request);
            this._bucketMap.put(bucketName, true);
        }
    }
}