Package main.controller.account
Class AccountManager
java.lang.Object
main.controller.account.AccountManager
A class manages the account of a user
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
changePassword
(UserType userType, String userID, String oldPassword, String newPassword) Changes the password of the userstatic User
getByDomainAndID
(UserType userType, String ID) Gets the user by the domain and IDprivate static String
Loads the students and coordinators from the CSV filegetUsersByUserName
(String userName) Gets the user by the user nameprivate static void
Loads the coordinators from the CSV resource fileprivate static void
Loads the faculties from the CSV resource fileprivate static void
Loads the students from the CSV resource filestatic void
Loads all users from the CSV resource filestatic User
Adds a new user to the databasestatic User
Registers a new userstatic User
Registers a new userstatic boolean
Checks if the repository is empty
-
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 addeduserID
- the ID of the user to be addedpassword
- the password of the user to be added- Returns:
- the user that is added
- Throws:
PasswordIncorrectException
- if the password is incorrectModelNotFoundException
- 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 changeduserID
- the ID of the user to be changedoldPassword
- the old password of the user to be changednewPassword
- the new password of the user to be changed- Throws:
PasswordIncorrectException
- if the old password is incorrectModelNotFoundException
- if the user is not found
-
getUsersByUserName
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 registereduserID
- the ID of the user to be registeredpassword
- the password of the user to be registeredname
- the name of the user to be registeredemail
- 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 registereduserID
- the ID of the user to be registeredname
- the name of the user to be registeredemail
- the email of the user to be registered- Returns:
- the user that is registered
- Throws:
ModelAlreadyExistsException
- if the user already exists
-
getID
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
Gets the user by the domain and ID- Parameters:
userType
- the type of the userID
- the ID of the user- Returns:
- the user with the domain and ID
- Throws:
ModelNotFoundException
- if the user is not found
-