Interface CurrentUserService

  • All Known Implementing Classes:
    CurrentUserServiceImpl

    public interface CurrentUserService
    Service methods for performing operations on the currently logged-in user.
    Author:
    bdferris
    • 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
      • isCurrentUserReporting

        boolean isCurrentUserReporting()
        See StandardAuthoritiesService for definition of reporting
        Returns:
        true if the current user is a reporting
      • 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 -
      • 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
      • 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
      • resetCurrentUser

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