mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-05 10:20:23 +01:00
Transfer Operations for CacheInspectPluginsTab
This commit is contained in:
parent
f50d8dc90c
commit
457334403e
@ -26,7 +26,7 @@ public interface TransferOperations {
|
||||
|
||||
void storeNetworkPageContent(UUID serverUUID, String encodedHtml) throws DBException;
|
||||
|
||||
void storePlayerPluginsTab(UUID player, UUID serverUUID, String encodedHtml) throws DBException;
|
||||
void storePlayerPluginsTab(UUID player, String encodedHtml) throws DBException;
|
||||
|
||||
// Get
|
||||
|
||||
|
@ -76,4 +76,27 @@ public class SQLTransferOps extends SQLOps implements TransferOperations {
|
||||
throw SQLErrorUtil.getExceptionFor(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storePlayerPluginsTab(UUID player, String encodedHtml) throws DBException {
|
||||
try {
|
||||
transferTable.storePlayerPluginsTab(player, encodedHtml);
|
||||
} catch (SQLException e) {
|
||||
throw SQLErrorUtil.getExceptionFor(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getServerPlayerIsOnline(UUID playerUUID) {
|
||||
return null; // TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, String> getEncodedPlayerPluginsTabs(UUID playerUUID) throws DBException {
|
||||
try {
|
||||
return transferTable.getPlayerPluginsTabs(playerUUID);
|
||||
} catch (SQLException e) {
|
||||
throw SQLErrorUtil.getExceptionFor(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ import com.djrapitops.plan.system.database.databases.sql.statements.Sql;
|
||||
import com.djrapitops.plan.system.database.databases.sql.statements.TableSqlParser;
|
||||
import com.djrapitops.plan.system.info.request.CacheAnalysisPageRequest;
|
||||
import com.djrapitops.plan.system.info.request.CacheInspectPageRequest;
|
||||
import com.djrapitops.plan.system.info.request.CacheInspectPluginsTabRequest;
|
||||
import com.djrapitops.plan.system.info.request.CacheNetworkPageContentRequest;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.utilities.MiscUtils;
|
||||
@ -147,4 +148,51 @@ public class TransferTable extends Table {
|
||||
public Map<UUID, String> getServerHtml() throws SQLException {
|
||||
return getHtmlPerUUIDForCacheRequest(CacheAnalysisPageRequest.class);
|
||||
}
|
||||
|
||||
public void storePlayerPluginsTab(UUID player, String encodedHtml) throws SQLException {
|
||||
execute(new ExecStatement(insertStatement) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, ServerInfo.getServerUUID().toString());
|
||||
statement.setLong(2, MiscUtils.getTime() + TimeAmount.MINUTE.ms());
|
||||
statement.setString(3, CacheInspectPluginsTabRequest.class.getSimpleName().toLowerCase());
|
||||
statement.setString(4, player.toString());
|
||||
statement.setString(5, encodedHtml);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Map<UUID, String> getPlayerPluginsTabs(UUID playerUUID) throws SQLException {
|
||||
String serverIDColumn = serverTable + "." + serverTable.getColumnID();
|
||||
String serverUUIDColumn = serverTable + "." + serverTable.getColumnUUID() + " as s_uuid";
|
||||
String sql = "SELECT " +
|
||||
columnContent + ", " +
|
||||
serverUUIDColumn +
|
||||
" FROM " + tableName +
|
||||
" JOIN " + serverTable + " on " + serverIDColumn + "=" + columnSenderID +
|
||||
" WHERE " + columnInfoType + "= ?" +
|
||||
" AND " + columnExpiry + "> ?" +
|
||||
" AND " + columnExtraVariables + "=?";
|
||||
|
||||
return query(new QueryStatement<Map<UUID, String>>(sql, 250) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, CacheInspectPluginsTabRequest.class.getSimpleName().toLowerCase());
|
||||
statement.setLong(2, MiscUtils.getTime());
|
||||
statement.setString(3, playerUUID.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, String> processResults(ResultSet set) throws SQLException {
|
||||
Map<UUID, String> htmlPerUUID = new HashMap<>();
|
||||
while (set.next()) {
|
||||
UUID serverUUID = UUID.fromString(set.getString("s_uuid"));
|
||||
String html64 = set.getString(columnContent);
|
||||
|
||||
htmlPerUUID.put(serverUUID, html64);
|
||||
}
|
||||
return htmlPerUUID;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -9,7 +9,6 @@ import com.djrapitops.plan.api.exceptions.connection.TransferDatabaseException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.webserver.pages.DefaultResponses;
|
||||
import com.djrapitops.plan.system.webserver.response.Response;
|
||||
import com.djrapitops.plan.system.webserver.response.cache.PageId;
|
||||
@ -55,7 +54,7 @@ public class CacheInspectPluginsTabRequest extends InfoRequestWithVariables impl
|
||||
|
||||
String encodedHtml = Base64Util.encode(navAndHtml);
|
||||
try {
|
||||
Database.getActive().transfer().storePlayerPluginsTab(player, ServerInfo.getServerUUID(), encodedHtml);
|
||||
Database.getActive().transfer().storePlayerPluginsTab(player, encodedHtml);
|
||||
} catch (DBException e) {
|
||||
throw new TransferDatabaseException(e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user