Package org.onebusaway.users.services
Interface CurrentUserService
-
- All Known Implementing Classes:
CurrentUserServiceImpl
public interface CurrentUserServiceService methods for performing operations on the currently logged-in user.- Author:
- bdferris
-
-
Field Summary
Fields Modifier and Type Field Description static StringMODE_ADD_ACCOUNTstatic StringMODE_LOGINstatic StringMODE_REGISTRATION
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intaddStopBookmark(String name, List<String> stopIds, RouteFilter filter)Add a stop bookmark with the specified name, stop ids, and route filter.voidclearDefaultLocation()Clear the default search location for the current uservoidclearPhoneNumberRegistration()Clear any pending phone number registration for the current user.booleancompletePhoneNumberRegistration(String registrationCode)Registers the specified phone number with the user by attaching a new UserIndex to the user with the phone number, or merging an existing user account with an existing UserIndex.voiddeleteCurrentUser()Delete the current user.voiddeleteStopBookmarks(int id)Delete the stop bookmark with the specified id.voidenableAdminRole()Enable admin role for the current user if there are no other admins in the system already.UserBeangetAnonymousUser()UserBeangetCurrentUser()UserBeangetCurrentUser(boolean createUserIfAppropriate)UserIndexgetCurrentUserAsUserIndex()IndexedUserDetailsgetCurrentUserDetails()IndexedUserDetailshandleAddAccount(String type, String id, String credentials, boolean isAnonymous)Handle the addition of a user index with the specified index type+id+credentials to the currently logged in user.IndexedUserDetailshandleLogin(String type, String id, String credentials, boolean isAnonymous, boolean registerIfNewUser)Handle login action for a user with the specified user index type+id+credentials.IndexedUserDetailshandleRegistration(String type, String id, String credentials, boolean isAnonymous)Handle registration/user-creation action for a user with the specified user index type+id+credentials.IndexedUserDetailshandleUserAction(String type, String id, String credentials, boolean isAnonymous, String mode)A generic method that dispatches based on the "mode" parameter.booleanhasPhoneNumberRegistration()booleanisCurrentUserAdmin()SeeStandardAuthoritiesServicefor definition of adminbooleanisCurrentUserAnonymous()SeeStandardAuthoritiesServicefor definition of anonymousbooleanisCurrentUserReporting()SeeStandardAuthoritiesServicefor definition of reportingvoidmarkServiceAlertAsRead(String situationId, long time, boolean isRead)Mark the specified service alert as read or unread at the specified time for the current user.StringregisterPhoneNumber(String phoneNumber)voidremoveUserIndex(UserIndexKey key)Remove theUserIndexwith the specified key from the user.voidresetCurrentUser()Reset the properties to default values for the current user.voidsetDefaultLocation(String locationName, double lat, double lon)Set the default search location for the current uservoidsetLastSelectedStopIds(List<String> stopIds)Set the last selected stop ids for the specified uservoidsetRememberUserPreferencesEnabled(boolean rememberUserPreferencesEnabled)voidupdateStopBookmark(int id, String name, List<String> stopIds, RouteFilter routeFilter)Updated a stop bookmark with the specified id with the specified name, stop ids, and route filter.
-
-
-
Field Detail
-
MODE_LOGIN
static final String MODE_LOGIN
- See Also:
- Constant Field Values
-
MODE_REGISTRATION
static final String MODE_REGISTRATION
- See Also:
- Constant Field Values
-
MODE_ADD_ACCOUNT
static final String MODE_ADD_ACCOUNT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCurrentUserDetails
IndexedUserDetails getCurrentUserDetails()
- Returns:
- the current user's details, or null if no user is currently logged in
-
getCurrentUser
UserBean getCurrentUser()
- Returns:
- the current user, or null if no user is currently logged in
-
getCurrentUser
UserBean getCurrentUser(boolean createUserIfAppropriate)
- Returns:
- the current user, creating the user as appropriate or returning null if no user is logged in or could not be created
-
getCurrentUserAsUserIndex
UserIndex getCurrentUserAsUserIndex()
- Returns:
- the current user, or null if no user is logged in
-
getAnonymousUser
UserBean getAnonymousUser()
- Returns:
- an anonymous, temporary user account that can be used as a placholder if no user is logged in. Never returns null.
-
isCurrentUserAnonymous
boolean isCurrentUserAnonymous()
SeeStandardAuthoritiesServicefor definition of anonymous- Returns:
- true if the current user is anonymous or if there is no current user
-
isCurrentUserAdmin
boolean isCurrentUserAdmin()
SeeStandardAuthoritiesServicefor definition of admin- Returns:
- true if the current user is an admin
-
isCurrentUserReporting
boolean isCurrentUserReporting()
SeeStandardAuthoritiesServicefor definition of reporting- Returns:
- true if the current user is a reporting
-
handleUserAction
IndexedUserDetails handleUserAction(String type, String id, String credentials, boolean isAnonymous, String mode)
A generic method that dispatches based on the "mode" parameter. If mode isMODE_LOGIN, then we pass off tohandleLogin(String, String, String, boolean, boolean)with registerIfNewUser set to true. If mode isMODE_REGISTRATION, then we pass off tohandleRegistration(String, String, String, boolean). Finally, if mode isMODE_ADD_ACCOUNT, we pass off tohandleAddAccount(String, String, String, boolean).- Parameters:
type- theUserIndexKeytypeid- theUserIndexKeyidcredentials-UserIndexcredentialsisAnonymous- seeStandardAuthoritiesServicefor definition of anonymousmode- one ofMODE_LOGIN,MODE_REGISTRATION, orMODE_ADD_ACCOUNT- Returns:
- the details of the logged in user on success, otherwise null
-
handleLogin
IndexedUserDetails handleLogin(String type, String id, String credentials, boolean isAnonymous, boolean registerIfNewUser)
Handle login action for a user with the specified user index type+id+credentials. Supports creating a new user with the specified user index if the registerIfNewUser flag is true. If an existing anonymous user account is already logged in and a new user is created, the existing user account will be migrated to the new user account.- Parameters:
type- theUserIndexKeytypeid- theUserIndexKeyidcredentials-UserIndexcredentialsisAnonymous- seeStandardAuthoritiesServicefor definition of anonymousregisterIfNewUser- if true, automatically register a new user if one does not exist already- Returns:
- the details of the logged in user on success, otherwise null
-
handleRegistration
IndexedUserDetails handleRegistration(String type, String id, String credentials, boolean isAnonymous)
Handle registration/user-creation action for a user with the specified user index type+id+credentials. If a user already existed with the specified user index already exists, it will be used. If an existing anonymous user account is already logged in, the existing user account will be migrated to the new user account.- Parameters:
type- theUserIndexKeytypeid- theUserIndexKeyidcredentials-UserIndexcredentialsisAnonymous- seeStandardAuthoritiesServicefor definition of anonymous- Returns:
- the details of the logged in user on success, otherwise null
-
handleAddAccount
IndexedUserDetails handleAddAccount(String type, String id, String credentials, boolean isAnonymous)
Handle the addition of a user index with the specified index type+id+credentials to the currently logged in user. If there is no currently logged in user, a new user will be created with the specified user index.- Parameters:
type- theUserIndexKeytypeid- theUserIndexKeyidcredentials-UserIndexcredentialsisAnonymous- seeStandardAuthoritiesServicefor definition of anonymous- Returns:
- the details of the logged in user on success, otherwise null
-
setRememberUserPreferencesEnabled
void setRememberUserPreferencesEnabled(boolean rememberUserPreferencesEnabled)
- Parameters:
rememberUserPreferencesEnabled- true if preferences should be remembered for the current user
-
setDefaultLocation
void setDefaultLocation(String locationName, double lat, double lon)
Set the default search location for the current user- Parameters:
locationName-lat-lon-
-
clearDefaultLocation
void clearDefaultLocation()
Clear the default search location for the current user
-
setLastSelectedStopIds
void setLastSelectedStopIds(List<String> stopIds)
Set the last selected stop ids for the specified user- Parameters:
stopIds-
-
addStopBookmark
int addStopBookmark(String name, List<String> stopIds, RouteFilter filter)
Add a stop bookmark with the specified name, stop ids, and route filter. SeeUserBean.getBookmarks().- Parameters:
name-stopIds-filter-- Returns:
- the newly created bookmark id
-
updateStopBookmark
void updateStopBookmark(int id, String name, List<String> stopIds, RouteFilter routeFilter)Updated a stop bookmark with the specified id with the specified name, stop ids, and route filter. SeeUserBean.getBookmarks().- Parameters:
id-name-stopIds-routeFilter-
-
deleteStopBookmarks
void deleteStopBookmarks(int id)
Delete the stop bookmark with the specified id. SeeUserBean.getBookmarks().- Parameters:
id-
-
registerPhoneNumber
String registerPhoneNumber(String phoneNumber)
- Parameters:
phoneNumber- the phone number to register to the current user- Returns:
- the registration code that must be used validate the phoneNumber in
a subsequent call to
completePhoneNumberRegistration(String).
-
hasPhoneNumberRegistration
boolean hasPhoneNumberRegistration()
- Returns:
- if the current user has a pending phone number registration outstanding
-
completePhoneNumberRegistration
boolean completePhoneNumberRegistration(String registrationCode)
Registers the specified phone number with the user by attaching a new UserIndex to the user with the phone number, or merging an existing user account with an existing UserIndex. SeeUserService.completePhoneNumberRegistration(UserIndex, String)- Parameters:
registrationCode-- Returns:
- true if the registration was successful, otherwise false
-
clearPhoneNumberRegistration
void clearPhoneNumberRegistration()
Clear any pending phone number registration for the current user. SeeUserService.clearPhoneNumberRegistration(UserIndexKey)
-
markServiceAlertAsRead
void markServiceAlertAsRead(String situationId, long time, boolean isRead)
Mark the specified service alert as read or unread at the specified time for the current user.- Parameters:
situationId- the service alert situation idtime- the time the service alert was read or marked unreadisRead- whether the service alert should be marked read or unread
-
removeUserIndex
void removeUserIndex(UserIndexKey key)
Remove theUserIndexwith the specified key from the user. SeeUserService.removeUserIndexForUser(User, UserIndexKey)- Parameters:
key-
-
deleteCurrentUser
void deleteCurrentUser()
Delete the current user. SeeUserService.deleteUser(User)
-
resetCurrentUser
void resetCurrentUser()
Reset the properties to default values for the current user. SeeUserService.resetUser(User).
-
enableAdminRole
void enableAdminRole()
Enable admin role for the current user if there are no other admins in the system already. SeeUserService.enableAdminRoleForUser(User, boolean).
-
-