Skip to content
Snippets Groups Projects
Commit d7bf7518 authored by Paul-Christian Volkmer's avatar Paul-Christian Volkmer
Browse files

Remove user serialization from UserService

parent c1ff00da
Branches
Tags
No related merge requests found
......@@ -222,55 +222,9 @@ public class UserService implements IUserService, InitializingBean, DisposableBe
return null;
}
@Override
public void afterPropertiesSet() {
try {
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File store = new File(tmpDir, "arsnova.bin");
if (!store.exists()) {
return;
}
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(store));
Hashtable<String, Map<?, ?>> map = (Hashtable<String, Map<?, ?>>) ois.readObject();
ois.close();
Map<UUID, User> s2u = (Map<UUID, User>) map.get("socketid2user");
Map<User, String> u2s = (Map<User, String>) map.get("user2session");
LOGGER.info("load from store: {}", map);
socketid2user.putAll(s2u);
user2sessionLegacy.putAll(u2s);
} catch (IOException e) {
LOGGER.error("IOException during restoring UserService", e);
} catch (ClassNotFoundException e) {
LOGGER.error("ClassNotFoundException during restoring UserService", e);
}
}
@Override
public void destroy() {
Hashtable<String, Map<?, ?>> map = new Hashtable<String, Map<?, ?>>();
map.put("socketid2user", socketid2user);
map.put("user2session", user2sessionLegacy);
try {
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File store = new File(tmpDir, "arsnova.bin");
if (!store.exists()) {
if (! store.createNewFile()) {
LOGGER.info("Could not create store file");
}
}
OutputStream file = new FileOutputStream(store);
ObjectOutputStream objOut = new ObjectOutputStream(file);
objOut.writeObject(map);
objOut.close();
file.close();
LOGGER.info("saved to store: {}", map);
} catch (IOException e) {
LOGGER.error("IOException while saving UserService", e);
}
LOGGER.error("Destroy UserService");
}
@Override
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment