diff options
Diffstat (limited to 'ufund-api/src/main/java/com/ufund/api/ufundapi/persistence')
3 files changed, 8 insertions, 41 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 4494939..1fc1e92 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 @@ -59,15 +59,15 @@ public class UserAuthFIleDAO implements UserAuthDAO { public void addUserAuth(UserAuth userAuth) throws IOException { synchronized (userAuthMap) { userAuthMap.put(userAuth.getKey(), userAuth); + save(); } - save(); } @Override public void removeUserAuth(String key) throws IOException { synchronized (userAuthMap) { userAuthMap.remove(key); + save(); } - save(); } } diff --git a/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java index 6558ce2..29d46cf 100644 --- a/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java +++ b/ufund-api/src/main/java/com/ufund/api/ufundapi/persistence/UserDAO.java @@ -49,15 +49,14 @@ public interface UserDAO { /** * Updates and saves a {@linkplain User user} * - * @param newUser {@link User user} object to be updated and saved - * @param name {@link String name} name of object to be updated + * @param user {@link User user} object to be updated and saved * * @return updated {@link User user} if successful, null if * {@link User user} could not be found * * @throws IOException if underlying storage cannot be accessed */ - User updateUser(User newUser, String name) throws IOException; + User updateUser(User user) throws IOException; /** * Deletes a {@linkplain User user} with the given id 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 9b206c8..f17f8f2 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 @@ -58,13 +58,6 @@ public class UserFileDAO implements UserDAO { } } - /** - * Return the user with the String name name or null otherwise - * - * @param username Name of desired user - * - * @return Desired user, null otherwise - */ @Override public User getUser(String username) { synchronized (users) { @@ -72,14 +65,6 @@ public class UserFileDAO implements UserDAO { } } - /** - * Create a User user - * - * @param user User to create - * - * @return Desired created user - * @throws IOException If there was an IO issue saving the file - */ @Override public User addUser(User user) throws IOException { synchronized (users) { @@ -92,36 +77,19 @@ public class UserFileDAO implements UserDAO { } } - /** - * Update a user that matches the supplied name - * - * @param name The name of the user - * @param newUser New user data - * - * @return Desired user, null otherwise - * @throws IOException If there was an IO issue saving the file - */ @Override - public User updateUser(User newUser, String name) throws IOException { + public User updateUser(User user) throws IOException { synchronized (users) { - if (users.containsKey(name)) { - users.put(name, newUser); + if (users.containsKey(user.getUsername())) { + users.put(user.getUsername(), user); save(); - return newUser; + return user; } else { return null; } } } - /** - * Delete a user matching the name - * - * @param username The name of the user - * - * @return True if deleted, false otherwise - * @throws IOException If there was an IO issue saving the file - */ @Override public boolean deleteUser(String username) throws IOException { synchronized (users) { |