dev: updated some libs, removed outdated and unused s3/aws code and annotations (#13802)

This commit is contained in:
ReSech 2025-06-29 22:36:10 +10:00 committed by GitHub
parent 450f7bd907
commit 6568c1f18a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 11 additions and 70 deletions

View file

@ -87,14 +87,6 @@
<artifactId>jetlang</artifactId>
<version>0.2.23</version>
</dependency>
<dependency>
<!-- amazon s3 cloud lib to upload game logs from experimental client -->
<!-- TODO: feature must be removed as unused or implemented for all -->
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.12.78</version>
</dependency>
<dependency>
<!-- GUI lib TODO: unused and can be deleted? -->
<groupId>com.jgoodies</groupId>

View file

@ -257,10 +257,7 @@ public class CallbackClientImpl implements CallbackClient {
if (panel != null) {
Session session = SessionHandler.getSession();
if (session.isJsonLogActive()) {
UUID gameId = callback.getObjectId();
appendJsonEvent("GAME_OVER", callback.getObjectId(), message);
String logFileName = "game-" + gameId + ".json";
S3Uploader.upload(logFileName, gameId.toString());
}
panel.endMessage(callback.getMessageId(), message.getGameView(), message.getOptions(), message.getMessage());
}

View file

@ -1,46 +0,0 @@
package mage.client.remote;
import com.amazonaws.AmazonClientException;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.transfer.TransferManager;
import com.amazonaws.services.s3.transfer.Upload;
import org.apache.log4j.Logger;
import java.io.File;
public class S3Uploader {
private static final Logger logger = Logger.getLogger(S3Uploader.class);
public static Boolean upload(String filePath, String keyName) throws Exception {
String existingBucketName = System.getenv("S3_BUCKET") != null ? System.getenv("S3_BUCKET")
: "xmage-game-logs-dev";
String accessKeyId = System.getenv("AWS_ACCESS_ID");
String secretKeyId = System.getenv("AWS_SECRET_KEY");
if (accessKeyId == null || accessKeyId.isEmpty()
|| secretKeyId == null || secretKeyId.isEmpty()
|| existingBucketName.isEmpty()) {
logger.info("Aborting json log sync.");
return false;
}
String path = new File("./" + filePath).getCanonicalPath();
logger.info("Syncing " + path + " to bucket: " + existingBucketName + " with AWS Access Id: " + accessKeyId);
BasicAWSCredentials awsCreds = new BasicAWSCredentials(accessKeyId, secretKeyId);
TransferManager tm = new TransferManager(awsCreds);
Upload upload = tm.upload(existingBucketName, "/game/" + keyName + ".json", new File(path));
try {
upload.waitForUploadResult();
logger.info("Sync Complete For " + path + " to bucket: " + existingBucketName + " with AWS Access Id: " + accessKeyId);
new File(path);
return true;
} catch (AmazonClientException amazonClientException) {
logger.fatal("Unable to upload file, upload was aborted.", amazonClientException);
return false;
}
}
}