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.InitializingBeanExceptionprotected UserData fromDBObject(com.mongodb.DBObject userDataObj)
protected List<UserData> fromDBCursor(com.mongodb.DBCursor cursor)
public void createNewUser(UserData data)
createNewUser in interface UserDataServicepublic void setUserPassword(String username, String password)
setUserPassword in interface UserDataServicepublic void setUserCreationState(String username, DataCreationState creationState)
setUserCreationState in interface UserDataServicepublic long countUsers(String domain, DataCreationState creationState)
countUsers in interface UserDataServicedomain - the domain to search or null for all domainscreationState - optional creation state to filter the count or null for allpublic long deleteUsers(DataCreationState creationState)
UserDataServicedeleteUsers in interface UserDataServicecreationState - the user creation state to target or null to delete all userspublic UserData findUserByUsername(String username)
findUserByUsername in interface UserDataServiceUserData found otherwise null
public UserData findUserByEmail(String email)
UserDataServicefindUserByEmail in interface UserDataServiceUserData found otherwise null.public List<UserData> getUsersByCreationState(DataCreationState creationState, int startIndex, int count)
UserDataServicegetUsersByCreationState in interface UserDataServicecreationState - the current creation statestartIndex - index to start getting users fromcount - number of users to fetchpublic UserData getRandomUser()
UserDataServicegetRandomUser in interface UserDataServicepublic List<UserData> getUsersInDomain(String domain, int startIndex, int count)
UserDataServicegetUsersInDomain in interface UserDataServicedomain - the user domainstartIndex - the start index for pagingcount - the number of users to retrieveUserDataService.DEFAULT_DOMAINpublic Iterator<String> getDomainsIterator()
UserDataServicegetDomainsIterator in interface UserDataServiceUserDataService.DEFAULT_DOMAINpublic UserData getRandomUserFromDomain(String domain)
UserDataServicegetRandomUserFromDomain in interface UserDataServicedomain - the user domainUserDataService.DEFAULT_DOMAINpublic UserData getRandomUserFromDomains(List<String> domains)
UserDataServicegetRandomUserFromDomains in interface UserDataServiceUserDataService.DEFAULT_DOMAINpublic void addUserGroups(String username, List<String> groups)
UserDataServiceaddUserGroups in interface UserDataServiceusername - the usernamegroups - new groups for the userpublic void removeUserGroups(String username, List<String> groups)
UserDataServiceremoveUserGroups in interface UserDataServiceusername - the usernamegroups - groups to which the user no longer belongsCopyright © 2005–2018 Alfresco Software. All rights reserved.