Skip to content

Commit 6e3b9ab

Browse files
Release 3.1 (#21)
* fixed javadoc warnings in LifecycleRule.java * Bucket Policy Support (#20)
1 parent 86a80b2 commit 6e3b9ab

13 files changed

+772
-3
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ allprojects {
3939
}
4040

4141
dependencies {
42-
compile 'com.emc.ecs:smart-client:2.1.1',
42+
compile 'com.emc.ecs:smart-client:2.2.0',
4343
'com.emc.ecs:object-transform:1.1.0',
4444
'commons-codec:commons-codec:1.10',
4545
'org.jdom:jdom2:2.0.6',

src/main/java/com/emc/object/s3/S3Client.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,20 @@ public interface S3Client {
178178
*/
179179
void deleteBucketLifecycle(String bucketName);
180180

181+
/**
182+
* Sets the bucket policy for <code>bucketName</code>
183+
*
184+
* @see BucketPolicy
185+
*/
186+
void setBucketPolicy(String bucketName, BucketPolicy policy);
187+
188+
/**
189+
* Gets the bucket policy for <code>bucketName</code>
190+
*
191+
* @see BucketPolicy
192+
*/
193+
BucketPolicy getBucketPolicy(String bucketName);
194+
181195
/**
182196
* Gets the location of <code>bucketName</code>. This call will return the name of the primary VDC of the bucket
183197
*/
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
* Copyright (c) 2015, EMC Corporation.
3+
* Redistribution and use in source and binary forms, with or without modification,
4+
* are permitted provided that the following conditions are met:
5+
*
6+
* + Redistributions of source code must retain the above copyright notice,
7+
* this list of conditions and the following disclaimer.
8+
* + Redistributions in binary form must reproduce the above copyright
9+
* notice, this list of conditions and the following disclaimer in the
10+
* documentation and/or other materials provided with the distribution.
11+
* + The name of EMC Corporation may not be used to endorse or promote
12+
* products derived from this software without specific prior written
13+
* permission.
14+
*
15+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
19+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25+
* POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
package com.emc.object.s3.bean;
28+
29+
import javax.xml.bind.annotation.XmlElement;
30+
import javax.xml.bind.annotation.XmlRootElement;
31+
import javax.xml.bind.annotation.XmlType;
32+
import java.util.ArrayList;
33+
import java.util.Arrays;
34+
import java.util.List;
35+
36+
@XmlRootElement
37+
@XmlType(propOrder = {"id", "version", "statements"})
38+
public class BucketPolicy {
39+
private String id;
40+
private String version;
41+
private List<BucketPolicyStatement> statements = new ArrayList<BucketPolicyStatement>();
42+
43+
@XmlElement(name = "Id")
44+
public String getId() {
45+
return id;
46+
}
47+
48+
public void setId(String id) {
49+
this.id = id;
50+
}
51+
52+
@XmlElement(name = "Version")
53+
public String getVersion() {
54+
return version;
55+
}
56+
57+
public void setVersion(String version) {
58+
this.version = version;
59+
}
60+
61+
@XmlElement(name = "Statement")
62+
public List<BucketPolicyStatement> getStatements() {
63+
return statements;
64+
}
65+
66+
public void setStatements(List<BucketPolicyStatement> statements) {
67+
this.statements = statements;
68+
}
69+
70+
public BucketPolicy withId(String id) {
71+
setId(id);
72+
return this;
73+
}
74+
75+
public BucketPolicy withVersion(String version) {
76+
setVersion(version);
77+
return this;
78+
}
79+
80+
public BucketPolicy withStatements(List<BucketPolicyStatement> statement) {
81+
setStatements(statement);
82+
return this;
83+
}
84+
85+
public BucketPolicy withStatements(BucketPolicyStatement... statements) {
86+
setStatements(Arrays.asList(statements));
87+
return this;
88+
}
89+
90+
@Override
91+
public boolean equals(Object o) {
92+
if (this == o) return true;
93+
if (o == null || getClass() != o.getClass()) return false;
94+
95+
BucketPolicy that = (BucketPolicy) o;
96+
97+
if (id != null ? !id.equals(that.id) : that.id != null) return false;
98+
if (version != null ? !version.equals(that.version) : that.version != null) return false;
99+
return statements != null ? statements.equals(that.statements) : that.statements == null;
100+
}
101+
102+
@Override
103+
public int hashCode() {
104+
int result = id != null ? id.hashCode() : 0;
105+
result = 31 * result + (version != null ? version.hashCode() : 0);
106+
result = 31 * result + (statements != null ? statements.hashCode() : 0);
107+
return result;
108+
}
109+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
* Copyright (c) 2015-2018, EMC Corporation.
3+
* Redistribution and use in source and binary forms, with or without modification,
4+
* are permitted provided that the following conditions are met:
5+
*
6+
* + Redistributions of source code must retain the above copyright notice,
7+
* this list of conditions and the following disclaimer.
8+
* + Redistributions in binary form must reproduce the above copyright
9+
* notice, this list of conditions and the following disclaimer in the
10+
* documentation and/or other materials provided with the distribution.
11+
* + The name of EMC Corporation may not be used to endorse or promote
12+
* products derived from this software without specific prior written
13+
* permission.
14+
*
15+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
19+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25+
* POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
package com.emc.object.s3.bean;
28+
29+
import org.codehaus.jackson.annotate.JsonCreator;
30+
import org.codehaus.jackson.annotate.JsonValue;
31+
32+
import javax.xml.bind.annotation.XmlEnum;
33+
import javax.xml.bind.annotation.XmlEnumValue;
34+
35+
@XmlEnum
36+
public enum BucketPolicyAction {
37+
@XmlEnumValue("s3:*")
38+
All("s3:*"),
39+
@XmlEnumValue("s3:GetObject")
40+
GetObject("s3:GetObject"),
41+
@XmlEnumValue("s3:GetObjectVersion")
42+
GetObjectVersion("s3:GetObjectVersion"),
43+
@XmlEnumValue("s3:PutObject")
44+
PutObject("s3:PutObject"),
45+
@XmlEnumValue("s3:GetObjectAcl")
46+
GetObjectAcl("s3:GetObjectAcl"),
47+
@XmlEnumValue("s3:GetObjectVersionAcl")
48+
GetObjectVersionAcl("s3:GetObjectVersionAcl"),
49+
@XmlEnumValue("s3:PutObjectAcl")
50+
PutObjectAcl("s3:PutObjectAcl"),
51+
@XmlEnumValue("s3:PutObjectVersionAcl")
52+
PutObjectVersionAcl("s3:PutObjectVersionAcl"),
53+
@XmlEnumValue("s3:DeleteObject")
54+
DeleteObject("s3:DeleteObject"),
55+
@XmlEnumValue("s3:DeleteObjectVersion")
56+
DeleteObjectVersion("s3:DeleteObjectVersion"),
57+
@XmlEnumValue("s3:ListMultipartUploadParts")
58+
ListMultipartUploadParts("s3:ListMultipartUploadParts"),
59+
@XmlEnumValue("s3:AbortMultipartUpload")
60+
AbortMultipartUpload("s3:AbortMultipartUpload"),
61+
@XmlEnumValue("s3:DeleteBucket")
62+
DeleteBucket("s3:DeleteBucket"),
63+
@XmlEnumValue("s3:ListBucket")
64+
ListBucket("s3:ListBucket"),
65+
@XmlEnumValue("s3:ListBucketVersions")
66+
ListBucketVersions("s3:ListBucketVersions"),
67+
@XmlEnumValue("s3:GetLifecycleConfiguration")
68+
GetLifecycleConfiguration("s3:GetLifecycleConfiguration"),
69+
@XmlEnumValue("s3:PutLifecycleConfiguration")
70+
PutLifecycleConfiguration("s3:PutLifecycleConfiguration"),
71+
@XmlEnumValue("s3:GetBucketAcl")
72+
GetBucketAcl("s3:GetBucketAcl"),
73+
@XmlEnumValue("s3:PutBucketAcl")
74+
PutBucketAcl("s3:PutBucketAcl"),
75+
@XmlEnumValue("s3:GetBucketCORS")
76+
GetBucketCORS("s3:GetBucketCORS"),
77+
@XmlEnumValue("s3:PutBucketCORS")
78+
PutBucketCORS("s3:PutBucketCORS"),
79+
@XmlEnumValue("s3:GetBucketVersioning")
80+
GetBucketVersioning("s3:GetBucketVersioning"),
81+
@XmlEnumValue("s3:PutBucketVersioning")
82+
PutBucketVersioning("s3:PutBucketVersioning"),
83+
@XmlEnumValue("s3:GetBucketPolicy")
84+
GetBucketPolicy("s3:GetBucketPolicy"),
85+
@XmlEnumValue("s3:DeleteBucketPolicy")
86+
DeleteBucketPolicy("s3:DeleteBucketPolicy"),
87+
@XmlEnumValue("s3:PutBucketPolicy")
88+
PutBucketPolicy("s3:PutBucketPolicy");
89+
90+
@JsonCreator
91+
public static BucketPolicyAction fromValue(String value) {
92+
for (BucketPolicyAction instance : values()) {
93+
if (value.equals(instance.getActionName())) return instance;
94+
}
95+
return null;
96+
}
97+
98+
private String actionName;
99+
100+
BucketPolicyAction(String actionName) {
101+
this.actionName = actionName;
102+
}
103+
104+
@JsonValue
105+
public String getActionName() {
106+
return actionName;
107+
}
108+
109+
@Override
110+
public String toString() {
111+
return getActionName();
112+
}
113+
}

0 commit comments

Comments
 (0)