@@ -56,10 +56,14 @@ public class S3AddImportsAndComments extends Recipe {
56
56
57
57
private static final Pattern CANNED_ACL = Pattern .compile (V1_S3_MODEL_PKG + "CannedAccessControlList" );
58
58
private static final Pattern GET_OBJECT_REQUEST = Pattern .compile (V1_S3_MODEL_PKG + "GetObjectRequest" );
59
+ private static final Pattern CREATE_BUCKET_REQUEST = Pattern .compile (V1_S3_MODEL_PKG + "CreateBucketRequest" );
60
+ private static final Pattern DELETE_OBJECTS_RESULT = Pattern .compile (V1_S3_MODEL_PKG + "DeleteObjectsResult" );
59
61
private static final Pattern INITIATE_MPU = Pattern .compile (V1_S3_MODEL_PKG + "InitiateMultipartUpload" );
60
62
private static final Pattern MULTI_FACTOR_AUTH = Pattern .compile (V1_S3_MODEL_PKG + "MultiFactorAuthentication" );
61
63
private static final Pattern SET_BUCKET_VERSION_REQUEST = Pattern .compile (V1_S3_MODEL_PKG
62
64
+ "SetBucketVersioningConfigurationRequest" );
65
+ private static final Pattern BUCKET_NOTIFICATION_CONFIG = Pattern .compile (V1_S3_MODEL_PKG
66
+ + "BucketNotificationConfiguration" );
63
67
64
68
@ Override
65
69
public String getDisplayName () {
@@ -167,15 +171,15 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
167
171
if (SET_PAYMENT_CONFIGURATION .matches (method )) {
168
172
String comment = "Transform for setRequestPaymentConfiguration method not supported. Payer enum is a "
169
173
+ "separate class in v2 (not nested). Please manually migrate "
170
- + "your code by update from RequestPaymentConfiguration.Payer to just Payer, and adjust "
174
+ + "your code by updating from RequestPaymentConfiguration.Payer to just Payer, and adjust "
171
175
+ "imports and names." ;
172
176
return method .withComments (createComments (comment ));
173
177
}
174
178
175
179
if (SET_LIFECYCLE_CONFIGURATION .matches (method )) {
176
180
// TODO: add the developer guide link in the comments once the doc is published.
177
181
String comment = "Transform for setBucketLifecycleConfiguration method not supported. Please manually migrate"
178
- + " your code by using builder pattern, update from BucketLifecycleConfiguration.Rule to "
182
+ + " your code by using builder pattern, updating from BucketLifecycleConfiguration.Rule to "
179
183
+ "LifecycleRule, StorageClass to TransitionStorageClass, and adjust "
180
184
+ "imports and names." ;
181
185
return method .withComments (createComments (comment ));
@@ -223,6 +227,30 @@ public J.NewClass visitNewClass(J.NewClass newClass, ExecutionContext ctx) {
223
227
return newClass .withComments (createComments (comment ));
224
228
}
225
229
230
+ if (type .isAssignableFrom (CREATE_BUCKET_REQUEST ) && newClass .getArguments ().size () == 2 ) {
231
+ String comment = "Transform for createBucketRequest with region is not supported. Please manually "
232
+ + "migrate your code by configuring the region as locationConstraint in "
233
+ + "createBucketConfiguration in the request builder" ;
234
+ return newClass .withComments (createComments (comment ));
235
+ }
236
+
237
+ if (type .isAssignableFrom (DELETE_OBJECTS_RESULT )) {
238
+ String comment = "Transform for DeleteObjectsResult class is not supported. DeletedObject class is a "
239
+ + "separate class in v2 (not nested). Please manually migrate your code by updating "
240
+ + "DeleteObjectsResult.DeletedObject to s3.model.DeletedObject" ;
241
+ return newClass .withComments (createComments (comment ));
242
+ }
243
+
244
+ if (type .isAssignableFrom (BUCKET_NOTIFICATION_CONFIG )) {
245
+ // TODO: add the developer guide link in the comments once the doc is published.
246
+ String comment = "Transform for BucketNotificationConfiguration class is not supported. "
247
+ + "BucketNotificationConfiguration is renamed to NotificationConfiguration. There is no common"
248
+ + " abstract class for lambdaFunction/topic/queue configurations. Use specific builders "
249
+ + "instead of addConfiguration() to add configurations. Change the vararg arguments or EnumSet "
250
+ + "in specific configurations constructor to List<String> in v2" ;
251
+ return newClass .withComments (createComments (comment ));
252
+ }
253
+
226
254
return newClass ;
227
255
}
228
256
0 commit comments