Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ public class S3AddImportsAndComments extends Recipe {

private static final Pattern CANNED_ACL = Pattern.compile(V1_S3_MODEL_PKG + "CannedAccessControlList");
private static final Pattern GET_OBJECT_REQUEST = Pattern.compile(V1_S3_MODEL_PKG + "GetObjectRequest");
private static final Pattern CREATE_BUCKET_REQUEST = Pattern.compile(V1_S3_MODEL_PKG + "CreateBucketRequest");
private static final Pattern DELETE_OBJECTS_RESULT = Pattern.compile(V1_S3_MODEL_PKG + "DeleteObjectsResult");
private static final Pattern INITIATE_MPU = Pattern.compile(V1_S3_MODEL_PKG + "InitiateMultipartUpload");
private static final Pattern MULTI_FACTOR_AUTH = Pattern.compile(V1_S3_MODEL_PKG + "MultiFactorAuthentication");
private static final Pattern SET_BUCKET_VERSION_REQUEST = Pattern.compile(V1_S3_MODEL_PKG
+ "SetBucketVersioningConfigurationRequest");
private static final Pattern BUCKET_NOTIFICATION_CONFIG = Pattern.compile(V1_S3_MODEL_PKG
+ "BucketNotificationConfiguration");

@Override
public String getDisplayName() {
Expand Down Expand Up @@ -167,15 +171,15 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
if (SET_PAYMENT_CONFIGURATION.matches(method)) {
String comment = "Transform for setRequestPaymentConfiguration method not supported. Payer enum is a "
+ "separate class in v2 (not nested). Please manually migrate "
+ "your code by update from RequestPaymentConfiguration.Payer to just Payer, and adjust "
+ "your code by updating from RequestPaymentConfiguration.Payer to just Payer, and adjust "
+ "imports and names.";
return method.withComments(createComments(comment));
}

if (SET_LIFECYCLE_CONFIGURATION.matches(method)) {
// TODO: add the developer guide link in the comments once the doc is published.
String comment = "Transform for setBucketLifecycleConfiguration method not supported. Please manually migrate"
+ " your code by using builder pattern, update from BucketLifecycleConfiguration.Rule to "
+ " your code by using builder pattern, updating from BucketLifecycleConfiguration.Rule to "
+ "LifecycleRule, StorageClass to TransitionStorageClass, and adjust "
+ "imports and names.";
return method.withComments(createComments(comment));
Expand Down Expand Up @@ -223,6 +227,30 @@ public J.NewClass visitNewClass(J.NewClass newClass, ExecutionContext ctx) {
return newClass.withComments(createComments(comment));
}

if (type.isAssignableFrom(CREATE_BUCKET_REQUEST) && newClass.getArguments().size() == 2) {
String comment = "Transform for createBucketRequest with region is not supported. Please manually "
+ "migrate your code by configuring the region as locationConstraint in "
+ "createBucketConfiguration in the request builder";
return newClass.withComments(createComments(comment));
}

if (type.isAssignableFrom(DELETE_OBJECTS_RESULT)) {
String comment = "Transform for DeleteObjectsResult class is not supported. DeletedObject class is a "
+ "separate class in v2 (not nested). Please manually migrate your code by updating "
+ "DeleteObjectsResult.DeletedObject to s3.model.DeletedObject";
return newClass.withComments(createComments(comment));
}

if (type.isAssignableFrom(BUCKET_NOTIFICATION_CONFIG)) {
// TODO: add the developer guide link in the comments once the doc is published.
String comment = "Transform for BucketNotificationConfiguration class is not supported. "
+ "BucketNotificationConfiguration is renamed to NotificationConfiguration. There is no common"
+ " abstract class for lambdaFunction/topic/queue configurations. Use specific builders "
+ "instead of addConfiguration() to add configurations. Change the vararg arguments or EnumSet "
+ "in specific configurations constructor to List<String> in v2";
return newClass.withComments(createComments(comment));
}

return newClass;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,11 @@ public final class NamingConversionUtils {
S3_POJO_MAPPING.put("RoutingRuleCondition", "Condition");
S3_POJO_MAPPING.put("S3ObjectSummary", "S3Object");
S3_POJO_MAPPING.put("ObjectListing", "ListObjectsResponse");
S3_POJO_MAPPING.put("VersionListing", "ListObjectVersionsResponse");
S3_POJO_MAPPING.put("S3VersionSummary", "ObjectVersion");
S3_POJO_MAPPING.put("AmazonS3Exception", "S3Exception");
S3_POJO_MAPPING.put("CloudFunctionConfiguration", "LambdaFunctionConfiguration");
S3_POJO_MAPPING.put("LambdaConfiguration", "LambdaFunctionConfiguration");

//Special Enum mapping
S3_POJO_MAPPING.put("S3Event", "Event");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,10 @@ recipeList:
newMethodName: withRequestPayer
- org.openrewrite.java.ChangeMethodName:
methodPattern: com.amazonaws.services.s3.model.SetBucketPolicyRequest withPolicyText(String)
newMethodName: withPolicy
newMethodName: withPolicy
- org.openrewrite.java.ChangeMethodName:
methodPattern: com.amazonaws.services.s3.model.BucketPolicy getPolicyText()
newMethodName: policy
- org.openrewrite.java.ChangeMethodName:
methodPattern: com.amazonaws.services.s3.model.VersionListing getVersionSummaries()
newMethodName: versions
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,14 @@ recipeList:
- java.lang.String
fluentNames:
- withEmailAddress
- software.amazon.awssdk.v2migration.ConstructorToFluent:
clzzFqcn: com.amazonaws.services.s3.model.Grant
parameterTypes:
- com.amazonaws.services.s3.model.Grantee
- com.amazonaws.services.s3.model.Permission
fluentNames:
- withGrantee
- withPermission
- software.amazon.awssdk.v2migration.ConstructorToFluent:
clzzFqcn: com.amazonaws.services.s3.model.GetRequestPaymentConfigurationRequest
parameterTypes:
Expand Down
Loading