Skip to content

Commit ec8b996

Browse files
committed
Refactoring
1 parent 46362d6 commit ec8b996

File tree

19 files changed

+67
-39
lines changed

19 files changed

+67
-39
lines changed

awsec2instances/pom.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,14 @@
2020
<dependency>
2121
<groupId>software.amazon.awssdk</groupId>
2222
<artifactId>bom</artifactId>
23-
<version>2.14.5</version>
23+
<version>2.16.23</version>
2424
<type>pom</type>
2525
<scope>import</scope>
2626
</dependency>
2727
</dependencies>
2828
</dependencyManagement>
2929

3030
<dependencies>
31-
<dependency>
32-
<groupId>org.slf4j</groupId>
33-
<artifactId>slf4j-log4j12</artifactId>
34-
<version>1.7.30</version>
35-
</dependency>
3631
<dependency>
3732
<groupId>software.amazon.awssdk</groupId>
3833
<artifactId>ec2</artifactId>

awss3copy/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<dependency>
2121
<groupId>software.amazon.awssdk</groupId>
2222
<artifactId>bom</artifactId>
23-
<version>2.16.18</version>
23+
<version>2.16.23</version>
2424
<type>pom</type>
2525
<scope>import</scope>
2626
</dependency>

awss3copy/src/main/java/example/S3Copy.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
package example;
1111

12-
import java.io.IOException;
1312
import java.io.UnsupportedEncodingException;
1413
import java.net.URLEncoder;
1514
import java.nio.charset.StandardCharsets;
@@ -21,17 +20,20 @@
2120
import software.amazon.awssdk.services.s3.model.CopyObjectRequest;
2221
import software.amazon.awssdk.services.s3.model.CopyObjectResponse;
2322

