Archiviert
1
0

WIP GDPR query processor

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,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);
}