Skip to content

Commit 839dcbf

Browse files
authored
developer guide added in comments (#6058)
1 parent f6adeaa commit 839dcbf

File tree

4 files changed

+33
-28
lines changed

4 files changed

+33
-28
lines changed

test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven-nocompile/after/src/main/java/foo/bar/S3Transforms.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ public class S3Transforms {
4141
String key;
4242

4343
void s3Pojos() {
44-
MultiFactorAuthentication mfa = /*AWS SDK for Java v2 migration: v2 does not have a MultiFactorAuthentication POJO. Please manually set the String value on the request POJO.*/new MultiFactorAuthentication("serialNum", "token");
44+
MultiFactorAuthentication mfa = /*AWS SDK for Java v2 migration: v2 does not have a MultiFactorAuthentication POJO. Please manually set the String value on the request POJO. Please reference https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/migration-s3-client.html#V1-MultifactorAuthentication*/new MultiFactorAuthentication("serialNum", "token");
4545

4646
DeleteObjectRequest deleteVersionRequest =
4747
DeleteObjectRequest.builder().bucket("bucket").key("key").versionId("id").mfa(mfa)
4848
.build();
4949
}
5050

5151
void setBucketAcl() {
52-
/*AWS SDK for Java v2 migration: Transform for AccessControlList and CannedAccessControlList not supported. In v2, CannedAccessControlList is replaced by BucketCannedACL for buckets and ObjectCannedACL for objects.*/s3.setBucketAcl(bucket, CannedAccessControlList.AuthenticatedRead);
52+
/*AWS SDK for Java v2 migration: Transform for AccessControlList and CannedAccessControlList not supported. In v2, CannedAccessControlList is replaced by BucketCannedACL for buckets and ObjectCannedACL for objects. Please reference https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/migration-s3-client.html#V1-AccessControlList*/s3.setBucketAcl(bucket, CannedAccessControlList.AuthenticatedRead);
5353
}
5454

5555
void setObjectAcl() {
56-
/*AWS SDK for Java v2 migration: Transform for AccessControlList and CannedAccessControlList not supported. In v2, CannedAccessControlList is replaced by BucketCannedACL for buckets and ObjectCannedACL for objects.*/s3.setObjectAcl(bucket, key, CannedAccessControlList.PublicRead);
56+
/*AWS SDK for Java v2 migration: Transform for AccessControlList and CannedAccessControlList not supported. In v2, CannedAccessControlList is replaced by BucketCannedACL for buckets and ObjectCannedACL for objects. Please reference https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/migration-s3-client.html#V1-AccessControlList*/s3.setObjectAcl(bucket, key, CannedAccessControlList.PublicRead);
5757
}
5858

5959
void upload_streamWithLiteralLength(S3TransferManager tm) {

test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven/after/src/main/java/foo/bar/S3.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ private void setBucketConfigs(S3Client s3, String bucket) {
373373
s3.putBucketInventoryConfiguration(PutBucketInventoryConfigurationRequest.builder().bucket(bucket).inventoryConfiguration(InventoryConfiguration.builder()
374374
.build())
375375
.build());
376-
/*AWS SDK for Java v2 migration: Transform for setBucketLifecycleConfiguration method not supported. Please manually migrate your code by using builder pattern, updating from BucketLifecycleConfiguration.Rule to LifecycleRule, StorageClass to TransitionStorageClass, and adjust imports and names.*/s3.putBucketLifecycleConfiguration(PutBucketLifecycleConfigurationRequest.builder().bucket(bucket).lifecycleConfiguration(BucketLifecycleConfiguration.builder()
376+
/*AWS SDK for Java v2 migration: Transform for setBucketLifecycleConfiguration method not supported. Please manually migrate your code by using builder pattern, updating from BucketLifecycleConfiguration.Rule to LifecycleRule, StorageClass to TransitionStorageClass, and adjust imports and names. Please reference https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/migration-s3-client.html#V1-setBucketLifecycleConfiguration*/s3.putBucketLifecycleConfiguration(PutBucketLifecycleConfigurationRequest.builder().bucket(bucket).lifecycleConfiguration(BucketLifecycleConfiguration.builder()
377377
.build())
378378
.build());
379379
s3.putBucketMetricsConfiguration(PutBucketMetricsConfigurationRequest.builder().bucket(bucket).metricsConfiguration(MetricsConfiguration.builder()
@@ -388,7 +388,7 @@ private void setBucketConfigs(S3Client s3, String bucket) {
388388
s3.putBucketReplication(PutBucketReplicationRequest.builder().bucket(bucket).replicationConfiguration(ReplicationConfiguration.builder()
389389
.build())
390390
.build());
391-
/*AWS SDK for Java v2 migration: Transform for setBucketTaggingConfiguration method not supported. Please manually migrate your code by using builder pattern, replacing TagSet.setTag() with .tagSet(Arrays.asList(Tag.builder())), and use Tagging instead of BucketTaggingConfiguration, and adjust imports and names.*/s3.putBucketTagging(PutBucketTaggingRequest.builder().bucket(bucket).tagging(Tagging.builder()
391+
/*AWS SDK for Java v2 migration: Transform for setBucketTaggingConfiguration method not supported. Please manually migrate your code by using builder pattern, replacing TagSet.setTag() with .tagSet(Arrays.asList(Tag.builder())), and use Tagging instead of BucketTaggingConfiguration, and adjust imports and names. Please reference https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/migration-s3-client.html#V1-setBucketTaggingConfiguration*/s3.putBucketTagging(PutBucketTaggingRequest.builder().bucket(bucket).tagging(Tagging.builder()
392392
.build())
393393
.build());
394394
s3.putBucketWebsite(PutBucketWebsiteRequest.builder().bucket(bucket).websiteConfiguration(WebsiteConfiguration.builder()

test/v2-migration-tests/src/test/resources/software/amazon/awssdk/v2migrationtests/maven/after/src/main/java/foo/bar/S3RequestConstructor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ public void requestconstructor() {
398398
.build());
399399

400400

401-
/*AWS SDK for Java v2 migration: Transform for setBucketLifecycleConfiguration method not supported. Please manually migrate your code by using builder pattern, updating from BucketLifecycleConfiguration.Rule to LifecycleRule, StorageClass to TransitionStorageClass, and adjust imports and names.*/s3.putBucketLifecycleConfiguration(
401+
/*AWS SDK for Java v2 migration: Transform for setBucketLifecycleConfiguration method not supported. Please manually migrate your code by using builder pattern, updating from BucketLifecycleConfiguration.Rule to LifecycleRule, StorageClass to TransitionStorageClass, and adjust imports and names. Please reference https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/migration-s3-client.html#V1-setBucketLifecycleConfiguration*/s3.putBucketLifecycleConfiguration(
402402
PutBucketLifecycleConfigurationRequest.builder().bucket(bucketName).lifecycleConfiguration(BucketLifecycleConfiguration.builder()
403403
.build())
404404
.build());
@@ -433,7 +433,7 @@ public void requestconstructor() {
433433
.build())
434434
.build());
435435

436-
/*AWS SDK for Java v2 migration: Transform for setBucketTaggingConfiguration method not supported. Please manually migrate your code by using builder pattern, replacing TagSet.setTag() with .tagSet(Arrays.asList(Tag.builder())), and use Tagging instead of BucketTaggingConfiguration, and adjust imports and names.*/s3.putBucketTagging(
436+
/*AWS SDK for Java v2 migration: Transform for setBucketTaggingConfiguration method not supported. Please manually migrate your code by using builder pattern, replacing TagSet.setTag() with .tagSet(Arrays.asList(Tag.builder())), and use Tagging instead of BucketTaggingConfiguration, and adjust imports and names. Please reference https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/migration-s3-client.html#V1-setBucketTaggingConfiguration*/s3.putBucketTagging(
437437
PutBucketTaggingRequest.builder().bucket(bucketName).tagging(Tagging.builder()
438438
.build())
439439
.build());

v2-migration/src/main/java/software/amazon/awssdk/v2migration/S3AddImportsAndComments.java

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -90,45 +90,44 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
9090
if (isSetObjectAcl || isSetBucketAcl) {
9191
removeV1S3ModelImport("CannedAccessControlList");
9292
maybeAddV2CannedAclImport(method.getArguments(), isSetObjectAcl, isSetBucketAcl);
93-
94-
// TODO: add the developer guide link in the comments once the doc is published.
9593
String comment = "Transform for AccessControlList and CannedAccessControlList not supported. "
9694
+ "In v2, CannedAccessControlList is replaced by BucketCannedACL for buckets and "
97-
+ "ObjectCannedACL for objects.";
95+
+ "ObjectCannedACL for objects." + devGuideLink("AccessControlList");
9896
return method.withComments(createComments(comment));
9997
}
10098
if (LIST_NEXT_BATCH_OBJECTS.matches(method)) {
101-
// TODO: add the developer guide link in the comments once the doc is published.
10299
String comment = "Transform for listNextBatchOfObjects method not supported. "
103100
+ "listNextBatchOfObjects() only exists in SDK v1, for SDK v2 use either "
104101
+ "listObjectsV2Paginator().stream() for automatic pagination"
105102
+ " or manually handle pagination with listObjectsV2() and nextToken in the response for more "
106-
+ "control";
103+
+ "control" + devGuideLink(method.getSimpleName());
107104
return method.withComments(createComments(comment));
108105
}
109106
if (LIST_NEXT_BATCH_VERSIONS.matches(method)) {
110-
// TODO: add the developer guide link in the comments once the doc is published.
111107
String comment = "Transform for listNextBatchOfVersions method not supported."
112108
+ "listNextBatchOfVersions() only exists in SDK v1, for SDK v2 use either "
113109
+ "listObjectVersionsPaginator().stream for automatic pagination"
114-
+ " or manually handle pagination with listObjectVersions() and VersionIdMarker/KeyMarker. ";
110+
+ " or manually handle pagination with listObjectVersions() and VersionIdMarker/KeyMarker."
111+
+ devGuideLink(method.getSimpleName());
115112
return method.withComments(createComments(comment));
116113
}
117114
if (SET_REGION.matches(method)) {
118115
String comment = "Transform for setRegion method not supported. Please manually "
119-
+ "migrate your code by configuring the region in the s3 client builder";
116+
+ "migrate your code by configuring the region in the s3 client builder"
117+
+ devGuideLink(method.getSimpleName());
120118
return method.withComments(createComments(comment));
121119
}
122120
if (SET_S3CLIENT_OPTIONS.matches(method)) {
123121
String comment = "Transform for setS3ClientOptions method not supported. Please manually "
124122
+ "migrate setS3ClientOptions by configuring the equivalent settings in "
125-
+ "S3Configuration.builder() when building your S3Client.";
123+
+ "S3Configuration.builder() when building your S3Client."
124+
+ devGuideLink(method.getSimpleName());
126125
return method.withComments(createComments(comment));
127126
}
128127
if (SELECT_OBJECT_CONTENT.matches(method)) {
129128
String comment = "Note: selectObjectContent is only supported in AWS SDK v2 with S3AsyncClient. "
130129
+ "Please manually migrate to event-based response handling using "
131-
+ "SelectObjectContentEventStream";
130+
+ "SelectObjectContentEventStream" + devGuideLink(method.getSimpleName());
132131
return method.withComments(createComments(comment));
133132
}
134133

@@ -156,15 +155,15 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
156155
}
157156

158157
if (SET_BUCKET_LOGGING.matches(method)) {
159-
// TODO: add the developer guide link in the comments once the doc is published.
160158
removeV1S3ModelImport("BucketLoggingConfiguration");
161159
addV2S3ModelImport("BucketLoggingStatus");
162160
addV2S3ModelImport("LoggingEnabled");
163161

164162
String comment = "Transform for setBucketLoggingConfiguration method not "
165163
+ "supported. The method is renamed to putBucketLogging. Please manually migrate your code by "
166164
+ "replacing BucketLoggingConfiguration with BucketLoggingStatus and LoggingEnabled builders, "
167-
+ "and updating the method name and parameters";
165+
+ "and updating the method name and parameters"
166+
+ devGuideLink(method.getSimpleName());
168167
return method.withComments(createComments(comment));
169168
}
170169

@@ -177,20 +176,18 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
177176
}
178177

179178
if (SET_LIFECYCLE_CONFIGURATION.matches(method)) {
180-
// TODO: add the developer guide link in the comments once the doc is published.
181179
String comment = "Transform for setBucketLifecycleConfiguration method not supported. Please manually migrate"
182180
+ " your code by using builder pattern, updating from BucketLifecycleConfiguration.Rule to "
183181
+ "LifecycleRule, StorageClass to TransitionStorageClass, and adjust "
184-
+ "imports and names.";
182+
+ "imports and names." + devGuideLink(method.getSimpleName());
185183
return method.withComments(createComments(comment));
186184
}
187185

188186
if (SET_TAGGING_CONFIGURATION.matches(method)) {
189-
// TODO: add the developer guide link in the comments once the doc is published.
190187
String comment = "Transform for setBucketTaggingConfiguration method not supported. Please manually migrate"
191188
+ " your code by using builder pattern, replacing TagSet.setTag() with .tagSet(Arrays.asList"
192189
+ "(Tag.builder())), and use Tagging instead of BucketTaggingConfiguration, and adjust imports"
193-
+ " and names.";
190+
+ " and names." + devGuideLink(method.getSimpleName());
194191
return method.withComments(createComments(comment));
195192
}
196193

@@ -209,21 +206,23 @@ public J.NewClass visitNewClass(J.NewClass newClass, ExecutionContext ctx) {
209206
if (type.isAssignableFrom(MULTI_FACTOR_AUTH) || setBucketVersionUsingMFA) {
210207
removeV1S3ModelImport("MultiFactorAuthentication");
211208
String comment = "v2 does not have a MultiFactorAuthentication POJO. Please manually set the String value on "
212-
+ "the request POJO.";
209+
+ "the request POJO." + devGuideLink("MultifactorAuthentication");
213210
return newClass.withComments(createComments(comment));
214211
}
215212

216213
if (type.isAssignableFrom(GET_OBJECT_REQUEST) && newClass.getArguments().size() == 1) {
217214
removeV1S3ModelImport("S3ObjectId");
218215
String comment = "v2 does not have S3ObjectId class. Please manually migrate the code by setting the configs "
219-
+ "directly into the request builder pattern.";
216+
+ "directly into the request builder pattern."
217+
+ devGuideLink("getObject-using-V1s-S3ObjectId");
220218
return newClass.withComments(createComments(comment));
221219
}
222220

223221
if (type.isAssignableFrom(INITIATE_MPU) && newClass.getArguments().size() == 3) {
224222
String comment = "Transform for ObjectMetadata in initiateMultipartUpload() method is not supported. Please "
225223
+ "manually migrate your code by replacing ObjectMetadata with individual setter methods "
226-
+ "or metadata map in the request builder.";
224+
+ "or metadata map in the request builder."
225+
+ devGuideLink("initiateMultipartUpload");
227226
return newClass.withComments(createComments(comment));
228227
}
229228

@@ -242,12 +241,12 @@ public J.NewClass visitNewClass(J.NewClass newClass, ExecutionContext ctx) {
242241
}
243242

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

@@ -277,5 +276,11 @@ private void removeV1S3ModelImport(String className) {
277276
private void addV2S3ModelImport(String className) {
278277
doAfterVisit(new AddImport<>(V2_S3_MODEL_PKG + className, null, false));
279278
}
279+
280+
private String devGuideLink(String name) {
281+
String prefix = " Please reference https://docs.aws.amazon"
282+
+ ".com/sdk-for-java/latest/developer-guide/migration-s3-client.html#V1-";
283+
return prefix + name;
284+
}
280285
}
281286
}

0 commit comments

Comments
 (0)