Package com.rit.dca.pubpaper.dao
Class UserDAO
java.lang.Object
com.rit.dca.pubpaper.dao.UserDAO
public class UserDAO
extends java.lang.Object
Database Connectivity and Access
-
Field Summary
Fields Modifier and Type Field Description private int
loggedInId
-
Constructor Summary
Constructors Constructor Description UserDAO()
-
Method Summary
Modifier and Type Method Description User
changeAdminStatus(int userId, boolean adminStatus)
Make a particular user Admin (Admin Only)User
changeReviewStatus(int userId, boolean reviewStatus)
Change review status of a particular user (Admin Only)protected boolean
checkAdmin(MySQLDatabase connection, int adminUserId)
Check whether a user is an admin userint
deleteUsers(int[] deletionIds)
Delete a particular user (Admin only)java.util.ArrayList<User>
getAllUsers()
Get all users (Admin only)int
getLoggedInId()
User
getProfile(int userId)
Get the profile info for user object (all properties)User
getUser(int userId)
Get a particular user information (Admin Only)User
login(java.lang.String email, java.lang.String password)
Login a particular user into the systemboolean
logout()
private int
nextUserId(MySQLDatabase connection)
Get the new user id to be insertedboolean
resetPassword(java.lang.String email)
Resets user's passwordprivate java.lang.String
setPassword(java.lang.String password)
Returns hashed passwordUser
setProfile(java.util.HashMap<java.lang.String,java.lang.Object> userData)
Set/Create profile info for existing/new user
-
Field Details
-
loggedInId
private int loggedInId
-
-
Constructor Details
-
UserDAO
public UserDAO()
-
-
Method Details
-
getLoggedInId
public int getLoggedInId() -
getProfile
Get the profile info for user object (all properties)- Parameters:
userId
- - user id for which profile data is requested.- Returns:
- User object of the profile requested
- Throws:
PubPaperException
-
setProfile
public User setProfile(java.util.HashMap<java.lang.String,java.lang.Object> userData) throws PubPaperExceptionSet/Create profile info for existing/new user- Parameters:
userData
- HashMap (key-value pairs) of profile parameters- Returns:
- User object of the profile which is updated/created
- Throws:
PubPaperException
-
nextUserId
Get the new user id to be inserted- Parameters:
connection
- MySQLDatabase connection object- Returns:
- int new user id to use
-
resetPassword
Resets user's password- Parameters:
email
- emailId of the user- Returns:
- Boolean value indicating if password reset was successful or no
- Throws:
PubPaperException
-
login
Login a particular user into the system- Parameters:
email
- emailId of the userpassword
- password of the user- Returns:
- User - user instance
- Throws:
PubPaperException
-
setPassword
private java.lang.String setPassword(java.lang.String password)Returns hashed password- Parameters:
password
- password of the user- Returns:
- String hashed password string
-
checkAdmin
Check whether a user is an admin user- Parameters:
connection
- MYSQLDatabase connection objectadminUserId
- id of the user- Returns:
- boolean status of validation
- Throws:
PubPaperException
-
getAllUsers
Get all users (Admin only)- Returns:
- ArrayList
Arraylist of all users in the database - Throws:
PubPaperException
-
getUser
Get a particular user information (Admin Only)- Parameters:
userId
- requested user- Returns:
- User - user instance
- Throws:
PubPaperException
-
deleteUsers
Delete a particular user (Admin only)- Parameters:
deletionIds
- integer array of userIds to delete- Returns:
- integer number of rowsAffected for the delete operation
- Throws:
PubPaperException
-
changeAdminStatus
Make a particular user Admin (Admin Only)- Parameters:
userId
- requested useradminStatus
- admin status to be given to the user- Returns:
- User - user instance
- Throws:
PubPaperException
-
changeReviewStatus
Change review status of a particular user (Admin Only)- Parameters:
userId
- requested userreviewStatus
- review status to be given to the user- Returns:
- User - user instance
- Throws:
PubPaperException
-
logout
public boolean logout()
-