aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserAuthFIleDAO.java
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2025-03-06 21:41:39 -0500
committersowgro <tpoke.ferrari@gmail.com>2025-03-06 21:41:39 -0500
commitbb9ce55cb5b55a6aaed2399e39a01d68f2491ce3 (patch)
tree7df43079fa8d3e5c7b34c5ab13389018c1216078 /ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserAuthFIleDAO.java
parenteb4edcc7e7e4f9a6a59bed6d3952486f179fc445 (diff)
downloadJellySolutions-bb9ce55cb5b55a6aaed2399e39a01d68f2491ce3.tar.gz
JellySolutions-bb9ce55cb5b55a6aaed2399e39a01d68f2491ce3.tar.bz2
JellySolutions-bb9ce55cb5b55a6aaed2399e39a01d68f2491ce3.zip
Push current changes (working on documentation and tests)
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserAuthFIleDAO.java')
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserAuthFIleDAO.java27
1 files changed, 19 insertions, 8 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserAuthFIleDAO.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserAuthFIleDAO.java
index 67918cc..4494939 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserAuthFIleDAO.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserAuthFIleDAO.java
@@ -24,6 +24,11 @@ public class UserAuthFIleDAO implements UserAuthDAO {
load();
}
+ /**
+ * Loads the data from the file into the map
+ *
+ * @throws IOException Thrown if there was an issue reading the file
+ */
private void load() throws IOException {
userAuthMap.clear();
@@ -34,29 +39,35 @@ public class UserAuthFIleDAO implements UserAuthDAO {
}
}
+ /**
+ * Saves the data from the map into the json file
+ *
+ * @throws IOException Thrown on any problem writing the file
+ */
private void save() throws IOException {
objectMapper.writeValue(new File(filename), userAuthMap.values());
}
- public UserAuth[] getAuthKeys() {
+ @Override
+ public UserAuth getUserAuth(String key) {
synchronized (userAuthMap) {
- return userAuthMap.values().toArray(UserAuth[]::new);
+ return userAuthMap.get(key);
}
}
@Override
- public UserAuth getUserAuth(String key) {
+ public void addUserAuth(UserAuth userAuth) throws IOException {
synchronized (userAuthMap) {
- return userAuthMap.get(key);
+ userAuthMap.put(userAuth.getKey(), userAuth);
}
+ save();
}
@Override
- public boolean addUserAuth(UserAuth userAuth) throws IOException {
+ public void removeUserAuth(String key) throws IOException {
synchronized (userAuthMap) {
- userAuthMap.put(userAuth.getKey(), userAuth);
- save();
- return true;
+ userAuthMap.remove(key);
}
+ save();
}
}