org.onebusaway.users.services
Interface CurrentUserService

All Known Implementing Classes:
CurrentUserServiceImpl

public interface CurrentUserService

Service methods for performing operations on the currently logged-in user.

Author:
bdferris

Field Summary
static String MODE_ADD_ACCOUNT
           
static String MODE_LOGIN
           
static String MODE_REGISTRATION
           
 
Method Summary
 int addStopBookmark(String name, List<String> stopIds, RouteFilter filter)
          Add a stop bookmark with the specified name, stop ids, and route filter.
 void clearDefaultLocation()
          Clear the default search location for the current user
 void clearPhoneNumberRegistration()
          Clear any pending phone number registration for the current user.
 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.
 void deleteCurrentUser()
          Delete the current user.
 void deleteStopBookmarks(int id)
          Delete the stop bookmark with the specified id.
 void enableAdminRole()
          Enable admin role for the current user if there are no other admins in the system already.
 UserBean getAnonymousUser()
           
 UserBean getCurrentUser()
           
 UserBean getCurrentUser(boolean createUserIfAppropriate)
           
 UserIndex getCurrentUserAsUserIndex()
           
 IndexedUserDetails getCurrentUserDetails()
           
 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.
 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.
 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.
 IndexedUserDetails handleUserAction(String type, String id, String credentials, boolean isAnonymous, String mode)
          A generic method that dispatches based on the "mode" parameter.
 boolean hasPhoneNumberRegistration()
          See UserService.hasPhoneNumberRegistration(UserIndexKey)
 boolean isCurrentUserAdmin()
          See StandardAuthoritiesService for definition of admin
 boolean isCurrentUserAnonymous()
          See StandardAuthoritiesService for definition of anonymous
 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.
 String registerPhoneNumber(String phoneNumber)
          See UserService.registerPhoneNumber(User, String)
 void removeUserIndex(UserIndexKey key)
          Remove the UserIndex with the specified key from the user.
 void resetCurrentUser()
          Reset the properties to default values for the current user.
 void setDefaultLocation(String locationName, double lat, double lon)
          Set the default search location for the current user
 void setLastSelectedStopIds(List<String> stopIds)
          Set the last selected stop ids for the specified user
 void setRememberUserPreferencesEnabled(boolean rememberUserPreferencesEnabled)
           
 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.
 

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()
See StandardAuthoritiesService for definition of anonymous

Returns:
true if the current user is anonymous or if there is no current user

isCurrentUserAdmin

boolean isCurrentUserAdmin()
See StandardAuthoritiesService for definition of admin

Returns:
true if the current user is an admin

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 is MODE_LOGIN, then we pass off to handleLogin(String, String, String, boolean, boolean) with registerIfNewUser set to true. If mode is MODE_REGISTRATION, then we pass off to handleRegistration(String, String, String, boolean) . Finally, if mode is MODE_ADD_ACCOUNT, we pass off to handleAddAccount(String, String, String, boolean).

Parameters:
type - the UserIndexKey type
id - the UserIndexKey id
credentials - UserIndex credentials
isAnonymous - see StandardAuthoritiesService for definition of anonymous
mode - one of MODE_LOGIN, MODE_REGISTRATION, or MODE_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 - the UserIndexKey type
id - the UserIndexKey id
credentials - UserIndex credentials
isAnonymous - see StandardAuthoritiesService for definition of anonymous
registerIfNewUser - 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 - the UserIndexKey type
id - the UserIndexKey id
credentials - UserIndex credentials
isAnonymous - see StandardAuthoritiesService for 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 - the UserIndexKey type
id - the UserIndexKey id
credentials - UserIndex credentials
isAnonymous - see StandardAuthoritiesService for 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. See UserBean.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. See UserBean.getBookmarks().

Parameters:
id -
name -
stopIds -
routeFilter -

deleteStopBookmarks

void deleteStopBookmarks(int id)
Delete the stop bookmark with the specified id. See UserBean.getBookmarks().

Parameters:
id -

registerPhoneNumber

String registerPhoneNumber(String phoneNumber)
See UserService.registerPhoneNumber(User, String)

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()
See UserService.hasPhoneNumberRegistration(UserIndexKey)

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. See UserService.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. See UserService.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 id
time - the time the service alert was read or marked unread
isRead - whether the service alert should be marked read or unread

removeUserIndex

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

Parameters:
key -

deleteCurrentUser

void deleteCurrentUser()
Delete the current user. See UserService.deleteUser(User)


resetCurrentUser

void resetCurrentUser()
Reset the properties to default values for the current user. See UserService.resetUser(User).


enableAdminRole

void enableAdminRole()
Enable admin role for the current user if there are no other admins in the system already. See UserService.enableAdminRoleForUser(User, boolean).



Copyright © 2011 OneBusAway. All Rights Reserved.