public static void main(String[] args) { final String USAGE = "\n" + "Usage:\n" + " GetBucketPolicy <bucket>\n\n" + "Where:\n" + " bucket - the bucket to get the policy from.\n\n" + "Example:\n" + " GetBucketPolicy testbucket\n\n"; if (args.length < 1) { System.out.println(USAGE); System.exit(1); } String bucket_name = args[0]; String policy_text = null; System.out.format("Getting policy for bucket: \"%s\"\n\n", bucket_name); final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient(); try { BucketPolicy bucket_policy = s3.getBucketPolicy(bucket_name); policy_text = bucket_policy.getPolicyText(); } catch (AmazonServiceException e) { System.err.println(e.getErrorMessage()); System.exit(1); } if (policy_text == null) { System.out.println("The specified bucket has no bucket policy."); } else { System.out.println("Returned policy:"); System.out.println("----"); System.out.println(policy_text); System.out.println("----\n"); } System.out.println("Done!"); }
@Override public BucketPolicy getBucketPolicy(String bucketName) throws AmazonClientException, AmazonServiceException { return delegate.getBucketPolicy(bucketName); }
@Override public BucketPolicy getBucketPolicy(GetBucketPolicyRequest getBucketPolicyRequest) throws AmazonClientException, AmazonServiceException { return delegate.getBucketPolicy(getBucketPolicyRequest); }
@Override public BucketPolicy getBucketPolicy(String bucketName) throws AmazonClientException, AmazonServiceException { throw new UnsupportedOperationException(); }
@Override public BucketPolicy getBucketPolicy(String bucketName) throws SdkClientException, AmazonServiceException { return call(() -> getDelegate().getBucketPolicy(bucketName)); }
@Override public BucketPolicy getBucketPolicy(GetBucketPolicyRequest getBucketPolicyRequest) throws SdkClientException, AmazonServiceException { return call(() -> getDelegate().getBucketPolicy(getBucketPolicyRequest)); }
@Override public BucketPolicy getBucketPolicy(String bucketName) throws AmazonClientException { return null; }
@Override public BucketPolicy getBucketPolicy(GetBucketPolicyRequest getBucketPolicyRequest) throws AmazonClientException { return null; }
@Override public BucketPolicy getBucketPolicy(String bucketName) throws AmazonClientException, AmazonServiceException { // TODO Auto-generated method stub return null; }
@Override public BucketPolicy getBucketPolicy(GetBucketPolicyRequest getBucketPolicyRequest) throws AmazonClientException, AmazonServiceException { // TODO Auto-generated method stub return null; }