aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/persistence')
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/CupboardFileDAO.java7
-rw-r--r--ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserFileDAO.java11
2 files changed, 7 insertions, 11 deletions
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/CupboardFileDAO.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/CupboardFileDAO.java
index 3115204..7efda83 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/CupboardFileDAO.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/CupboardFileDAO.java
@@ -55,14 +55,12 @@ public class CupboardFileDAO implements CupboardDAO {
/**
* Saves the needs to json
*
- * @return True if the save was successful, false otherwise
* @throws IOException If there was an IO issue saving the file
*/
- private boolean save() throws IOException {
+ private void save() throws IOException {
Need[] needArray = needs.values().toArray(Need[]::new);
objectMapper.writeValue(new File(filename), needArray);
- return true;
}
@Override
@@ -109,7 +107,8 @@ public class CupboardFileDAO implements CupboardDAO {
synchronized (needs) {
if (needs.containsKey(id)) {
needs.remove(id);
- return save();
+ save();
+ return true;
} else {
return false;
}
diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserFileDAO.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserFileDAO.java
index 63d864a..0d9b9e4 100644
--- a/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserFileDAO.java
+++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserFileDAO.java
@@ -45,12 +45,10 @@ public class UserFileDAO implements UserDAO {
/**
* Saves the needs to json
*
- * @return True if the save was successful, false otherwise
* @throws IOException If there was an IO issue saving the file
*/
- private boolean save() throws IOException {
+ private void save() throws IOException {
objectMapper.writeValue(new File(filename), users.values());
- return true;
}
@Override
@@ -83,9 +81,7 @@ public class UserFileDAO implements UserDAO {
public User updateUser(User user) throws IOException {
synchronized (users) {
if (users.containsKey(user.getUsername())) {
- // var old = users.put(user.getUsername(), user);
- // user.copyPassword(old);
- if (user.getBasket() == null || user.getType() == null) {
+ if (user.getBasket() == null || user.getType() == null) { // TODO clean this up
User oldData = users.get(user.getUsername());
User crutch = new User(oldData.getUsername(), 0, new ArrayList<>(), oldData.getType());
crutch.copyPassword(oldData);
@@ -107,7 +103,8 @@ public class UserFileDAO implements UserDAO {
synchronized (users) {
if (users.containsKey(username)) {
users.remove(username);
- return save();
+ save();
+ return true;
} else {
return false;
}