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> <artifactId>jetlang</artifactId>
<version>0.2.23</version> <version>0.2.23</version>
</dependency> </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> <dependency>
<!-- GUI lib TODO: unused and can be deleted? --> <!-- GUI lib TODO: unused and can be deleted? -->
<groupId>com.jgoodies</groupId> <groupId>com.jgoodies</groupId>

View file

@ -257,10 +257,7 @@ public class CallbackClientImpl implements CallbackClient {
if (panel != null) { if (panel != null) {
Session session = SessionHandler.getSession(); Session session = SessionHandler.getSession();
if (session.isJsonLogActive()) { if (session.isJsonLogActive()) {
UUID gameId = callback.getObjectId();
appendJsonEvent("GAME_OVER", callback.getObjectId(), message); 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()); 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;
}
}
}

View file

@ -218,7 +218,7 @@
<dependency> <dependency>
<groupId>org.apache.shiro</groupId> <groupId>org.apache.shiro</groupId>
<artifactId>shiro-core</artifactId> <artifactId>shiro-core</artifactId>
<version>1.8.0</version> <version>1.13.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.mail</groupId> <groupId>javax.mail</groupId>

View file

@ -8,7 +8,6 @@ import mage.util.ThreadUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.InvokerCallbackHandler;
import javax.annotation.Nonnull;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -29,7 +28,7 @@ public class SessionManagerImpl implements SessionManager {
} }
@Override @Override
public Optional<Session> getSession(@Nonnull String sessionId) { public Optional<Session> getSession(String sessionId) {
return Optional.ofNullable(sessions.getOrDefault(sessionId, null)); return Optional.ofNullable(sessions.getOrDefault(sessionId, null));
} }
@ -180,12 +179,12 @@ public class SessionManagerImpl implements SessionManager {
} }
@Override @Override
public boolean isValidSession(@Nonnull String sessionId) { public boolean isValidSession(String sessionId) {
return sessions.containsKey(sessionId); return sessions.containsKey(sessionId);
} }
@Override @Override
public Optional<User> getUser(@Nonnull String sessionId) { public Optional<User> getUser(String sessionId) {
Session session = sessions.get(sessionId); Session session = sessions.get(sessionId);
if (session != null) { if (session != null) {
return managerFactory.userManager().getUser(sessions.get(sessionId).getUserId()); return managerFactory.userManager().getUser(sessions.get(sessionId).getUserId());

View file

@ -7,12 +7,11 @@ import mage.server.Session;
import mage.server.User; import mage.server.User;
import org.jboss.remoting.callback.InvokerCallbackHandler; import org.jboss.remoting.callback.InvokerCallbackHandler;
import javax.annotation.Nonnull;
import java.util.Optional; import java.util.Optional;
public interface SessionManager { public interface SessionManager {
Optional<Session> getSession(@Nonnull String sessionId); Optional<Session> getSession(String sessionId);
void createSession(String sessionId, InvokerCallbackHandler callbackHandler); void createSession(String sessionId, InvokerCallbackHandler callbackHandler);
@ -37,9 +36,9 @@ public interface SessionManager {
boolean checkAdminAccess(String sessionId); boolean checkAdminAccess(String sessionId);
boolean isValidSession(@Nonnull String sessionId); boolean isValidSession(String sessionId);
Optional<User> getUser(@Nonnull String sessionId); Optional<User> getUser(String sessionId);
boolean extendUserSession(String sessionId, String pingInfo); boolean extendUserSession(String sessionId, String pingInfo);

View file

@ -25,7 +25,7 @@
<dependency> <dependency>
<groupId>com.google.protobuf</groupId> <groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId> <artifactId>protobuf-java</artifactId>
<version>3.19.3</version> <version>3.25.8</version>
</dependency> </dependency>
</dependencies> </dependencies>
@ -55,7 +55,7 @@
</goals> </goals>
<configuration> <configuration>
<protocArtifact>com.google.protobuf:protoc:3.18.0</protocArtifact> <protocArtifact>com.google.protobuf:protoc:3.25.8</protocArtifact>
<inputDirectories> <inputDirectories>
<include>${project.basedir}/src/main/proto</include> <include>${project.basedir}/src/main/proto</include>
</inputDirectories> </inputDirectories>

View file

@ -349,7 +349,7 @@
<!-- extended lib from google (collections, io, etc) --> <!-- extended lib from google (collections, io, etc) -->
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>30.1.1-jre</version> <version>33.4.8-jre</version>
</dependency> </dependency>
<dependency> <dependency>
<!-- escape/unescape html in texts --> <!-- escape/unescape html in texts -->
@ -373,7 +373,7 @@
<!-- scraping lib to download and parse html/symbols/images/svg --> <!-- scraping lib to download and parse html/symbols/images/svg -->
<groupId>org.jsoup</groupId> <groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId> <artifactId>jsoup</artifactId>
<version>1.14.3</version> <version>1.21.1</version>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>