Class InMemoryUser

  • All Implemented Interfaces:
    Loggable, NotificationRulesHolder, AuthorityHolder, RolesHolder, UserEx, UserRolesInit, PropertyHolder, SPropertyHolder, SUser, User

    public class InMemoryUser
    extends Object
    implements UserEx
    Original GuestUser or RootUser throws exception on attempt to change its profile (because there is no such thing as profile for guest user). However in the web interface you often need to show information based on current user settings. That is why this object is used in web interfaces instead of original guest user. The settings of this object are not persisted, they disappear once the user logs out. Also this wrapper is used in read only mode.
    • Method Detail

      • setProperties

        public boolean setProperties​(@NotNull
                                     Map<? extends PropertyKey,​String> properties)
        Description copied from interface: SPropertyHolder
        Updates the specified properties. Only those properties will be updated which keys are specified in the properties map. All other properties will be left intact.
        Specified by:
        setProperties in interface SPropertyHolder
        Parameters:
        properties - properties
        Returns:
        true if at least one property was changed, false otherwise
      • setProperty

        public boolean setProperty​(@NotNull
                                   PropertyKey propertyKey,
                                   String value)
        Description copied from interface: SPropertyHolder
        Sets a property with specified key and value.
        Specified by:
        setProperty in interface SPropertyHolder
        Parameters:
        propertyKey - property key
        value - value of the property
        Returns:
        true if the property value was actually changed, false otherwise
      • deleteProperty

        public boolean deleteProperty​(@NotNull
                                      PropertyKey propertyKey)
        Description copied from interface: SPropertyHolder
        Deletes a property with specified key.
        Specified by:
        deleteProperty in interface SPropertyHolder
        Parameters:
        propertyKey - property key
        Returns:
        true if the property was actually deleted, false otherwise
      • setUserProperties

        public void setUserProperties​(@NotNull
                                      Map<? extends PropertyKey,​String> properties)
                               throws UserNotFoundException
        Description copied from interface: SUser
        Updates properties of the user specified by user id. Only those properties will be updated which keys are specified in the properties map. All other properties will be left intact.
        Specified by:
        setUserProperties in interface SUser
        Parameters:
        properties - properties
        Throws:
        UserNotFoundException - if specified user no longer exists
      • getPropertyValue

        public String getPropertyValue​(PropertyKey propertyKey)
        Description copied from interface: PropertyHolder
        Returns value of the property with specified key
        Specified by:
        getPropertyValue in interface PropertyHolder
        Parameters:
        propertyKey - value of the property with specified key
        Returns:
        value of the property with specified key
      • getBooleanProperty

        public boolean getBooleanProperty​(PropertyKey propertyKey)
        Description copied from interface: PropertyHolder
        Returns value of the boolean property
        Specified by:
        getBooleanProperty in interface PropertyHolder
        Parameters:
        propertyKey - property key
        Returns:
        value
      • setBlockState

        public void setBlockState​(String blockType,
                                  String blockState)
        Description copied from interface: SUser
        Stores collapsable block state for this user
        Specified by:
        setBlockState in interface SUser
        Parameters:
        blockType - type of block
        blockState - state
      • getBlockState

        public String getBlockState​(String blockType)
        Description copied from interface: SUser
        Retrieves state of a block stored for this user
        Specified by:
        getBlockState in interface SUser
        Parameters:
        blockType - type of block
        Returns:
        block state or null
      • isPermissionGrantedGlobally

        public boolean isPermissionGrantedGlobally​(@NotNull
                                                   Permission permission)
        Description copied from interface: AuthorityHolder
        Returns true if specified permission granted globally (i.e. not associated with any particular object)
        Specified by:
        isPermissionGrantedGlobally in interface AuthorityHolder
        Parameters:
        permission - permission to check
        Returns:
        true or false
      • getVisibleProjects

        public List<String> getVisibleProjects()
        Description copied from interface: User
        Computes list of visible projects sorted according to the order specified by user.
        Specified by:
        getVisibleProjects in interface User
        Returns:
        list of visible projects ids
      • getAllProjects

        public List<String> getAllProjects()
        Description copied from interface: User
        Returns all projects sorted according to the order specified by user.
        Specified by:
        getAllProjects in interface User
        Returns:
        list of all of the projects ids
      • isPermissionGrantedForProject

        public boolean isPermissionGrantedForProject​(@NotNull
                                                     String projectId,
                                                     @NotNull
                                                     Permission permission)
        Description copied from interface: AuthorityHolder
        Returns true if permission is granted for a project, i.e. the result is true if there is a project related permission granted globally or for specified project
        Specified by:
        isPermissionGrantedForProject in interface AuthorityHolder
        Parameters:
        projectId - project internal id
        permission - permission to check
        Returns:
        see above
      • getVcsModifications

        @NotNull
        public List<SVcsModification> getVcsModifications​(int numberOfActiveDays)
        Description copied from interface: SUser
        Returns the list of changes made by this user filtered according to the caller's permissions.
        Specified by:
        getVcsModifications in interface SUser
        Parameters:
        numberOfActiveDays - number of last active days of changing
        Returns:
        unmodifiable list of user changes
      • isPermissionGrantedForAnyProject

        public boolean isPermissionGrantedForAnyProject​(@NotNull
                                                        Permission permission)
        Description copied from interface: AuthorityHolder
        Returns true if specified permission is granted for at least one project
        Specified by:
        isPermissionGrantedForAnyProject in interface AuthorityHolder
        Parameters:
        permission - permission to check
        Returns:
        see above
      • getAllModifications

        @NotNull
        public List<SVcsModification> getAllModifications()
        Description copied from interface: SUser
        Returns the list of all (personal and non-personal) user modifications sorted by VCS date. Returns only modifications which have at least one related configuration.
        Specified by:
        getAllModifications in interface SUser
        Returns:
        see above
      • getGlobalPermissions

        @NotNull
        public Permissions getGlobalPermissions()
        Description copied from interface: AuthorityHolder
        Returns all granted non-project related permissions and all project-related permissions granted globally
        Specified by:
        getGlobalPermissions in interface AuthorityHolder
        Returns:
        see above
      • getProjectsPermissions

        @NotNull
        public Map<String,​Permissions> getProjectsPermissions()
        Description copied from interface: AuthorityHolder
        Returns map of project-related permissions that were granted for a particular project. Project internal id is used as the key.
        Specified by:
        getProjectsPermissions in interface AuthorityHolder
        Returns:
        map of project permissions
      • getPermissionsGrantedForProject

        @NotNull
        public Permissions getPermissionsGrantedForProject​(@NotNull
                                                           String projectId)
        Description copied from interface: AuthorityHolder
        Returns all permissions granted for particular project. These include permissions granted specifically for the specified project and granted global project-related permissions (i.e. permissions supporting project association Permission.isProjectAssociationSupported()).
        Specified by:
        getPermissionsGrantedForProject in interface AuthorityHolder
        Parameters:
        projectId - project internal id
        Returns:
        all granted permissions for particular project
      • getPermissionsGrantedForAllProjects

        @NotNull
        public Permissions getPermissionsGrantedForAllProjects​(@NotNull
                                                               Collection<String> projectIds)
        Description copied from interface: AuthorityHolder
        Returns all permissions granted for all projects from the collection. These include permissions granted specifically for the specified projects and granted global project-related permissions (i.e. permissions supporting project association Permission.isProjectAssociationSupported()).
        Specified by:
        getPermissionsGrantedForAllProjects in interface AuthorityHolder
        Parameters:
        projectIds - collection of project internal ids
        Returns:
        all granted permissions for all projects
      • getPermissionsGrantedForAnyOfProjects

        @NotNull
        public Permissions getPermissionsGrantedForAnyOfProjects​(@NotNull
                                                                 Collection<String> projectIds)
        Description copied from interface: AuthorityHolder
        Returns union of permissions granted for projects from the collection. These include permissions granted specifically for the specified projects and granted global project-related permissions (i.e. permissions supporting project association Permission.isProjectAssociationSupported()).
        Specified by:
        getPermissionsGrantedForAnyOfProjects in interface AuthorityHolder
        Parameters:
        projectIds - collection of project internal ids
        Returns:
        all granted permissions for all projects
      • getAssociatedUser

        @Nullable
        public User getAssociatedUser()
        Description copied from interface: AuthorityHolder
        Returns the user object associated with the principal.
        Specified by:
        getAssociatedUser in interface AuthorityHolder
        Returns:
        may be null if the authority holder is not a user.
      • hasAllPermissionsOf

        public boolean hasAllPermissionsOf​(@NotNull
                                           AuthorityHolder authorityHolder)
        Description copied from interface: AuthorityHolder
        Returns true if this authority holder has all permissions of another authority holder.
        Specified by:
        hasAllPermissionsOf in interface AuthorityHolder
        Returns:
        see above
      • getRolesWithScope

        @NotNull
        public Collection<Role> getRolesWithScope​(@NotNull
                                                  RoleScope scope)
        Description copied from interface: RolesHolder
        Returns all roles with specified scope.
        Specified by:
        getRolesWithScope in interface RolesHolder
        Parameters:
        scope - roles scope
        Returns:
        all roles with specified scope.
      • hasPassword

        public boolean hasPassword()
        Description copied from interface: UserEx
        Returns true if user has password, false otherwise (e.g. if it was created by NT domain or LDAP login module)
        Specified by:
        hasPassword in interface UserEx
        Returns:
      • isPseudoUser

        public boolean isPseudoUser()
        Specified by:
        isPseudoUser in interface UserEx
      • setEmailIsVerified

        public boolean setEmailIsVerified​(@NotNull
                                          String email)
        Description copied from interface: UserEx
        Mark user`s email as verified if it's equal to email passed in parameter.
        Specified by:
        setEmailIsVerified in interface UserEx
        Returns:
        true if verified email was set, false otherwise
      • getVerifiedEmail

        @Nullable
        public String getVerifiedEmail()
        Description copied from interface: UserEx
        Returns null if user doesn't have email specified or his email is not verified.
        Specified by:
        getVerifiedEmail in interface UserEx
      • setProjectsOrder

        public void setProjectsOrder​(@NotNull
                                     List<String> projectsOrder)
                              throws UserNotFoundException
        Description copied from interface: SUser
        Sets order of the projects.
        Specified by:
        setProjectsOrder in interface SUser
        Parameters:
        projectsOrder - identificators of all projects in the order specified by user
        Throws:
        UserNotFoundException - if specified user no longer exists
      • resetRoles

        public void resetRoles()
        Description copied from interface: UserRolesInit
        Causes roles reloading from the database.
        Specified by:
        resetRoles in interface UserRolesInit
      • hideProject

        public void hideProject​(@NotNull
                                String projectId)
                         throws UserNotFoundException
        Description copied from interface: SUser
        Marks a project with specified id as invisible
        Specified by:
        hideProject in interface SUser
        Parameters:
        projectId - id of the project
        Throws:
        UserNotFoundException - if this user does not exist anymore
      • removeRole

        public void removeRole​(@NotNull
                               Role role)
        Description copied from interface: RolesHolder
        Removes specified role. If the role is associated with several scopes all of these roles will be removed.
        Specified by:
        removeRole in interface RolesHolder
        Parameters:
        role - role to remove
      • isSystemAdministratorRoleGranted

        public boolean isSystemAdministratorRoleGranted()
        Description copied from interface: RolesHolder
        Returns true if this roles holder contains system administrator role granted directly or inherited via parent holders. Same as:
        isSystemAdministratorRoleGrantedDirectly() || isSystemAdministratorRoleInherited()
        Specified by:
        isSystemAdministratorRoleGranted in interface RolesHolder
        Returns:
        see above.
      • isSystemAdministratorRoleGrantedDirectly

        public boolean isSystemAdministratorRoleGrantedDirectly()
        Description copied from interface: RolesHolder
        Returns true if this roles holder contains system administrator role granted directly.
        Specified by:
        isSystemAdministratorRoleGrantedDirectly in interface RolesHolder
        Returns:
        see above.
      • applyOrder

        public void applyOrder​(@NotNull
                               String notifierType,
                               @NotNull
                               long[] ruleIds)
        Description copied from interface: NotificationRulesHolder
        Sorts the notification rules in the specified order.
        Specified by:
        applyOrder in interface NotificationRulesHolder
        Parameters:
        notifierType - type of the notifier
        ruleIds - ids of the rules in the required order
      • isSystemAdministratorRoleInherited

        public boolean isSystemAdministratorRoleInherited()
        Description copied from interface: RolesHolder
        Returns true if one of the parents (transitively) of this roles holder contains system administrator role.
        Specified by:
        isSystemAdministratorRoleInherited in interface RolesHolder
        Returns:
        see above
      • getOrderedBuildTypes

        @NotNull
        public List<SBuildType> getOrderedBuildTypes​(@Nullable
                                                     SProject project)
        Description copied from interface: SUser
        Returns the list of build configurations (in a project, or globally) sorted according to user settings. The configurations invisible for the user are omitted.
        Specified by:
        getOrderedBuildTypes in interface SUser
        Parameters:
        project - the project (can be null)
        Returns:
        the list of build configurations
      • setBuildTypesOrder

        public void setBuildTypesOrder​(@NotNull
                                       SProject project,
                                       @NotNull
                                       List<SBuildType> visible,
                                       @NotNull
                                       List<SBuildType> invisible)
        Description copied from interface: SUser
        Sets visible and invisible build types for the given project in the specified order.
        Specified by:
        setBuildTypesOrder in interface SUser
        Parameters:
        project - the project
        visible - the list of visible build types
        invisible - the list of invisible build types
      • getFilteredVisibleBuildTypes

        @NotNull
        public SortedMap<SProject,​List<SBuildType>> getFilteredVisibleBuildTypes​(@Nullable
                                                                                       BuildTypeFilter filter)
        Description copied from interface: UserEx
        Returns sorted map of build configurations per project. The build configurations are sorted according to user settings.
        Specified by:
        getFilteredVisibleBuildTypes in interface UserEx
        Parameters:
        filter - filter of build configurations, can be null
        Returns:
        sorted map of build types per project
      • resetBuildTypesOrder

        public void resetBuildTypesOrder​(@NotNull
                                         SProject project)
        Description copied from interface: UserEx
        Resets the build types order settings to defaults.
        Specified by:
        resetBuildTypesOrder in interface UserEx
        Parameters:
        project - the project
      • updatePermissions

        public void updatePermissions()
        Description copied from interface: UserEx
        Forces this user to recompute its permissions.
        Specified by:
        updatePermissions in interface UserEx
      • isHasHiddenProjects

        public boolean isHasHiddenProjects()
        Description copied from interface: UserEx
        Returns whether the user has any hidden (i.e. configured to be not-visible) projects.
        Specified by:
        isHasHiddenProjects in interface UserEx
        Returns:
        true if the user has any hidden projects
      • isConfiguredVisibleProjects

        public boolean isConfiguredVisibleProjects()
        Description copied from interface: UserEx
        Returns whether the user has configured visible projects.
        Specified by:
        isConfiguredVisibleProjects in interface UserEx
        Returns:
        true if the user has configured visible projects
      • getUserGroups

        @NotNull
        public List<UserGroup> getUserGroups()
        Description copied from interface: SUser
        Returns the list of groups which this user belongs to. Only groups which contain this user directly are considered. If you need all user groups use SUser.getAllUserGroups().

        No specific order of the groups is guaranteed.

        Specified by:
        getUserGroups in interface SUser
        Returns:
        list of groups containing this user
        See Also:
        SUser.getAllUserGroups()
      • getAllUserGroups

        @NotNull
        public List<UserGroup> getAllUserGroups()
        Description copied from interface: SUser
        Returns the list of all user groups that include this user, directly or through intermediate subgroups.

        No specific order of the groups is guaranteed.

        Specified by:
        getAllUserGroups in interface SUser
        Returns:
        list of all groups containing this user
        See Also:
        SUser.getUserGroups()
      • getVcsUsernameProperties

        @NotNull
        public List<VcsUsernamePropertyKey> getVcsUsernameProperties()
        Description copied from interface: SUser
        Returns list of VCS username properties associated with this user. VCS username property defines username of this user in a concrete VCS root or VCS repository type (Subversion, Perforce, etc).
        Specified by:
        getVcsUsernameProperties in interface SUser
        Returns:
        list of VCS usernames
      • getId

        public long getId()
        Description copied from interface: User
        Returns user id
        Specified by:
        getId in interface User
        Returns:
        user id
      • getRealm

        public String getRealm()
        Description copied from interface: User
        Returns realm of the user.
        Specified by:
        getRealm in interface User
        Returns:
        realm of the user
      • getUsername

        public String getUsername()
        Description copied from interface: User
        Returns username of this user
        Specified by:
        getUsername in interface User
        Returns:
        username
      • getName

        public String getName()
        Description copied from interface: User
        Returns full name of this user
        Specified by:
        getName in interface User
        Returns:
        user full name
      • getEmail

        public String getEmail()
        Description copied from interface: User
        Returns e-mail of this user
        Specified by:
        getEmail in interface User
        Returns:
        email address
      • getDescriptiveName

        public String getDescriptiveName()
        Description copied from interface: User
        Returns full name of the user if it is not empty, otherwise returns username.
        Specified by:
        getDescriptiveName in interface User
        Returns:
        full name or username if full name is empty
      • getExtendedName

        public String getExtendedName()
        Specified by:
        getExtendedName in interface User
        Returns:
        user full name and username in the form: <full name> (<username>)
      • getLastLoginTimestamp

        public Date getLastLoginTimestamp()
        Description copied from interface: User
        Returns this user last login timestamp
        Specified by:
        getLastLoginTimestamp in interface User
        Returns:
        last login timestamp
      • isHighlightRelatedDataInUI

        public boolean isHighlightRelatedDataInUI()
        Description copied from interface: SUser
        Returns true if highlighting of user changes, investigations, and other related data in web UI is enabled. The value is controlled by the StandardProperties.HIGHLIGHT_MY_CHANGES property.
        Specified by:
        isHighlightRelatedDataInUI in interface SUser
        Returns:
        true if highlighting of user changes, investigations, and other related data in web UI is enabled.
      • isGuest

        public boolean isGuest()
        Description copied from interface: SUser
        Returns true if the user is guest
        Specified by:
        isGuest in interface SUser
      • getBuildTypesOrder

        @NotNull
        public Collection<SBuildType> getBuildTypesOrder​(@NotNull
                                                         SProject project)
        Specified by:
        getBuildTypesOrder in interface SUser
        Parameters:
        project - the project
        Returns:
        List of build configurations in configured order. Empty list will be returned in case user didn't configure any order.
      • describe

        @NotNull
        public String describe​(boolean verbose)
        Specified by:
        describe in interface Loggable
        Parameters:
        verbose - verbosity of object description
        Returns:
        description of this object. If verbose is true, description should have mode details.
      • setCreationInProgress

        public void setCreationInProgress​(boolean inProgress)
        Specified by:
        setCreationInProgress in interface UserEx
      • init

        public void init​(@NotNull
                         String username,
                         String name,
                         String email,
                         Long lastLogin,
                         boolean hasPassword)
        Specified by:
        init in interface UserEx
      • resetBlocks

        public void resetBlocks()
        Description copied from interface: UserEx
        Reset cached blocks
        Specified by:
        resetBlocks in interface UserEx
      • resetCachedProperties

        public void resetCachedProperties()
        Description copied from interface: UserEx
        Reset cached blocks
        Specified by:
        resetCachedProperties in interface UserEx
      • resetCachedVcsUsernames

        public void resetCachedVcsUsernames()
        Description copied from interface: UserEx
        Reset cached blocks
        Specified by:
        resetCachedVcsUsernames in interface UserEx
      • setAttribute

        public void setAttribute​(@NotNull
                                 String attributeKey,
                                 @NotNull
                                 String attributeValue)
        Description copied from interface: UserEx
        Set user attribute
        Specified by:
        setAttribute in interface UserEx
      • getAttribute

        @Nullable
        public String getAttribute​(@NotNull
                                   String attributeKey)
        Description copied from interface: UserEx
        Get user attribute
        Specified by:
        getAttribute in interface UserEx
        Returns:
        user attribute or null if there is no attribute with such key
      • getAttributes

        @NotNull
        public Map<String,​String> getAttributes()
        Description copied from interface: UserEx
        Get all user attributes
        Specified by:
        getAttributes in interface UserEx
        Returns:
        user attributes or an empty map
      • deleteAttribute

        public void deleteAttribute​(@NotNull
                                    String attributeKey)
        Description copied from interface: UserEx
        Delete user attribute
        Specified by:
        deleteAttribute in interface UserEx
      • resetCachedAttributes

        public void resetCachedAttributes()
        Description copied from interface: UserEx
        Reset cached user attributes
        Specified by:
        resetCachedAttributes in interface UserEx
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object