org.onebusaway.users.services
Interface UserService

All Known Implementing Classes:
UserServiceImpl

public interface UserService

Service methods for performing operations on user accounts.

Author:
bdferris
See Also:
UserIndex, User, UserBean

Method Summary
 UserIndex addUserIndexToUser(User user, UserIndexKey key, String credentials)
          Add a UserIndex with the specified id and credentials to an existing user, returning the new index.
 void clearPhoneNumberRegistration(UserIndexKey userIndexKey)
          Reset a previous call to registerPhoneNumber(User, String) for the specified user
 UserIndex completePhoneNumberRegistration(UserIndex userIndex, String registrationCode)
          Complete phone number registration.
 void deleteStaleUsers()
          Deletes stale users from the system.
 void deleteUser(User user)
          Delete the specified user.
 void disableAdminRoleForUser(User user, boolean onlyIfOtherAdmins)
          Remove the admin role for a User.
 void enableAdminRoleForUser(User user, boolean onlyIfNoOtherAdmins)
          Enable the admin role for a User.
 List<Integer> getAllUserIds()
           
 List<Integer> getAllUserIdsInRange(int offset, int limit)
           
 UserBean getAnonymousUser()
           
 Long getMinApiRequestIntervalForKey(String key, boolean forceRefresh)
           
 int getNumberOfAdmins()
           
 int getNumberOfUsers()
           
 UserIndex getOrCreateUserForIndexKey(UserIndexKey key, String credentials, boolean isAnonymous)
           
 UserIndex getOrCreateUserForUsernameAndPassword(String username, String password)
           
 UserBean getUserAsBean(User user)
           
 User getUserForId(int userId)
           
 UserIndex getUserIndexForId(UserIndexKey key)
           
 List<String> getUserIndexKeyValuesForKeyType(String keyType)
           
 UserPropertiesMigrationStatus getUserPropertiesMigrationStatus()
          See UserPropertiesMigration
 boolean hasPhoneNumberRegistration(UserIndexKey userIndexKey)
           
 boolean isAdministrator(User user)
          Is the specified user an administrator? See the discussion in StandardAuthoritiesService
 boolean isAnonymous(User user)
          Is the specified user anonymous? See the discussion in StandardAuthoritiesService
 void mergeUsers(User sourceUser, User targetUser)
          Given two user accounts, merge the two users into one.
 String registerPhoneNumber(User user, String phoneNumber)
          Begin phone number registration for the specified user.
 void removeUserIndexForUser(User user, UserIndexKey key)
          Remove the UserIndex with the specified id from the user.
 void resetUser(User user)
          Reset all properties for the specified user to default values.
 void setCredentialsForUserIndex(UserIndex userIndex, String credentials)
          Update the credentials for the specified user index
 void setPasswordForUsernameUserIndex(UserIndex userIndex, String password)
          Update the password for the UserIndexTypes.USERNAME user index
 void startUserPropertiesMigration()
          Start the user property migration task - see UserPropertiesMigration
 

Method Detail

getNumberOfUsers

int getNumberOfUsers()
Returns:
the number of users in the system

getAllUserIds

List<Integer> getAllUserIds()
Returns:
the list of all user ids

getAllUserIdsInRange

List<Integer> getAllUserIdsInRange(int offset,
                                   int limit)
Parameters:
offset - index offset into the full user id list
limit - length of subset of the user id list to return
Returns:
a subset of the list of all user ids in the system

getUserForId

User getUserForId(int userId)
Parameters:
userId - see User.getId()
Returns:
the user with the specifed id, or null if not found

getNumberOfAdmins

int getNumberOfAdmins()
Returns:
the number of users with the admin role set

getUserIndexKeyValuesForKeyType

List<String> getUserIndexKeyValuesForKeyType(String keyType)
Returns:
the set of UserIndexKey values having the specified UserIndexKey type

getUserIndexForId

UserIndex getUserIndexForId(UserIndexKey key)
Parameters:
key - see UserIndex.getId()
Returns:
the user index with the specified key, or null if not found

getOrCreateUserForIndexKey

UserIndex getOrCreateUserForIndexKey(UserIndexKey key,
                                     String credentials,
                                     boolean isAnonymous)
Parameters:
key - see UserIndex.getId()
credentials - UserIndex.getCredentials()
isAnonymous - is a newly created user anonymous - User.getRoles()
Returns:
an existing user index with the specified key if it already exists, or a newly created user index (and underlying user) with the specified properties

getOrCreateUserForUsernameAndPassword

UserIndex getOrCreateUserForUsernameAndPassword(String username,
                                                String password)
Parameters:
username -
password -
Returns:
an existing user index with the specified username if it already exists, or a newly created user index (and underlying user) with the specified username and password credentials

addUserIndexToUser

UserIndex addUserIndexToUser(User user,
                             UserIndexKey key,
                             String credentials)
