SteamWar/BungeeCore
Archiviert
13
2

WIP GDPR query processor
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2021-11-23 19:59:50 +01:00
Ursprung 866d57f8dc
Commit a6ea418047

Datei anzeigen

@ -6,7 +6,6 @@ import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.io.*; import java.io.*;
import java.sql.SQLException;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
@ -91,26 +90,31 @@ public class GDPRQuery extends BasicCommand {
private void sqlCSV(SteamwarUser user, ZipOutputStream out, Statement statement, String path) throws IOException { private void sqlCSV(SteamwarUser user, ZipOutputStream out, Statement statement, String path) throws IOException {
write(stream -> { write(stream -> {
PrintWriter writer = new PrintWriter(stream); OutputStreamWriter writer = new OutputStreamWriter(stream);
statement.select(rs -> { statement.select(rs -> {
int columns = rs.getMetaData().getColumnCount(); try {
int columns = rs.getMetaData().getColumnCount();
for(int i = 1; i <= columns; i++) {
writer.write(rs.getMetaData().getColumnName(1));
writer.write(";");
}
writer.println();
while(rs.next()) {
for(int i = 1; i <= columns; i++) { for(int i = 1; i <= columns; i++) {
try { writer.write(rs.getMetaData().getColumnLabel(i));
writer.write(rs.getString(i));
} catch (NullPointerException e) {
// ignored
}
writer.write(";"); writer.write(";");
} }
writer.println(); writer.write("\n");
while(rs.next()) {
for(int i = 1; i <= columns; i++) {
try {
writer.write(rs.getString(i));
} catch (NullPointerException e) {
// ignored
}
writer.write(";");
}
writer.write("\n");
}
writer.flush();
} catch (IOException e) {
throw new SecurityException("Could not write file", e);
} }
return null; return null;
}, user.getId()); }, user.getId());
@ -121,20 +125,13 @@ public class GDPRQuery extends BasicCommand {
personalKitData.select(rs -> { personalKitData.select(rs -> {
while(rs.next()) { while(rs.next()) {
try { try {
write(stream -> { String path = "PersonalKit/" + rs.getString("GameMode") + "/" + rs.getString("Name");
try { try(InputStream data = rs.getBinaryStream("Inventory")) {
new PrintWriter(stream).print(rs.getString("Inventory")); copy(data, out, path + ".Inventory.yml");
} catch (SQLException e) { }
throw new SecurityException("Could not export PersonalKits", e); try(InputStream data = rs.getBinaryStream("Armor")) {
} copy(data, out, path + ".Armor.yml");
}, out, "PersonalKit/" + rs.getString("GameMode") + "/" + rs.getString("Name") + ".Inventory.yml"); }
write(stream -> {
try {
new PrintWriter(stream).print(rs.getString("Armor"));
} catch (SQLException e) {
throw new SecurityException("Could not export PersonalKits", e);
}
}, out, "PersonalKit/" + rs.getString("GameMode") + "/" + rs.getString("Name") + ".Armor.yml");
} catch (IOException e) { } catch (IOException e) {
throw new SecurityException("Could not export PersonalKits", e); throw new SecurityException("Could not export PersonalKits", e);
} }