Class AccountManager

java.lang.Object
main.controller.account.AccountManager

public class AccountManager extends Object
A class manages the account of a user
  • Constructor Details

    • AccountManager

      public AccountManager()
  • Method Details

    • login

      public static User login(UserType userType, String userID, String password) throws PasswordIncorrectException, ModelNotFoundException
      Adds a new user to the database
      Parameters:
      userType - the type of the user to be added
      userID - the ID of the user to be added
      password - the password of the user to be added
      Returns:
      the user that is added
      Throws:
      PasswordIncorrectException - if the password is incorrect
      ModelNotFoundException - if the user is not found
    • changePassword

      public static void changePassword(UserType userType, String userID, String oldPassword, String newPassword) throws PasswordIncorrectException, ModelNotFoundException
      Changes the password of the user
      Parameters:
      userType - the type of the user to be changed
      userID - the ID of the user to be changed
      oldPassword - the old password of the user to be changed
      newPassword - the new password of the user to be changed
      Throws:
      PasswordIncorrectException - if the old password is incorrect
      ModelNotFoundException - if the user is not found
    • getUsersByUserName

      public static List<User> getUsersByUserName(String userName)
      Gets the user by the user name
      Parameters:
      userName - the user name of the user
      Returns:
      the user with the user name
    • register

      public static User register(UserType userType, String userID, String password, String name, String email) throws ModelAlreadyExistsException
      Registers a new user
      Parameters:
      userType - the type of the user to be registered
      userID - the ID of the user to be registered
      password - the password of the user to be registered
      name - the name of the user to be registered
      email - the email of the user to be registered
      Returns:
      the user that is registered
      Throws:
      ModelAlreadyExistsException - if the user already exists
    • register

      public static User register(UserType userType, String userID, String name, String email) throws ModelAlreadyExistsException
      Registers a new user
      Parameters:
      userType - the type of the user to be registered
      userID - the ID of the user to be registered
      name - the name of the user to be registered
      email - the email of the user to be registered
      Returns:
      the user that is registered
      Throws:
      ModelAlreadyExistsException - if the user already exists
    • getID

      private static String getID(String email)
      Loads the students and coordinators from the CSV file
      Parameters:
      email - the email of the user
      Returns:
      the ID of the user
    • loadStudents

      private static void loadStudents()
      Loads the students from the CSV resource file
    • loadCoordinators

      private static void loadCoordinators()
      Loads the coordinators from the CSV resource file
    • loadFaculties

      private static void loadFaculties()
      Loads the faculties from the CSV resource file
    • loadUsers

      public static void loadUsers()
      Loads all users from the CSV resource file
    • repositoryIsEmpty

      public static boolean repositoryIsEmpty()
      Checks if the repository is empty
      Returns:
      true if the repository is empty, false otherwise
    • getByDomainAndID

      public static User getByDomainAndID(UserType userType, String ID) throws ModelNotFoundException
      Gets the user by the domain and ID
      Parameters:
      userType - the type of the user
      ID - the ID of the user
      Returns:
      the user with the domain and ID
      Throws:
      ModelNotFoundException - if the user is not found