SteamWar/BungeeCore
Archiviert
13
2

GDPR query processor #271

Zusammengeführt
Lixfel hat 3 Commits von dsgvo-query nach master 2021-12-02 08:37:45 +01:00 zusammengeführt
Nur Änderungen aus Commit a6ea418047 werden angezeigt - Alle Commits anzeigen

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,26 +90,31 @@ 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 -> {
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++) {
try {
writer.write(rs.getString(i));
} catch (NullPointerException e) {
// ignored
}
writer.write(rs.getMetaData().getColumnLabel(i));
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;
}, 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);
}
}, 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");
String path = "PersonalKit/" + rs.getString("GameMode") + "/" + rs.getString("Name");
try(InputStream data = rs.getBinaryStream("Inventory")) {
copy(data, out, path + ".Inventory.yml");
}
try(InputStream data = rs.getBinaryStream("Armor")) {
copy(data, out, path + ".Armor.yml");
}
} catch (IOException e) {
throw new SecurityException("Could not export PersonalKits", e);
}