Add a UserIndex with the specified id and credentials to an existing user, returning the new index. If an index with the specified id already exists, it is returned instead.

Parameters:
user - the target user
key - see UserIndex.getId()
credentials - see UserIndex.getCredentials()
Returns:
the newly attached user index, or an existing index if already attached

removeUserIndexForUser

void removeUserIndexForUser(User user,
                            UserIndexKey key)
Remove the UserIndex with the specified id from the user.

Parameters:
user -
key - see UserIndex.getId()

setCredentialsForUserIndex

void setCredentialsForUserIndex(UserIndex userIndex,
                                String credentials)
Update the credentials for the specified user index

Parameters:
userIndex -
credentials -

setPasswordForUsernameUserIndex

void setPasswordForUsernameUserIndex(UserIndex userIndex,
                                     String password)
Update the password for the UserIndexTypes.USERNAME user index

Parameters:
userIndex -
password -

getUserAsBean

UserBean getUserAsBean(User user)
Parameters:
user -
Returns:
the specified user as a user bean object

getAnonymousUser

UserBean getAnonymousUser()
Returns:
an anonymous default user object

deleteUser

void deleteUser(User user)
Delete the specified user. Will delete any UserIndex objects pointing to that user as well.

Parameters:
user -

resetUser

void resetUser(User user)
Reset all properties for the specified user to default values.

Parameters:
user -

isAnonymous

boolean isAnonymous(User user)
Is the specified user anonymous? See the discussion in StandardAuthoritiesService

Parameters:
user -
Returns:
true if the user is anonymous, otherwise false

isAdministrator

boolean isAdministrator(User user)
Is the specified user an administrator? See the discussion in StandardAuthoritiesService

Parameters:
user -
Returns:
true if the user is an administrator, otherwise false

enableAdminRoleForUser

void enableAdminRoleForUser(User user,
                            boolean onlyIfNoOtherAdmins)
Enable the admin role for a User. For admin bootstrapping, we have a check that will only allow you to set an admin role if no other admins exist. This would be useful for marking the very first user in a system as admin.

Parameters:
user - the user to mark as an admin
onlyIfNoOtherAdmins - when true, will only add the admin role if no other users are marked as admin

disableAdminRoleForUser

void disableAdminRoleForUser(User user,
                             boolean onlyIfOtherAdmins)
Remove the admin role for a User.

Parameters:
user -
onlyIfOtherAdmins - when true, will only remove the admin role if at least one other user is marked as admin

mergeUsers

void mergeUsers(User sourceUser,
                User targetUser)
Given two user accounts, merge the two users into one. The source user is deleted while the target user is updated. Properties in the target user take presedence over properties in the source user if there is overlap.

Parameters:
sourceUser - this user will be deleted
targetUser - this user will be updated and kept

startUserPropertiesMigration

void startUserPropertiesMigration()
Start the user property migration task - see UserPropertiesMigration


getUserPropertiesMigrationStatus

UserPropertiesMigrationStatus getUserPropertiesMigrationStatus()
See UserPropertiesMigration

Returns:
the status for the user properties migration task

registerPhoneNumber

String registerPhoneNumber(User user,
                           String phoneNumber)
Begin phone number registration for the specified user. Returns a code that the user must specify in a call to completePhoneNumberRegistration(UserIndex, String) to verify that they do in fact own that phone number.

Parameters:
user -
phoneNumber -
Returns:
the code that must be supplied in a subsequent call to completePhoneNumberRegistration(UserIndex, String)

hasPhoneNumberRegistration

boolean hasPhoneNumberRegistration(UserIndexKey userIndexKey)
Parameters:
userIndexKey -
Returns:
true if a phone number registration task is pending for the specified user

completePhoneNumberRegistration

UserIndex completePhoneNumberRegistration(UserIndex userIndex,
                                          String registrationCode)
Complete phone number registration. If the registrationCode matches one returned in a previous call to registerPhoneNumber(User, String), then registration is completed by creating a new UserIndex with type UserIndexTypes.PHONE_NUMBER with the phone number specified in the previous call to register phone number.

Parameters:
userIndex -
registrationCode -
Returns:
the newly created UserIndex object for the phone number user index

clearPhoneNumberRegistration

void clearPhoneNumberRegistration(UserIndexKey userIndexKey)
Reset a previous call to registerPhoneNumber(User, String) for the specified user

Parameters:
userIndexKey -

getMinApiRequestIntervalForKey

Long getMinApiRequestIntervalForKey(String key,
                                    boolean forceRefresh)
Parameters:
key - an API key
forceRefresh - guarantees that supplied value has not been cached
Returns:
the minimum interval between requests in milliseconds for the key, or null for a key with no permission to access the API

deleteStaleUsers

void deleteStaleUsers()
Deletes stale users from the system. Stale users have a last access time of more than a month ago.



Copyright © 2012 OneBusAway. All Rights Reserved.