public class UserDataServiceImpl extends AbstractUserDataService implements org.springframework.beans.factory.InitializingBean
UserData
storage. All UserData
returned from and persisted
with this service will be testrun-specific. The testrun-identifier is set in the constructor.Modifier and Type | Class and Description |
---|---|
static class |
UserDataServiceImpl.Range |
UserDataService.UserCallback
Modifier and Type | Field and Description |
---|---|
protected com.mongodb.DBCollection |
collection
The collection of users, which can be reused by derived extensions.
|
static String |
FIELD_CREATION_STATE |
static String |
FIELD_DOMAIN |
static String |
FIELD_EMAIL |
static String |
FIELD_FIRST_NAME |
static String |
FIELD_GROUPS |
static String |
FIELD_ID |
static String |
FIELD_KEY |
static String |
FIELD_LAST_NAME |
static String |
FIELD_PASSWORD |
static String |
FIELD_RANDOMIZER |
static String |
FIELD_USERNAME |
DEFAULT_DOMAIN
Constructor and Description |
---|
UserDataServiceImpl(com.mongodb.DB db,
String collection) |
Modifier and Type | Method and Description |
---|---|
void |
addUserGroups(String username,
List<String> groups)
Record additional groups that the user belongs to.
|
void |
afterPropertiesSet() |
long |
countUsers(String domain,
DataCreationState creationState) |
void |
createNewUser(UserData data) |
long |
deleteUsers(DataCreationState creationState)
Delete users by create state
|
UserData |
findUserByEmail(String email)
Find a user by email address
|
UserData |
findUserByUsername(String username)
Find a user by username
|
protected List<UserData> |
fromDBCursor(com.mongodb.DBCursor cursor)
Turn a cursor into an array of API-friendly objects
|
protected UserData |
fromDBObject(com.mongodb.DBObject userDataObj)
Helper to convert a Mongo DBObject into the API consumable object
Note that null is handled as a null return.
|
Iterator<String> |
getDomainsIterator()
An iterator over domains in the users collection.
|
UserData |
getRandomUser()
Select a random, pre-created user.
|
UserData |
getRandomUserFromDomain(String domain)
Select a random, pre-created user.
|
UserData |
getRandomUserFromDomains(List<String> domains)
Select a random, pre-created user that is a member of one of the given domains.
|
List<UserData> |
getUsersByCreationState(DataCreationState creationState,
int startIndex,
int count)
Get the users based on user creation state
|
List<UserData> |
getUsersInDomain(String domain,
int startIndex,
int count)
Access created users by their user domain using paging
|
void |
removeUserGroups(String username,
List<String> groups)
Remove some groups from the user's groups list
|
void |
setUserCreationState(String username,
DataCreationState creationState)
Change the 'created' state of the user i.e.
|
void |
setUserPassword(String username,
String password)
Update a user's password
|
public static final String FIELD_RANDOMIZER
public static final String FIELD_USERNAME
public static final String FIELD_PASSWORD
public static final String FIELD_CREATION_STATE
public static final String FIELD_FIRST_NAME
public static final String FIELD_LAST_NAME
public static final String FIELD_EMAIL
public static final String FIELD_DOMAIN
public static final String FIELD_GROUPS
public static final String FIELD_ID
public static final String FIELD_KEY
protected final com.mongodb.DBCollection collection
public UserDataServiceImpl(com.mongodb.DB db, String collection)
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Exception
protected UserData fromDBObject(com.mongodb.DBObject userDataObj)
protected List<UserData> fromDBCursor(com.mongodb.DBCursor cursor)
public void createNewUser(UserData data)
createNewUser
in interface UserDataService
public void setUserPassword(String username, String password)
setUserPassword
in interface UserDataService
public void setUserCreationState(String username, DataCreationState creationState)
setUserCreationState
in interface UserDataService
public long countUsers(String domain, DataCreationState creationState)
countUsers
in interface UserDataService
domain
- the domain to search or null for all domainscreationState
- optional creation state to filter the count or null for allpublic long deleteUsers(DataCreationState creationState)
UserDataService
deleteUsers
in interface UserDataService
creationState
- the user creation state to target or null to delete all userspublic UserData findUserByUsername(String username)
findUserByUsername
in interface UserDataService
UserData
found otherwise null
public UserData findUserByEmail(String email)
UserDataService
findUserByEmail
in interface UserDataService
UserData
found otherwise null.public List<UserData> getUsersByCreationState(DataCreationState creationState, int startIndex, int count)
UserDataService
getUsersByCreationState
in interface UserDataService
creationState
- the current creation statestartIndex
- index to start getting users fromcount
- number of users to fetchpublic UserData getRandomUser()
UserDataService
getRandomUser
in interface UserDataService
public List<UserData> getUsersInDomain(String domain, int startIndex, int count)
UserDataService
getUsersInDomain
in interface UserDataService
domain
- the user domainstartIndex
- the start index for pagingcount
- the number of users to retrieveUserDataService.DEFAULT_DOMAIN
public Iterator<String> getDomainsIterator()
UserDataService
getDomainsIterator
in interface UserDataService
UserDataService.DEFAULT_DOMAIN
public UserData getRandomUserFromDomain(String domain)
UserDataService
getRandomUserFromDomain
in interface UserDataService
domain
- the user domainUserDataService.DEFAULT_DOMAIN
public UserData getRandomUserFromDomains(List<String> domains)
UserDataService
getRandomUserFromDomains
in interface UserDataService
UserDataService.DEFAULT_DOMAIN
public void addUserGroups(String username, List<String> groups)
UserDataService
addUserGroups
in interface UserDataService
username
- the usernamegroups
- new groups for the userpublic void removeUserGroups(String username, List<String> groups)
UserDataService
removeUserGroups
in interface UserDataService
username
- the usernamegroups
- groups to which the user no longer belongsCopyright © 2005–2018 Alfresco Software. All rights reserved.