8
8
import software .amazon .awssdk .services .s3 .model .ObjectCannedACL ;
9
9
10
10
/**
11
- * <p>Amazon payload storage configuration options such as Amazon S3 client,
11
+ * <p>Amazon payload storage configuration options such as synchronous Amazon S3 client,
12
12
* bucket name, and payload size threshold for payloads.</p>
13
13
*
14
14
* <p>Server side encryption is optional and can be enabled using with {@link #withServerSideEncryption(ServerSideEncryptionStrategy)}
31
31
* @see software.amazon.payloadoffloading.ServerSideEncryptionFactory
32
32
*/
33
33
@ NotThreadSafe
34
- public class PayloadStorageConfiguration {
34
+ public class PayloadStorageConfiguration extends PayloadStorageConfigurationBase {
35
35
private static final Logger LOG = LoggerFactory .getLogger (PayloadStorageConfiguration .class );
36
36
37
37
private S3Client s3 ;
38
- private String s3BucketName ;
39
- private int payloadSizeThreshold = 0 ;
40
- private boolean alwaysThroughS3 = false ;
41
- private boolean payloadSupport = false ;
42
- /**
43
- * This field is optional, it is set only when we want to configure S3 Server Side Encryption with KMS.
44
- */
45
- private ServerSideEncryptionStrategy serverSideEncryptionStrategy ;
46
- /**
47
- * This field is optional, it is set only when we want to add access control list to Amazon S3 buckets and objects
48
- */
49
- private ObjectCannedACL objectCannedACL ;
50
38
51
39
public PayloadStorageConfiguration () {
52
40
s3 = null ;
53
- s3BucketName = null ;
54
- serverSideEncryptionStrategy = null ;
55
- objectCannedACL = null ;
56
41
}
57
42
58
43
public PayloadStorageConfiguration (PayloadStorageConfiguration other ) {
44
+ super (other );
59
45
this .s3 = other .getS3Client ();
60
- this .s3BucketName = other .getS3BucketName ();
61
- this .payloadSupport = other .isPayloadSupportEnabled ();
62
- this .alwaysThroughS3 = other .isAlwaysThroughS3 ();
63
- this .payloadSizeThreshold = other .getPayloadSizeThreshold ();
64
- this .serverSideEncryptionStrategy = other .getServerSideEncryptionStrategy ();
65
- this .objectCannedACL = other .getObjectCannedACL ();
66
46
}
67
47
68
48
/**
@@ -78,13 +58,8 @@ public void setPayloadSupportEnabled(S3Client s3, String s3BucketName) {
78
58
LOG .error (errorMessage );
79
59
throw SdkClientException .create (errorMessage );
80
60
}
81
- if (isPayloadSupportEnabled ()) {
82
- LOG .warn ("Payload support is already enabled. Overwriting AmazonS3Client and S3BucketName." );
83
- }
61
+ super .setPayloadSupportEnabled (s3BucketName );
84
62
this .s3 = s3 ;
85
- this .s3BucketName = s3BucketName ;
86
- this .payloadSupport = true ;
87
- LOG .info ("Payload support enabled." );
88
63
}
89
64
90
65
/**
@@ -104,10 +79,8 @@ public PayloadStorageConfiguration withPayloadSupportEnabled(S3Client s3, String
104
79
* Disables support for payloads.
105
80
*/
106
81
public void setPayloadSupportDisabled () {
82
+ super .setPayloadSupportDisabled ();
107
83
s3 = null ;
108
- s3BucketName = null ;
109
- payloadSupport = false ;
110
- LOG .info ("Payload support disabled." );
111
84
}
112
85
113
86
/**
@@ -120,15 +93,6 @@ public PayloadStorageConfiguration withPayloadSupportDisabled() {
120
93
return this ;
121
94
}
122
95
123
- /**
124
- * Check if the support for payloads if enabled.
125
- *
126
- * @return true if support for payloads is enabled.
127
- */
128
- public boolean isPayloadSupportEnabled () {
129
- return payloadSupport ;
130
- }
131
-
132
96
/**
133
97
* Gets the Amazon S3 client which is being used for storing payloads.
134
98
*
@@ -138,15 +102,6 @@ public S3Client getS3Client() {
138
102
return s3 ;
139
103
}
140
104
141
- /**
142
- * Gets the name of the S3 bucket which is being used for storing payload.
143
- *
144
- * @return The name of the bucket which is being used.
145
- */
146
- public String getS3BucketName () {
147
- return s3BucketName ;
148
- }
149
-
150
105
/**
151
106
* Sets the payload size threshold for storing payloads in Amazon S3.
152
107
*
@@ -159,25 +114,6 @@ public PayloadStorageConfiguration withPayloadSizeThreshold(int payloadSizeThres
159
114
return this ;
160
115
}
161
116
162
- /**
163
- * Gets the payload size threshold for storing payloads in Amazon S3.
164
- *
165
- * @return payload size threshold which is being used for storing in Amazon S3. Default: 256KB.
166
- */
167
- public int getPayloadSizeThreshold () {
168
- return payloadSizeThreshold ;
169
- }
170
-
171
- /**
172
- * Sets the payload size threshold for storing payloads in Amazon S3.
173
- *
174
- * @param payloadSizeThreshold Payload size threshold to be used for storing in Amazon S3.
175
- * Default: 256KB.
176
- */
177
- public void setPayloadSizeThreshold (int payloadSizeThreshold ) {
178
- this .payloadSizeThreshold = payloadSizeThreshold ;
179
- }
180
-
181
117
/**
182
118
* Sets whether or not all payloads regardless of their size should be stored in Amazon S3.
183
119
*
@@ -190,25 +126,6 @@ public PayloadStorageConfiguration withAlwaysThroughS3(boolean alwaysThroughS3)
190
126
return this ;
191
127
}
192
128
193
- /**
194
- * Checks whether or not all payloads regardless of their size are being stored in Amazon S3.
195
- *
196
- * @return True if all payloads regardless of their size are being stored in Amazon S3. Default: false
197
- */
198
- public boolean isAlwaysThroughS3 () {
199
- return alwaysThroughS3 ;
200
- }
201
-
202
- /**
203
- * Sets whether or not all payloads regardless of their size should be stored in Amazon S3.
204
- *
205
- * @param alwaysThroughS3 Whether or not all payloads regardless of their size
206
- * should be stored in Amazon S3. Default: false
207
- */
208
- public void setAlwaysThroughS3 (boolean alwaysThroughS3 ) {
209
- this .alwaysThroughS3 = alwaysThroughS3 ;
210
- }
211
-
212
129
/**
213
130
* Sets which method of server side encryption should be used, if required.
214
131
*
@@ -222,35 +139,6 @@ public PayloadStorageConfiguration withServerSideEncryption(ServerSideEncryption
222
139
return this ;
223
140
}
224
141
225
- /**
226
- * Sets which method of server side encryption should be use, if required.
227
- *
228
- * This is optional, it is set only when you want to configure S3 Server Side Encryption with KMS.
229
- *
230
- * @param serverSideEncryptionStrategy The method of encryption required for S3 server side encryption with KMS.
231
- */
232
- public void setServerSideEncryptionStrategy (ServerSideEncryptionStrategy serverSideEncryptionStrategy ) {
233
- this .serverSideEncryptionStrategy = serverSideEncryptionStrategy ;
234
- }
235
-
236
- /**
237
- * The method of service side encryption which should be used, if required.
238
- *
239
- * @return The server side encryption method required. Default null.
240
- */
241
- public ServerSideEncryptionStrategy getServerSideEncryptionStrategy () {
242
- return this .serverSideEncryptionStrategy ;
243
- }
244
-
245
- /**
246
- * Configures the ACL to apply to the Amazon S3 putObject request.
247
- * @param objectCannedACL
248
- * The ACL to be used when storing objects in Amazon S3
249
- */
250
- public void setObjectCannedACL (ObjectCannedACL objectCannedACL ) {
251
- this .objectCannedACL = objectCannedACL ;
252
- }
253
-
254
142
/**
255
143
* Configures the ACL to apply to the Amazon S3 putObject request.
256
144
* @param objectCannedACL
@@ -260,20 +148,4 @@ public PayloadStorageConfiguration withObjectCannedACL(ObjectCannedACL objectCan
260
148
setObjectCannedACL (objectCannedACL );
261
149
return this ;
262
150
}
263
-
264
- /**
265
- * Checks whether an ACL have been configured for storing objects in Amazon S3.
266
- * @return True if ACL is defined
267
- */
268
- public boolean isObjectCannedACLDefined () {
269
- return null != objectCannedACL ;
270
- }
271
-
272
- /**
273
- * Gets the AWS ACL to apply to the Amazon S3 putObject request.
274
- * @return Amazon S3 object ACL
275
- */
276
- public ObjectCannedACL getObjectCannedACL () {
277
- return objectCannedACL ;
278
- }
279
151
}
0 commit comments