Interface UserDao
- All Known Implementing Classes:
MongoUserDao
Generally methods with the word "strict" in their prototype mean the operation without regard for the active flag. Other methods may use the active flag to emulate a user that has been deleted from the system.
Created by patricktwohig on 3/26/15.
-
Method Summary
Modifier and TypeMethodDescriptioncreateOrUpdateUser
(User user) Creates a user if one does not exist for the provided info or updates a user if one does exist.createUser
(User user) Creates or activates a user, or if the user is currently inactive this will reinstate access.createUserStrict
(User user) Creates a user with the given User object.createUserWithPassword
(User user, String password) Creates a user and sets the user's password.createUserWithPasswordStrict
(User user, String password) Creates a user with the given User object and password.findUserByNameOrEmail
(String userNameOrEmail) Finds a user either by email or name.findUserWithLoginAndPassword
(String userNameOrEmail, String password) Finds aUser
given the login credentials and assword.Gets the user with the userId.default User
getUserByNameOrEmail
(String userNameOrEmail) Gets the user with the user name or email address.getUsers
(int offset, int count) Gets a listing of all users given the offset, and count.Gets a listing of all users given the offset, and count.getUsersByPrimaryPhoneNumbers
(int offset, int count, List<String> phone) Gets a listing of all users given the offset, count and phone numbervoid
softDeleteUser
(String userId) Deletes a user from the database.updateUser
(User user) Updates the given active user.updateUser
(User user, String password) Updates the given active user.updateUser
(User user, String newPassword, String oldPassword) Updates the given active user.updateUserStrict
(User user) Updates the given user, regardless of active status and then returns the user instance as it was written to the database.updateUserStrict
(User user, String password) Updates the given user, regardless of active status and then returns the user instance as it was written to the database.default User
validateUserPassword
(String userNameOrEmail, String password) Validates the user's password and returns the current User instance.
-
Method Details
-
getUser
Gets the user with the userId. If the user is not active, then this method will behave as if the user does not exist.- Parameters:
userId
- the user's as determined byUser.getId()
- Returns:
- the active user
-
findUser
-
findUserByNameOrEmail
Finds a user either by email or name. -
getUserByNameOrEmail
Gets the user with the user name or email address. If the user is not active, then this method will behave as if the user does not exist.- Parameters:
userNameOrEmail
- the username or email- Returns:
- the active user
-
getUsers
Gets a listing of all users given the offset, and count. Additionally, the user requested must be active. Users not active will be treated as if they do not exist.- Parameters:
offset
- the offsetcount
- the count- Returns:
- the users in the system
-
getUsers
Gets a listing of all users given the offset, and count. Additionally, the user requested must be active.- Parameters:
offset
- the offsetcount
- the countquery
- a query to filter the results- Returns:
- the users in the system
-
getUsersByPrimaryPhoneNumbers
Gets a listing of all users given the offset, count and phone number- Parameters:
offset
- the offsetcount
- the countphone
- a phone numberto filter the results- Returns:
- the users in the system
-
createUserStrict
Creates a user with the given User object. Using "Strict" semantics, if the user exists then this will throw an exception. The resulting user will have a scrambled password.- Parameters:
user
- the user to create- Returns:
- the User as it was created.
-
createUserWithPasswordStrict
Creates a user with the given User object and password. Using "Strict" semantics, if the user exists then this will throw an exception. The resulting user will be assigned the given password.- Parameters:
user
- the user to createpassword
- the password to assign the user- Returns:
- the User as it was created.
-
createUser
Creates or activates a user, or if the user is currently inactive this will reinstate access. This securely scrambles the user's password and therefore the user must change password at a later date.Similar to
createUserStrict(User)
the user will be assigned a scrambled password if the user does not exist (or was previously inactive). This will not touch the user's password if the user both exists and was flagged as active.- Parameters:
user
- the user- Returns:
- the User, as written to the database
-
createUserWithPassword
Creates a user and sets the user's password. If the user exists then this will reinstate the user's account with a new password.- Parameters:
user
- the user to createpassword
- the password for the user to use- Returns:
- the User, as was written to the database
-
updateUserStrict
Updates the given user, regardless of active status and then returns the user instance as it was written to the database.This will only apply to a
This does not change the user's password.User
with aUserUid
containing a schema with an id prepended with dev.getelements. Other schemas will be assumed to external login methods.- Parameters:
user
- the user to update- Returns:
- the user as was written to the database
-
updateUserStrict
Updates the given user, regardless of active status and then returns the user instance as it was written to the database.This will only apply to a
This will update the user's password.User
with aUserUid
containing a schema with an id prepended with dev.getelements. Other schemas will be assumed to external login methods.- Parameters:
user
- the user to update- Returns:
- the user as was written to the database
-
updateUser
Updates the given active user. If the user has been deleted or has been flagged as inactive, then this method will fail.This will only apply to a
This does not change the user's password.User
with aUserUid
containing a schema with an id prepended with dev.getelements. Other schemas will be assumed to external login methods.- Parameters:
user
- the user to update- Returns:
- the User as written to the database
-
updateUser
Updates the given active user. If the user has been deleted or has been flagged as inactive, then this method will fail.This will only apply to a
User
with aUserUid
containing a schema with an id prepended with dev.getelements. Other schemas will be assumed to external login methods.- Parameters:
user
- the user to updatepassword
- the user password- Returns:
- the User, as written to the database
-
updateUser
Updates the given active user. If the user has been deleted or has been flagged as inactive, then this method will fail.This will only apply to a
User
with aUserUid
containing a schema with an id prepended with dev.getelements. Other schemas will be assumed to external login methods.- Parameters:
user
- the user to updatenewPassword
- the user's new passwordoldPassword
- the user's old password- Returns:
- the User, as written to the database
-
createOrUpdateUser
Creates a user if one does not exist for the provided info or updates a user if one does exist.If the user is currently inactive this will reinstate access. This securely scrambles the user's password and therefore the user must change password at a later date.
Similar to
createUserStrict(User)
the user will be assigned a scrambled password if the user does not exist (or was previously inactive). This will not touch the user's password if the user both exists and was flagged as active.- Parameters:
user
- the user- Returns:
- the User, as written to the database
-
softDeleteUser
Deletes a user from the database. In actuality, this isn't a true delete, but rather just flags the user as inactive. LazyValue flagged inactive, a user will not show up in any results for active users.- Parameters:
userId
- the user's as determined byUser.getId()
-
validateUserPassword
Validates the user's password and returns the current User instance. If the password validation fails, then this simply throws an instance ofForbiddenException
- Parameters:
userNameOrEmail
- the user's name or email addresspassword
- the password- Returns:
- the User, never null
-
findUserWithLoginAndPassword
Finds aUser
given the login credentials and assword. If the password validation fails, then this will return an emptyOptional
. If the password validation succeeds, then this returns the user that matched.- Parameters:
userNameOrEmail
- the user's name or email addresspassword
- the password- Returns:
- the User, never null
-