From e1ca3b5cc58a7a33d158903868541377ec1ca8e3 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 28 Oct 2016 18:39:17 +0200 Subject: [PATCH] * Removed the LogServices (H2 DB file that logs actions). --- Mage.Client/serverlist.txt | 1 - .../main/java/mage/server/MageServerImpl.java | 15 ----------- .../main/java/mage/server/SessionManager.java | 12 --------- .../java/mage/server/TableController.java | 3 --- .../server/services/impl/LogServiceImpl.java | 27 ------------------- 5 files changed, 58 deletions(-) delete mode 100644 Mage.Server/src/main/java/mage/server/services/impl/LogServiceImpl.java diff --git a/Mage.Client/serverlist.txt b/Mage.Client/serverlist.txt index e4c7e0a490..4d7edbf19f 100644 --- a/Mage.Client/serverlist.txt +++ b/Mage.Client/serverlist.txt @@ -1,6 +1,5 @@ XMage.de 1 (Europe/Germany) fast :xmage.de:17171 woogerworks (North America/USA) :xmage.woogerworks.com:17171 -woogerworks replacment (North America/USA) :158.69.192.238:17171 XMage.tahiti :xmage.tahiti.one:443 Seedds Server (Asia) :115.29.203.80:17171 localhost -> connect to your local server (must be started):localhost:17171 diff --git a/Mage.Server/src/main/java/mage/server/MageServerImpl.java b/Mage.Server/src/main/java/mage/server/MageServerImpl.java index c27f009b25..b2f2c51843 100644 --- a/Mage.Server/src/main/java/mage/server/MageServerImpl.java +++ b/Mage.Server/src/main/java/mage/server/MageServerImpl.java @@ -68,9 +68,7 @@ import mage.server.game.GamesRoom; import mage.server.game.GamesRoomManager; import mage.server.game.PlayerFactory; import mage.server.game.ReplayManager; -import mage.server.services.LogKeys; import mage.server.services.impl.FeedbackServiceImpl; -import mage.server.services.impl.LogServiceImpl; import mage.server.tournament.TournamentFactory; import mage.server.tournament.TournamentManager; import mage.server.util.ConfigSettings; @@ -188,7 +186,6 @@ public class MageServerImpl implements MageServer { public boolean registerClient(String userName, String sessionId, MageVersion version) throws MageException { // This method is deprecated, so just inform the server version. logger.info("MageVersionException: userName=" + userName + ", version=" + version); - LogServiceImpl.instance.log(LogKeys.KEY_WRONG_VERSION, userName, version.toString(), Main.getVersion().toString(), sessionId); throw new MageVersionException(version, Main.getVersion()); } @@ -197,7 +194,6 @@ public class MageServerImpl implements MageServer { try { if (version.compareTo(Main.getVersion()) != 0) { logger.info("MageVersionException: userName=" + userName + ", version=" + version); - LogServiceImpl.instance.log(LogKeys.KEY_WRONG_VERSION, userName, version.toString(), Main.getVersion().toString(), sessionId); throw new MageVersionException(version, Main.getVersion()); } return SessionManager.getInstance().connectUser(sessionId, userName, password); @@ -266,7 +262,6 @@ public class MageServerImpl implements MageServer { logger.debug("- " + user.getName() + " userId: " + user.getId()); logger.debug("- chatId: " + TableManager.getInstance().getChatId(table.getTableId())); } - LogServiceImpl.instance.log(LogKeys.KEY_TABLE_CREATED, sessionId, userId.toString(), table.getTableId().toString()); return table; } }); @@ -315,7 +310,6 @@ public class MageServerImpl implements MageServer { } TableView table = GamesRoomManager.getInstance().getRoom(roomId).createTournamentTable(userId, options); logger.debug("Tournament table " + table.getTableId() + " created"); - LogServiceImpl.instance.log(LogKeys.KEY_TOURNAMENT_TABLE_CREATED, sessionId, userId.toString(), table.getTableId().toString()); return table; } catch (Exception ex) { handleException(ex); @@ -1190,7 +1184,6 @@ public class MageServerImpl implements MageServer { public void execute() { String host = SessionManager.getInstance().getSession(sessionId).getHost(); FeedbackServiceImpl.instance.feedback(username, title, type, message, email, host); - LogServiceImpl.instance.log(LogKeys.KEY_FEEDBACK_ADDED, sessionId, username, host); } }); } @@ -1226,7 +1219,6 @@ public class MageServerImpl implements MageServer { protected void execute(final String actionName, final String sessionId, final Action action, boolean checkAdminRights) throws MageException { if (checkAdminRights) { if (!SessionManager.getInstance().isAdmin(sessionId)) { - LogServiceImpl.instance.log(LogKeys.KEY_NOT_ADMIN, actionName, sessionId); return; } } @@ -1246,8 +1238,6 @@ public class MageServerImpl implements MageServer { } catch (MageException me) { throw new RuntimeException(me); } - } else { - LogServiceImpl.instance.log(LogKeys.KEY_NOT_VALID_SESSION_INTERNAL, actionName, sessionId); } } } @@ -1255,15 +1245,12 @@ public class MageServerImpl implements MageServer { } catch (Exception ex) { handleException(ex); } - } else { - LogServiceImpl.instance.log(LogKeys.KEY_NOT_VALID_SESSION, actionName, sessionId); } } protected T executeWithResult(String actionName, final String sessionId, final ActionWithResult action, boolean checkAdminRights) throws MageException { if (checkAdminRights) { if (!SessionManager.getInstance().isAdmin(sessionId)) { - LogServiceImpl.instance.log(LogKeys.KEY_NOT_ADMIN, actionName, sessionId); return action.negativeResult(); } } @@ -1278,8 +1265,6 @@ public class MageServerImpl implements MageServer { } catch (Exception ex) { handleException(ex); } - } else { - LogServiceImpl.instance.log(LogKeys.KEY_NOT_VALID_SESSION, actionName, sessionId); } return action.negativeResult(); } diff --git a/Mage.Server/src/main/java/mage/server/SessionManager.java b/Mage.Server/src/main/java/mage/server/SessionManager.java index 20c7d3ab47..843aefe05b 100644 --- a/Mage.Server/src/main/java/mage/server/SessionManager.java +++ b/Mage.Server/src/main/java/mage/server/SessionManager.java @@ -32,8 +32,6 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import mage.MageException; import mage.players.net.UserData; -import mage.server.services.LogKeys; -import mage.server.services.impl.LogServiceImpl; import org.apache.log4j.Logger; import org.jboss.remoting.callback.InvokerCallbackHandler; @@ -81,8 +79,6 @@ public class SessionManager { logger.debug(userName + " not registered: " + returnMessage); return false; } - LogServiceImpl.instance.log(LogKeys.KEY_USER_REGISTERED, userName, session.getHost(), sessionId); - logger.info(userName + " registered"); logger.debug("- userId: " + session.getUserId()); logger.debug("- sessionId: " + sessionId); @@ -95,8 +91,6 @@ public class SessionManager { if (session != null) { String returnMessage = session.connectUser(userName, password); if (returnMessage == null) { - LogServiceImpl.instance.log(LogKeys.KEY_USER_CONNECTED, userName, session.getHost(), sessionId); - logger.info(userName + " connected to server"); logger.debug("- userId: " + session.getUserId()); logger.debug("- sessionId: " + sessionId); @@ -115,7 +109,6 @@ public class SessionManager { Session session = sessions.get(sessionId); if (session != null) { session.connectAdmin(); - LogServiceImpl.instance.log(LogKeys.KEY_ADMIN_CONNECTED, "Admin", session.getHost(), sessionId); logger.info("Admin connected from " + session.getHost()); return true; } @@ -144,15 +137,12 @@ public class SessionManager { switch (reason) { case Disconnected: session.kill(reason); - LogServiceImpl.instance.log(LogKeys.KEY_SESSION_KILLED, sessionId); break; case SessionExpired: session.kill(reason); - LogServiceImpl.instance.log(LogKeys.KEY_SESSION_EXPIRED, sessionId); break; case LostConnection: session.userLostConnection(); - LogServiceImpl.instance.log(LogKeys.KEY_SESSION_DISCONNECTED, sessionId); break; default: logger.error("endSession: unexpected reason " + reason.toString() + " - sessionId: " + sessionId); @@ -187,7 +177,6 @@ public class SessionManager { user.showUserMessage("Admin operation", "Your session was disconnected by Admin."); userAdmin.showUserMessage("Admin action", "User" + user.getName() + " was disconnected."); disconnect(userSessionId, DisconnectReason.AdminDisconnect); - LogServiceImpl.instance.log(LogKeys.KEY_SESSION_DISCONNECTED_BY_ADMIN, sessionId, userSessionId); } else { userAdmin.showUserMessage("Admin operation", "User with sessionId " + userSessionId + " could not be found!"); } @@ -206,7 +195,6 @@ public class SessionManager { public void endUserSession(String sessionId, String userSessionId) { if (isAdmin(sessionId)) { disconnect(userSessionId, DisconnectReason.AdminDisconnect); - LogServiceImpl.instance.log(LogKeys.KEY_SESSION_END_BY_ADMIN, sessionId, userSessionId); } } diff --git a/Mage.Server/src/main/java/mage/server/TableController.java b/Mage.Server/src/main/java/mage/server/TableController.java index 5e18b5badc..2162af3c6b 100644 --- a/Mage.Server/src/main/java/mage/server/TableController.java +++ b/Mage.Server/src/main/java/mage/server/TableController.java @@ -62,8 +62,6 @@ import mage.server.game.GameFactory; import mage.server.game.GameManager; import mage.server.game.PlayerFactory; import mage.server.record.TableRecorderImpl; -import mage.server.services.LogKeys; -import mage.server.services.impl.LogServiceImpl; import mage.server.tournament.TournamentController; import mage.server.tournament.TournamentFactory; import mage.server.tournament.TournamentManager; @@ -606,7 +604,6 @@ public class TableController { if (match.getGame() != null) { logger.debug("- chatId: " + GameManager.getInstance().getChatId(match.getGame().getId())); } - LogServiceImpl.instance.log(LogKeys.KEY_GAME_STARTED, String.valueOf(userPlayerMap.size()), creator, opponent.toString()); } catch (Exception ex) { logger.fatal("Error starting game table: " + table.getId(), ex); if (table != null) { diff --git a/Mage.Server/src/main/java/mage/server/services/impl/LogServiceImpl.java b/Mage.Server/src/main/java/mage/server/services/impl/LogServiceImpl.java deleted file mode 100644 index 8ab91fd2b6..0000000000 --- a/Mage.Server/src/main/java/mage/server/services/impl/LogServiceImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package mage.server.services.impl; - -import mage.db.EntityManager; -import mage.server.services.LogService; -import org.apache.log4j.Logger; - -import java.util.Calendar; - -/** - * @author noxx - */ -public enum LogServiceImpl implements LogService { - instance; - - private static Logger log = Logger.getLogger(LogServiceImpl.class); - - @Override - public void log(String key, String... args) { - Calendar cal = Calendar.getInstance(); - try { - EntityManager.instance.insertLog(key, cal.getTime(), args); - } catch (Exception e) { - log.fatal(e); - } - } - -}