Example usage for com.amazonaws.services.s3 AmazonS3 deleteBucketPolicy

List of usage examples for com.amazonaws.services.s3 AmazonS3 deleteBucketPolicy

Introduction

In this page you can find the example usage for com.amazonaws.services.s3 AmazonS3 deleteBucketPolicy.

Prototype

public void deleteBucketPolicy(DeleteBucketPolicyRequest deleteBucketPolicyRequest)
        throws SdkClientException, AmazonServiceException;

Source Link

Document

Deletes the policy associated with the specified bucket.

Usage

From source file:aws.example.s3.DeleteBucketPolicy.java

License:Open Source License

public static void main(String[] args) {
    final String USAGE = "\n" + "Usage:\n" + "    DeleteBucketPolicy <bucket>\n\n" + "Where:\n"
            + "    bucket - the bucket to delete the policy from.\n\n" + "Example:\n"
            + "    DeleteBucketPolicy testbucket\n\n";

    if (args.length < 1) {
        System.out.println(USAGE);
        System.exit(1);/*from   w  w  w.  j a  v  a2s  .  co  m*/
    }

    String bucket_name = args[0];
    String policy_text = null;

    System.out.format("Deleting policy from bucket: \"%s\"\n\n", bucket_name);

    final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient();
    try {
        s3.deleteBucketPolicy(bucket_name);
    } catch (AmazonServiceException e) {
        System.err.println(e.getErrorMessage());
        System.exit(1);
    }

    System.out.println("Done!");
}

From source file:org.duracloud.s3task.streaming.StreamingTaskRunnerTestBase.java

License:Apache License

protected AmazonS3 createMockS3ClientV3() throws Exception {
    AmazonS3 service = EasyMock.createMock(AmazonS3.class);

    service.deleteBucketPolicy(EasyMock.isA(String.class));
    EasyMock.expectLastCall().once();//from ww  w  . jav a 2  s  .  c om

    EasyMock.replay(service);
    return service;
}