23+
2424
public class S3Copy {
2525
private static final Region REGION = Region.of("eu-west-1"); // Region name
2626

27-
public static void main(String[] args) throws IOException {
27+
public static void main(String[] args) {
2828
String sourceBucketName; // Source bucket name
2929
String sourceKey; // Source key
3030
String destinationBucketName; // Destination bucket name
3131
String destinationKey; // Destination key
3232

3333
if (args.length < 3) {
34-
System.out.println("Not enough parameters.\nProper Usage is: java -jar s3copy.jar <SOURCE_BUCKET> <SOURCE_OBJECT> <DESTINATION_BUCKET>");
34+
System.out.println("Not enough parameters.\n" +
35+
"Proper Usage is: java -jar s3copy.jar " +
36+
"<SOURCE_BUCKET> <SOURCE_OBJECT> <DESTINATION_BUCKET>");
3537
System.exit(1);
3638
}
3739

awss3create/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<dependency>
2121
<groupId>software.amazon.awssdk</groupId>
2222
<artifactId>bom</artifactId>
23-
<version>2.16.14</version>
23+
<version>2.16.23</version>
2424
<type>pom</type>
2525
<scope>import</scope>
2626
</dependency>

awss3create/src/main/java/example/S3Create.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
package example;
99

10-
import java.io.IOException;
1110
import software.amazon.awssdk.core.exception.SdkException;
1211
import software.amazon.awssdk.awscore.exception.AwsServiceException;
1312
import software.amazon.awssdk.core.waiters.WaiterResponse;
@@ -25,10 +24,11 @@ public class S3Create {
2524

2625
private static final Region REGION = Region.of("eu-west-1"); // Region name
2726

28-
public static void main(String[] args) throws IOException {
27+
public static void main(String[] args) {
2928

3029
if (args.length < 1) {
31-
System.out.println("Not enough parameters.\nProper Usage is: java -jar s3create.jar <BUCKET_NAME>");
30+
System.out.println("Not enough parameters.\n" +
31+
"Proper Usage is: java -jar s3create.jar <BUCKET_NAME>");
3232
System.exit(1);
3333
}
3434

@@ -44,6 +44,7 @@ public static void main(String[] args) throws IOException {
4444

4545
try {
4646
System.out.println("Creating bucket ...");
47+
4748
S3Waiter s3Waiter = s3client.waiter();
4849
CreateBucketRequest bucketRequest = CreateBucketRequest.builder()
4950
.bucket(bucketName)
@@ -62,7 +63,9 @@ public static void main(String[] args) throws IOException {
6263
// Get Bucket location
6364
GetBucketLocationRequest bucketLocationRequest = GetBucketLocationRequest.builder().bucket(bucketName).build();
6465
GetBucketLocationResponse bucketLocationResponse = s3client.getBucketLocation(bucketLocationRequest);
66+
6567
System.out.println("Bucket location: " + bucketLocationResponse.locationConstraintAsString());
68+
6669
} catch (S3Exception e) {
6770
if (e.statusCode() == 409) {
6871
System.out.println("Error: Bucket already exists!!");

awss3delete/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<dependency>
2121
<groupId>software.amazon.awssdk</groupId>
2222
<artifactId>bom</artifactId>
23-
<version>2.16.14</version>
23+
<version>2.16.23</version>
2424
<type>pom</type>
2525
<scope>import</scope>
2626
</dependency>

awss3delete/src/main/java/example/S3Delete.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,22 @@
77

88
package example;
99

10-
import java.io.IOException;
1110
import software.amazon.awssdk.core.exception.SdkException;
1211
import software.amazon.awssdk.awscore.exception.AwsServiceException;
1312
import software.amazon.awssdk.regions.Region;
1413
import software.amazon.awssdk.services.s3.S3Client;
1514
import software.amazon.awssdk.services.s3.model.S3Exception;
1615
import software.amazon.awssdk.services.s3.model.DeleteBucketRequest;
1716

17+
1818
public class S3Delete {
1919
private static final Region REGION = Region.of("eu-west-1"); // Region name
2020

21-
public static void main(String[] args) throws IOException {
21+
public static void main(String[] args) {
2222

2323
if (args.length < 1) {
24-
System.out.println("Not enough parameters.\nProper Usage is: java -jar s3delete.jar <BUCKET_NAME>");
24+
System.out.println("Not enough parameters.\n" +
25+
"Proper Usage is: java -jar s3delete.jar <BUCKET_NAME>");
2526
System.exit(1);
2627
}
2728

@@ -37,10 +38,13 @@ public static void main(String[] args) throws IOException {
3738

3839
try {
3940
System.out.println("Deleting bucket ...");
41+
4042
// Delete bucket
4143
DeleteBucketRequest deleteBucketRequest = DeleteBucketRequest.builder().bucket(bucketName).build();
4244
s3client.deleteBucket(deleteBucketRequest);
45+
4346
System.out.println("Deleted");
47+
4448
} catch (S3Exception e) {
4549
if (e.statusCode() == 404) {
4650
System.out.println("Error: Bucket does not exist!!");

awss3deleteobject/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<dependency>
2121
<groupId>software.amazon.awssdk</groupId>
2222
<artifactId>bom</artifactId>
23-
<version>2.16.18</version>
23+
<version>2.16.23</version>
2424
<type>pom</type>
2525
<scope>import</scope>
2626
</dependency>

awss3deleteobject/src/main/java/example/S3DeleteObject.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
package example;
1010

11-
import java.io.IOException;
1211
import java.util.ArrayList;
1312
import software.amazon.awssdk.core.exception.SdkException;
1413
import software.amazon.awssdk.awscore.exception.AwsServiceException;
@@ -19,13 +18,16 @@
1918
import software.amazon.awssdk.services.s3.model.ObjectIdentifier;
2019
import software.amazon.awssdk.services.s3.model.DeleteObjectsRequest;
2120

21+
2222
public class S3DeleteObject {
2323
private static final Region REGION = Region.of("eu-west-1"); // Region name
2424

25-
public static void main(String[] args) throws IOException {
25+
public static void main(String[] args) {
2626

2727
if (args.length < 2) {
28-
System.out.println("Not enough parameters.\nProper Usage is: java -jar s3deleteobject.jar <BUCKET_NAME> <OBJECT_NAME>");
28+
System.out.println("Not enough parameters.\n" +
29+
"Proper Usage is: java -jar s3deleteobject.jar " +
30+
"<BUCKET_NAME> <OBJECT_NAME>");
2931
System.exit(1);
3032
}
3133

@@ -45,6 +47,7 @@ public static void main(String[] args) throws IOException {
4547

4648
try {
4749
System.out.println("Deleting object ...");
50+
4851
ArrayList<ObjectIdentifier> toDelete = new ArrayList<ObjectIdentifier>();
4952
toDelete.add(ObjectIdentifier.builder().key(keyName).build());
5053

@@ -54,7 +57,9 @@ public static void main(String[] args) throws IOException {
5457
.delete(Delete.builder().objects(toDelete).build())
5558
.build();
5659
s3client.deleteObjects(delReq);
60+
5761
System.out.println("Deleted");
62+
5863
} catch (S3Exception e) {
5964
if (e.statusCode() == 404) {
6065
System.out.println("Error: Bucket does not exist!!");

awss3download/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<dependency>
2121
<groupId>software.amazon.awssdk</groupId>
2222
<artifactId>bom</artifactId>
23-
<version>2.16.14</version>
23+
<version>2.16.23</version>
2424
<type>pom</type>
2525
<scope>import</scope>
2626
</dependency>

0 commit comments

Comments
 (0)