mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-28 20:17:42 +01:00
Implemented a couple missing Check, Fetch & Save Operations for SQL
This commit is contained in:
parent
60257a3004
commit
ba661ca2e0
@ -41,7 +41,7 @@ public interface FetchOperations {
|
|||||||
|
|
||||||
Optional<Server> getBungeeInformation() throws DBException;
|
Optional<Server> getBungeeInformation() throws DBException;
|
||||||
|
|
||||||
Optional<Integer> getServerID(UUID serverUUID);
|
Optional<Integer> getServerID(UUID serverUUID) throws DBException;
|
||||||
|
|
||||||
// Raw Data
|
// Raw Data
|
||||||
|
|
||||||
|
@ -5,9 +5,9 @@ import com.djrapitops.plan.api.exceptions.database.FatalDBException;
|
|||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class ErrorUtil {
|
public class SQLErrorUtil {
|
||||||
|
|
||||||
private ErrorUtil() {
|
private SQLErrorUtil() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DBException getExceptionFor(SQLException e) {
|
public static DBException getExceptionFor(SQLException e) {
|
@ -4,19 +4,19 @@ import com.djrapitops.plan.system.database.databases.Database;
|
|||||||
import com.djrapitops.plan.system.database.databases.operation.BackupOperations;
|
import com.djrapitops.plan.system.database.databases.operation.BackupOperations;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
|
|
||||||
public class SQLBackupOps implements BackupOperations {
|
public class SQLBackupOps extends SQLOps implements BackupOperations {
|
||||||
|
|
||||||
private final SQLDB db;
|
|
||||||
|
|
||||||
public SQLBackupOps(SQLDB db) {
|
public SQLBackupOps(SQLDB db) {
|
||||||
this.db = db;
|
super(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void backup(Database toDatabase) {
|
public void backup(Database toDatabase) {
|
||||||
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restore(Database fromDatabase) {
|
public void restore(Database fromDatabase) {
|
||||||
|
// TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,44 +2,57 @@ package com.djrapitops.plan.system.database.databases.sql.operation;
|
|||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||||
import com.djrapitops.plan.system.database.databases.operation.CheckOperations;
|
import com.djrapitops.plan.system.database.databases.operation.CheckOperations;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.ErrorUtil;
|
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
|
import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil;
|
||||||
|
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class SQLCheckOps implements CheckOperations {
|
public class SQLCheckOps extends SQLOps implements CheckOperations {
|
||||||
|
|
||||||
private final SQLDB db;
|
|
||||||
|
|
||||||
public SQLCheckOps(SQLDB db) {
|
public SQLCheckOps(SQLDB db) {
|
||||||
this.db = db;
|
super(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPlayerRegistered(UUID player) throws DBException {
|
public boolean isPlayerRegistered(UUID player) throws DBException {
|
||||||
try {
|
try {
|
||||||
return db.getUsersTable().isRegistered(player);
|
return usersTable.isRegistered(player);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPlayerRegistered(UUID player, UUID server) throws DBException {
|
public boolean isPlayerRegistered(UUID player, UUID server) throws DBException {
|
||||||
try {
|
try {
|
||||||
return db.getUserInfoTable().isRegistered(player, server);
|
return userInfoTable.isRegistered(player, server);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doesWebUserExists(String username) throws DBException {
|
public boolean doesWebUserExists(String username) throws DBException {
|
||||||
try {
|
try {
|
||||||
return db.getSecurityTable().userExists(username);
|
return securityTable.userExists(username);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPlayerRegisteredOnThisServer(UUID player) throws DBException {
|
||||||
|
return isPlayerRegistered(player, ServerInfo.getServerUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isServerInDatabase(UUID serverUUID) throws DBException {
|
||||||
|
try {
|
||||||
|
return serverTable.getServerID(serverUUID).isPresent();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ package com.djrapitops.plan.system.database.databases.sql.operation;
|
|||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||||
import com.djrapitops.plan.system.database.databases.operation.CountOperations;
|
import com.djrapitops.plan.system.database.databases.operation.CountOperations;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.ErrorUtil;
|
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
|
import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -19,7 +19,7 @@ public class SQLCountOps extends SQLOps implements CountOperations {
|
|||||||
try {
|
try {
|
||||||
return userInfoTable.getServerUserCount(server);
|
return userInfoTable.getServerUserCount(server);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ public class SQLCountOps extends SQLOps implements CountOperations {
|
|||||||
try {
|
try {
|
||||||
return usersTable.getPlayerCount();
|
return usersTable.getPlayerCount();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,9 @@ import com.djrapitops.plan.data.ServerProfile;
|
|||||||
import com.djrapitops.plan.data.WebUser;
|
import com.djrapitops.plan.data.WebUser;
|
||||||
import com.djrapitops.plan.data.container.*;
|
import com.djrapitops.plan.data.container.*;
|
||||||
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
|
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.ErrorUtil;
|
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
|
import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil;
|
||||||
|
import com.djrapitops.plan.system.info.server.Server;
|
||||||
import com.djrapitops.plan.utilities.MiscUtils;
|
import com.djrapitops.plan.utilities.MiscUtils;
|
||||||
import com.djrapitops.plugin.api.TimeAmount;
|
import com.djrapitops.plugin.api.TimeAmount;
|
||||||
|
|
||||||
@ -45,7 +46,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
|
|
||||||
return profile;
|
return profile;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +84,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
}
|
}
|
||||||
return players;
|
return players;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +119,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
|
|
||||||
return profile;
|
return profile;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +143,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return usersTable.getSavedUUIDs();
|
return usersTable.getSavedUUIDs();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +152,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return userInfoTable.getSavedUUIDs(server);
|
return userInfoTable.getSavedUUIDs(server);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +161,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return serverTable.getServerNames();
|
return serverTable.getServerNames();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,7 +170,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return serverTable.getServerUUID(serverName);
|
return serverTable.getServerUUID(serverName);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,27 +179,25 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return usersTable.getUuidOf(playerName);
|
return usersTable.getUuidOf(playerName);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WebUser getWebUser(String username) throws DBException {
|
public WebUser getWebUser(String username) throws DBException {
|
||||||
try {
|
try {
|
||||||
return securityTable.getWebUser(username);
|
return securityTable.getWebUser(username);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TPS> getTPSData(UUID serverUUID) throws DBException {
|
public List<TPS> getTPSData(UUID serverUUID) throws DBException {
|
||||||
try {
|
try {
|
||||||
return tpsTable.getTPSData(serverUUID);
|
return tpsTable.getTPSData(serverUUID);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +206,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return tpsTable.getNetworkOnlineData();
|
return tpsTable.getNetworkOnlineData();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,7 +215,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return usersTable.getRegisterDates();
|
return usersTable.getRegisterDates();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +224,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return tpsTable.getAllTimePeak(serverUUID);
|
return tpsTable.getAllTimePeak(serverUUID);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +233,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return tpsTable.getPeakPlayerCount(serverUUID, afterDate);
|
return tpsTable.getPeakPlayerCount(serverUUID, afterDate);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +242,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return sessionsTable.getAllSessions(false);
|
return sessionsTable.getAllSessions(false);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +251,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return sessionsTable.getAllSessions(true);
|
return sessionsTable.getAllSessions(true);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +260,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return worldTable.getWorldNames(serverUuid);
|
return worldTable.getWorldNames(serverUuid);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +269,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return nicknamesTable.getNicknames(uuid, serverUUID);
|
return nicknamesTable.getNicknames(uuid, serverUUID);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +278,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return actionsTable.getActions(uuid);
|
return actionsTable.getActions(uuid);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,7 +287,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return usersTable.getUsers();
|
return usersTable.getUsers();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +296,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return sessionsTable.getLastSeenForAllPlayers();
|
return sessionsTable.getLastSeenForAllPlayers();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +305,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return geoInfoTable.getAllGeoInfo();
|
return geoInfoTable.getAllGeoInfo();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,7 +314,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return usersTable.getPlayerNames();
|
return usersTable.getPlayerNames();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,7 +323,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return usersTable.getPlayerName(playerUUID);
|
return usersTable.getPlayerName(playerUUID);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,7 +332,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return serverTable.getServerName(serverUUID);
|
return serverTable.getServerName(serverUUID);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +341,25 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
|
|||||||
try {
|
try {
|
||||||
return nicknamesTable.getNicknames(uuid);
|
return nicknamesTable.getNicknames(uuid);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Server> getBungeeInformation() throws DBException {
|
||||||
|
try {
|
||||||
|
return serverTable.getBungeeInfo();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Integer> getServerID(UUID serverUUID) throws DBException {
|
||||||
|
try {
|
||||||
|
return serverTable.getServerID(serverUUID);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ package com.djrapitops.plan.system.database.databases.sql.operation;
|
|||||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||||
import com.djrapitops.plan.api.exceptions.database.FatalDBException;
|
import com.djrapitops.plan.api.exceptions.database.FatalDBException;
|
||||||
import com.djrapitops.plan.system.database.databases.operation.RemoveOperations;
|
import com.djrapitops.plan.system.database.databases.operation.RemoveOperations;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.ErrorUtil;
|
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
|
import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.tables.Table;
|
import com.djrapitops.plan.system.database.databases.sql.tables.Table;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.tables.UserIDTable;
|
import com.djrapitops.plan.system.database.databases.sql.tables.UserIDTable;
|
||||||
import com.djrapitops.plugin.api.Benchmark;
|
import com.djrapitops.plugin.api.Benchmark;
|
||||||
@ -41,7 +41,7 @@ public class SQLRemoveOps extends SQLOps implements RemoveOperations {
|
|||||||
|
|
||||||
securityTable.removeUser(webUser);
|
securityTable.removeUser(webUser);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getFatalExceptionFor(e);
|
throw SQLErrorUtil.getFatalExceptionFor(e);
|
||||||
} finally {
|
} finally {
|
||||||
Benchmark.stop("Database", "Remove Account");
|
Benchmark.stop("Database", "Remove Account");
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ public class SQLRemoveOps extends SQLOps implements RemoveOperations {
|
|||||||
table.removeAllData();
|
table.removeAllData();
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getFatalExceptionFor(e);
|
throw SQLErrorUtil.getFatalExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ public class SQLRemoveOps extends SQLOps implements RemoveOperations {
|
|||||||
try {
|
try {
|
||||||
securityTable.removeUser(userName);
|
securityTable.removeUser(userName);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getFatalExceptionFor(e);
|
throw SQLErrorUtil.getFatalExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,9 @@ package com.djrapitops.plan.system.database.databases.sql.operation;
|
|||||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||||
import com.djrapitops.plan.data.container.*;
|
import com.djrapitops.plan.data.container.*;
|
||||||
import com.djrapitops.plan.system.database.databases.operation.SaveOperations;
|
import com.djrapitops.plan.system.database.databases.operation.SaveOperations;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.ErrorUtil;
|
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
|
import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil;
|
||||||
|
import com.djrapitops.plan.system.info.server.Server;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -31,7 +32,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
tpsTable.insertAllTPS(ofServers);
|
tpsTable.insertAllTPS(ofServers);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
commandUseTable.insertCommandUsage(ofServers);
|
commandUseTable.insertCommandUsage(ofServers);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +50,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
usersTable.insertUsers(ofServers);
|
usersTable.insertUsers(ofServers);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
sessionsTable.insertSessions(ofServers, containsExtraData);
|
sessionsTable.insertSessions(ofServers, containsExtraData);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
usersTable.updateKicked(ofUsers);
|
usersTable.updateKicked(ofUsers);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +77,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
userInfoTable.insertUserInfo(ofServers);
|
userInfoTable.insertUserInfo(ofServers);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +86,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
nicknamesTable.insertNicknames(ofServers);
|
nicknamesTable.insertNicknames(ofServers);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
geoInfoTable.insertAllGeoInfo(ofUsers);
|
geoInfoTable.insertAllGeoInfo(ofUsers);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +104,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
userInfoTable.updateBanStatus(uuid, banned);
|
userInfoTable.updateBanStatus(uuid, banned);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +113,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
userInfoTable.updateOpStatus(uuid, op);
|
userInfoTable.updateOpStatus(uuid, op);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +122,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
usersTable.registerUser(uuid, registered, name);
|
usersTable.registerUser(uuid, registered, name);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +131,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
actionsTable.insertAction(uuid, action);
|
actionsTable.insertAction(uuid, action);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +140,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
geoInfoTable.saveGeoInfo(uuid, geoInfo);
|
geoInfoTable.saveGeoInfo(uuid, geoInfo);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +149,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
usersTable.kicked(uuid);
|
usersTable.kicked(uuid);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +158,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
usersTable.updateName(uuid, playerName);
|
usersTable.updateName(uuid, playerName);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +167,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
nicknamesTable.saveUserName(uuid, displayName);
|
nicknamesTable.saveUserName(uuid, displayName);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +176,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
userInfoTable.registerUserInfo(uuid, registered);
|
userInfoTable.registerUserInfo(uuid, registered);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +185,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
commandUseTable.commandUsed(commandName);
|
commandUseTable.commandUsed(commandName);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +194,7 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
tpsTable.insertTPS(tps);
|
tpsTable.insertTPS(tps);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +203,16 @@ public class SQLSaveOps extends SQLOps implements SaveOperations {
|
|||||||
try {
|
try {
|
||||||
sessionsTable.saveSession(uuid, session);
|
sessionsTable.saveSession(uuid, session);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void serverInfoForThisServer(Server server) throws DBException {
|
||||||
|
try {
|
||||||
|
serverTable.saveCurrentServerInfo(server);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,8 +2,8 @@ package com.djrapitops.plan.system.database.databases.sql.operation;
|
|||||||
|
|
||||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||||
import com.djrapitops.plan.system.database.databases.operation.SearchOperations;
|
import com.djrapitops.plan.system.database.databases.operation.SearchOperations;
|
||||||
import com.djrapitops.plan.system.database.databases.sql.ErrorUtil;
|
|
||||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||||
|
import com.djrapitops.plan.system.database.databases.sql.SQLErrorUtil;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -19,7 +19,7 @@ public class SQLSearchOps extends SQLOps implements SearchOperations {
|
|||||||
try {
|
try {
|
||||||
return usersTable.getMatchingNames(search);
|
return usersTable.getMatchingNames(search);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw ErrorUtil.getExceptionFor(e);
|
throw SQLErrorUtil.getExceptionFor(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user