Class MongoUserDao
- All Implemented Interfaces:
UserDao
UserDao
.
Created by patricktwohig on 3/26/15.-
Constructor Summary
Constructors -
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.findMongoUser
(User user) findMongoUser
(String userId) findMongoUser
(org.bson.types.ObjectId userId) findUserByNameOrEmail
(String userNameOrEmail) Finds a user either by email or name.findUserWithLoginAndPassword
(String userNameOrEmail, String password) Finds aUser
given the login credentials and assword.dev.morphia.Datastore
getMongoUser
(User user) getMongoUser
(String userId) getMongoUser
(org.bson.types.ObjectId mongoUserId) Gets the user with the userId.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> phones) Gets a listing of all users given the offset, count and phone numbervoid
setDatastore
(dev.morphia.Datastore datastore) void
setDozerMapper
(MapperRegistry dozerMapperRegistry) void
setMongoDBUtils
(MongoDBUtils mongoDBUtils) void
setMongoPasswordUtils
(MongoPasswordUtils mongoPasswordUtils) void
setMongoProfileDao
(MongoProfileDao mongoProfileDao) void
setMongoUserUidDao
(MongoUserUidDao mongoUserUidDao) void
setPasswordEncoding
(String passwordEncoding) void
setValidationHelper
(ValidationHelper validationHelper) void
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.void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.getelements.elements.sdk.dao.UserDao
findUser, getUserByNameOrEmail, validateUserPassword
-
Constructor Details
-
MongoUserDao
public MongoUserDao()
-
-
Method Details
-
getUser
Description copied from interface:UserDao
Gets the user with the userId. If the user is not active, then this method will behave as if the user does not exist.- Specified by:
getUser
in interfaceUserDao
- Parameters:
userId
- the user's as determined byUser.getId()
- Returns:
- the active user
-
getMongoUser
-
findMongoUser
-
findMongoUser
-
findMongoUser
-
getMongoUser
-
getMongoUser
-
findUserByNameOrEmail
Description copied from interface:UserDao
Finds a user either by email or name.- Specified by:
findUserByNameOrEmail
in interfaceUserDao
- Parameters:
userNameOrEmail
- the username or email- Returns:
- an
Optional<User>
-
getUsers
Description copied from interface:UserDao
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. -
getUsers
Description copied from interface:UserDao
Gets a listing of all users given the offset, and count. Additionally, the user requested must be active. -
getUsersByPrimaryPhoneNumbers
Description copied from interface:UserDao
Gets a listing of all users given the offset, count and phone number- Specified by:
getUsersByPrimaryPhoneNumbers
in interfaceUserDao
- Parameters:
offset
- the offsetcount
- the countphones
- a phone numberto filter the results- Returns:
- the users in the system
-
createUserStrict
Description copied from interface:UserDao
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.- Specified by:
createUserStrict
in interfaceUserDao
- Parameters:
user
- the user to create- Returns:
- the User as it was created.
-
createUserWithPasswordStrict
Description copied from interface:UserDao
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.- Specified by:
createUserWithPasswordStrict
in interfaceUserDao
- Parameters:
user
- the user to createpassword
- the password to assign the user- Returns:
- the User as it was created.
-
createUserWithPassword
Description copied from interface:UserDao
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.- Specified by:
createUserWithPassword
in interfaceUserDao
- Parameters:
user
- the user to createpassword
- the password for the user to use- Returns:
- the User, as was written to the database
-
createUser
Description copied from interface:UserDao
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
UserDao.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.- Specified by:
createUser
in interfaceUserDao
- Parameters:
user
- the user- Returns:
- the User, as written to the database
-
updateUserStrict
Description copied from interface:UserDao
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.- Specified by:
updateUserStrict
in interfaceUserDao
- Parameters:
user
- the user to update- Returns:
- the user as was written to the database
-
updateUserStrict
Description copied from interface:UserDao
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.- Specified by:
updateUserStrict
in interfaceUserDao
- Parameters:
user
- the user to update- Returns:
- the user as was written to the database
-
updateUser
Description copied from interface:UserDao
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.- Specified by:
updateUser
in interfaceUserDao
- Parameters:
user
- the user to update- Returns:
- the User as written to the database
-
updateUser
Description copied from interface:UserDao
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.- Specified by:
updateUser
in interfaceUserDao
- Parameters:
user
- the user to updatepassword
- the user password- Returns:
- the User, as written to the database
-
updateUser
Description copied from interface:UserDao
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.- Specified by:
updateUser
in interfaceUserDao
- 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
Description copied from interface:UserDao
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
UserDao.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.- Specified by:
createOrUpdateUser
in interfaceUserDao
- Parameters:
user
- the user- Returns:
- the User, as written to the database
-
softDeleteUser
Description copied from interface:UserDao
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.- Specified by:
softDeleteUser
in interfaceUserDao
- Parameters:
userId
- the user's as determined byUser.getId()
-
validate
-
findUserWithLoginAndPassword
Description copied from interface:UserDao
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.- Specified by:
findUserWithLoginAndPassword
in interfaceUserDao
- Parameters:
userNameOrEmail
- the user's name or email addresspassword
- the password- Returns:
- the User, never null
-
getDatastore
public dev.morphia.Datastore getDatastore() -
setDatastore
@Inject public void setDatastore(dev.morphia.Datastore datastore) -
getPasswordEncoding
-
setPasswordEncoding
@Inject public void setPasswordEncoding(@Named("dev.getelements.elements.password.encoding") String passwordEncoding) -
getValidationHelper
-
setValidationHelper
-
getMongoDBUtils
-
setMongoDBUtils
-
getDozerMapper
-
setDozerMapper
-
getMongoPasswordUtils
-
setMongoPasswordUtils
-
getMongoProfileDao
-
setMongoProfileDao
-
getMongoUserUidDao
-
setMongoUserUidDao
-