Skip to content

Commit

Permalink
Merge pull request #103 from urbancamo/develop
Browse files Browse the repository at this point in the history
 Release 1.4.9
  • Loading branch information
urbancamo authored Jun 24, 2024
2 parents f6aaf80 + c7e1e87 commit e8d69c8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 28 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<groupId>uk.m0nom</groupId>
<artifactId>adif-processor</artifactId>
<version>1.4.8</version>
<version>1.4.9</version>

<name>ADIF Processor</name>
<url>https://github.com/urbancamo/adif-processor</url>
Expand Down
28 changes: 1 addition & 27 deletions src/main/java/uk/m0nom/adifproc/file/AwsS3FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import com.amazonaws.regions.Regions;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
import com.amazonaws.services.s3.model.ObjectListing;
import com.amazonaws.services.s3.model.S3Object;
import com.amazonaws.services.s3.model.S3ObjectSummary;
import lombok.Getter;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -18,8 +16,6 @@
import java.io.IOException;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.util.Set;
import java.util.TreeSet;
import java.util.logging.Logger;

@Service
Expand All @@ -43,32 +39,10 @@ public AwsS3FileUtils(Environment env) {
if (configured) {
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
s3client = AmazonS3ClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(credentials)).withRegion(Regions.EU_WEST_2).build();
logger.info("AWS S3 file utilities configured");
}
}

public void archiveFile(String folder, String file, String content) {
if (isConfigured()) {
String path = String.format("%s/%s", folder, file);
try {
s3client.putObject(ADIF_PROC_BUCKET, path, content);
} catch (Exception e) {
logger.severe(String.format("Exception archiving file %s into bucket %s: %s", path, ADIF_PROC_BUCKET, e.getMessage()));
}
}
}

public Set<String> getFiles(String filePath) {
if (isConfigured()) {
Set<String> inputFiles = new TreeSet<>();
ObjectListing objectListing = s3client.listObjects(ADIF_PROC_BUCKET, filePath);
for (S3ObjectSummary os : objectListing.getObjectSummaries()) {
inputFiles.add(os.getKey());
}
return inputFiles;
}
return null;
}

public String readFile(String folder, String inputFile) {
if (isConfigured()) {
S3Object s3object = s3client.getObject(ADIF_PROC_BUCKET, String.format("%s/%s", folder, inputFile));
Expand Down

0 comments on commit e8d69c8

Please sign in to comment.