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