Package org.silverpeas.core.chat
Class ChatUser
- java.lang.Object
-
- org.silverpeas.core.admin.user.model.UserDetail
-
- org.silverpeas.core.chat.ChatUser
-
- All Implemented Interfaces:
Serializable
,Comparable<User>
,User
public class ChatUser extends UserDetail
A Silverpeas user with an account in a Chat service. The Silverpeas Chat Engine uses the services of an external chat server; so each user in Silverpeas has also an account in the chat server and hence has a unique identifier in that chat service.- Author:
- remipassmoilesel
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.silverpeas.core.admin.user.model.UserDetail
UserDetail.OnCreationDate, UserDetail.OnFirstNameAndLastName
-
-
Field Summary
-
Fields inherited from class org.silverpeas.core.admin.user.model.UserDetail
BLANK_NAME, SYSTEM_USER_ID
-
Fields inherited from interface org.silverpeas.core.admin.user.model.User
DEFAULT_AVATAR_PATH
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object other)
static ChatUser
fromUser(User user)
Creates a newChatUser
from the specified Silverpeas user.UserAccessLevel
getAccessLevel()
Gets the user access level.String
getAvatar()
Gets the avatar URL of the user.static ChatUser
getById(String userId)
Gets a chat user from the specified Silverpeas unique identifier.String
getChatDomain()
Gets the chat domain to which this user belongs.String
getChatId()
Gets the unique identifier of this user in the chat service.String
getChatLogin()
Gets the chat service login of this user.String
getChatPassword()
Gets the chat service password of this user.Date
getCreationDate()
Gets the date of the user creation.static ChatUser
getCurrentRequester()
Gets the user behind the current request to Silverpeas and that have an account in the chat service.String
getDisplayedName()
Default first name and last name concatenation.String
getDomainId()
Gets the user domain id.String
getDurationOfCurrentSession()
Gets the duration of the current user session since its last registered login date.String
getEmailAddress()
Gets the user email.String
getFirstName()
Gets the first name of the user.String
getId()
The unique identifier of the user into Silverpeas.String
getLastName()
Gets the last name of the user.String
getLogin()
Gets the user login.Date
getSaveDate()
Gets the date of the last user save.String
getSmallAvatar()
Gets the URL of a smaller version of avatar than the one provided byUser.getAvatar()
method.UserState
getState()
Please useUser.isValidState()
to retrieve user validity information.Date
getStateSaveDate()
Gets the last date of the last user save.String
getStatus()
Gets the current status filled by the user itself.UserPreferences
getUserPreferences()
Gets the preferences of this user.int
getVersion()
Gets the version of the user data.int
hashCode()
boolean
isAccessAdmin()
Indicates if the user has admin access on the platform.boolean
isAccessDomainManager()
Indicates if the user has domain manager access on the platform.boolean
isAccessGuest()
Indicates if the user has guest access on the platform.boolean
isAccessPdcManager()
Indicates if the user has PDC manager access on the platform.boolean
isAccessUnknown()
Indicates if the user has unknown access on the platform.boolean
isAccessUser()
Indicates if the user has user access on the platform.boolean
isActivatedState()
This method indicates if the user is activated.boolean
isAnonymous()
Indicates if the user is an anonymous one.boolean
isAtLeastInOneGroup(List<String> groupIds)
Is the user at least in one of the following groups of users in Silverpeas?boolean
isBlanked()
Indicates if the user was blanked after its deletion.boolean
isBlockedState()
This method is the only one able to indicate the user blocked state.boolean
isChatEnabled()
Is the chat service is enabled for this user?boolean
isConnected()
Indicates if the user is currently connected to Silverpeas.boolean
isDeactivatedState()
This method is the only one able to indicate the user deactivated state.boolean
isDeletedState()
This method is the only one able to indicate the user deletion state.boolean
isDomainAdminRestricted()
Indicates if the user has admin account and is restricted to access the resource in its own domain only.boolean
isDomainRestricted()
Indicates if the user is restricted to access the resource in its own domain only.boolean
isExpiredState()
This method is the only one able to indicate the user expiration state.boolean
isFullyDefined()
Indicates if the mandatory user data are defined.boolean
isPlayingAdminRole(String instanceId)
Indicates if either the user is an administrator or he plays the administrator role in the specified component instance.boolean
isRegistered()
Has the user already an account in the chat server?boolean
isRemovedState()
This method is the only one able to indicate the user removed state.boolean
isSystem()
Is this user the system one?boolean
isValidState()
This method is the only one able to indicate the user validity state.-
Methods inherited from class org.silverpeas.core.admin.user.model.UserDetail
compareTo, from, getAll, getAnonymousUser, getAnonymousUserId, getAvatarFileName, getDomain, getExpirationDate, getInvitationReceivedFrom, getInvitationSentTo, getLastLoginCredentialUpdateDate, getLastLoginDate, getLoginAnswer, getLoginQuestion, getNbSuccessfulLoginAttempts, getNotifManualReceiverLimit, getOrganisationController, getSpecificId, getSystemUser, getToken, getTosAcceptanceDate, getUserManualNotificationUserReceiverLimitValue, hasSensitiveData, isAnonymousUser, isAnonymousUserExist, isAvatarDefined, isBackOfficeVisible, isInRelationWith, isUserManualNotificationUserReceiverLimit, setAccessLevel, setCreationDate, setDomainId, setEmailAddress, setExpirationDate, setFirstName, setId, setLastLoginCredentialUpdateDate, setLastLoginDate, setLastName, setLogin, setLoginAnswer, setLoginQuestion, setNbSuccessfulLoginAttempts, setNotifManualReceiverLimit, setSaveDate, setSensitiveData, setSpecificId, setState, setStateSaveDate, setTosAcceptanceDate, setUserManualNotificationUserReceiverLimit, setVersion, traceUser
-
-
-
-
Method Detail
-
getById
public static ChatUser getById(String userId)
Gets a chat user from the specified Silverpeas unique identifier.- Parameters:
userId
- the unique identifier of a user in Silverpeas.- Returns:
- a user having an account in Silverpeas.
-
getCurrentRequester
public static ChatUser getCurrentRequester()
Gets the user behind the current request to Silverpeas and that have an account in the chat service.- Returns:
- the current requester as a
ChatUser
.
-
fromUser
public static ChatUser fromUser(User user)
Creates a newChatUser
from the specified Silverpeas user. It will convert the specified user to a chat user.- Parameters:
user
- a Silverpeas user.- Returns:
- a Chat service user.
-
getChatId
public String getChatId()
Gets the unique identifier of this user in the chat service. It is made up of the user login plus the domain of the chat service; they are concatenated with @ as separator.- Returns:
- the unique identifier of the user the the chat service.
-
getChatLogin
public String getChatLogin()
Gets the chat service login of this user. The login format is defined by the RFC-7622 in which it represents thelocalpart
field conforming theUsernameCaseMapped
profile of the PRECISIdentifierClass
defined in RFC-7613.- Returns:
- the login of the user in the chat service.
-
getChatPassword
public String getChatPassword()
Gets the chat service password of this user.- Returns:
- the password associated with its login in the chat service.
-
getChatDomain
public String getChatDomain()
Gets the chat domain to which this user belongs. The chat domain is read from the property fileorg/silverpeas/chat/settings/chat.properties
and it depends on the Silverpeas domain of the user. If no chat domain is mapped to the Silverpeas domain of the user, then the default one (the one set by thechat.xmpp.domain.default
property) is returned.- Returns:
- the name of the chat domain of the user or an empty string if no chat domain is mapped to the Silverpeas domain of the user.
-
isChatEnabled
public boolean isChatEnabled()
Is the chat service is enabled for this user? It is enabled if both the chat service is enabled in Silverpeas, the user domain he belongs to is mapped to a chat domain in the chat service and he belongs to a group of users in Silverpeas that is allowed to access the chat service.- Returns:
- true if the chat is enabled for the user. False otherwise.
-
isRegistered
public boolean isRegistered()
Has the user already an account in the chat server?- Returns:
- true if
isChatEnabled()
returns true and if the user has an account in the chat server, false otherwise or ifChatServerException
has been detected.
-
isAtLeastInOneGroup
public boolean isAtLeastInOneGroup(List<String> groupIds)
Is the user at least in one of the following groups of users in Silverpeas? This method is mainly used to check the ACL on the chat client functionalities when bootstrapping later.- Parameters:
groupIds
- a list of unique identifiers of group of users in Silverpeas.- Returns:
- true if the user is at least in one of the specified groups.
-
getId
public String getId()
Description copied from interface:User
The unique identifier of the user into Silverpeas.- Specified by:
getId
in interfaceUser
- Overrides:
getId
in classUserDetail
- Returns:
- identifier as string.
-
getDomainId
public String getDomainId()
Description copied from interface:User
Gets the user domain id.- Specified by:
getDomainId
in interfaceUser
- Overrides:
getDomainId
in classUserDetail
- Returns:
- user domain id as string.
-
isDomainRestricted
public boolean isDomainRestricted()
Description copied from interface:User
Indicates if the user is restricted to access the resource in its own domain only.- Specified by:
isDomainRestricted
in interfaceUser
- Overrides:
isDomainRestricted
in classUserDetail
- Returns:
- true if it's restricted, false otherwise.
-
isDomainAdminRestricted
public boolean isDomainAdminRestricted()
Description copied from interface:User
Indicates if the user has admin account and is restricted to access the resource in its own domain only.- Specified by:
isDomainAdminRestricted
in interfaceUser
- Overrides:
isDomainAdminRestricted
in classUserDetail
- Returns:
- true if it's restricted, false otherwise.
-
getLogin
public String getLogin()
Description copied from interface:User
Gets the user login.- Specified by:
getLogin
in interfaceUser
- Overrides:
getLogin
in classUserDetail
- Returns:
- user login as string.
-
getLastName
public String getLastName()
Description copied from interface:User
Gets the last name of the user.- Specified by:
getLastName
in interfaceUser
- Overrides:
getLastName
in classUserDetail
- Returns:
- last name as string.
-
getFirstName
public String getFirstName()
Description copied from interface:User
Gets the first name of the user.- Specified by:
getFirstName
in interfaceUser
- Overrides:
getFirstName
in classUserDetail
- Returns:
- first name as string.
-
getEmailAddress
public String getEmailAddress()
Description copied from interface:User
Gets the user email.- Specified by:
getEmailAddress
in interfaceUser
- Overrides:
getEmailAddress
in classUserDetail
- Returns:
- user email as string.
-
getCreationDate
public Date getCreationDate()
Description copied from interface:User
Gets the date of the user creation.- Specified by:
getCreationDate
in interfaceUser
- Overrides:
getCreationDate
in classUserDetail
- Returns:
- creation date of the user as
Date
.
-
getSaveDate
public Date getSaveDate()
Description copied from interface:User
Gets the date of the last user save.- Specified by:
getSaveDate
in interfaceUser
- Overrides:
getSaveDate
in classUserDetail
- Returns:
- the date of the last user save as
Date
.
-
getVersion
public int getVersion()
Description copied from interface:User
Gets the version of the user data. The number of time the entity has been saved in other words.- Specified by:
getVersion
in interfaceUser
- Overrides:
getVersion
in classUserDetail
- Returns:
- the version of the last save as integer.
-
getStateSaveDate
public Date getStateSaveDate()
Description copied from interface:User
Gets the last date of the last user save.- Specified by:
getStateSaveDate
in interfaceUser
- Overrides:
getStateSaveDate
in classUserDetail
- Returns:
- the date of last user state save (when it changes) as
Date
.
-
isFullyDefined
public boolean isFullyDefined()
Description copied from interface:User
Indicates if the mandatory user data are defined.- Specified by:
isFullyDefined
in interfaceUser
- Overrides:
isFullyDefined
in classUserDetail
- Returns:
- true if all mandatory are defined, false otherwise.
-
getDisplayedName
public String getDisplayedName()
Description copied from interface:User
Default first name and last name concatenation.- Specified by:
getDisplayedName
in interfaceUser
- Overrides:
getDisplayedName
in classUserDetail
- Returns:
- concatenation of first name and last name as string (without outer space).
-
getAccessLevel
public UserAccessLevel getAccessLevel()
Description copied from interface:User
Gets the user access level.- Specified by:
getAccessLevel
in interfaceUser
- Overrides:
getAccessLevel
in classUserDetail
- Returns:
- the access level as
UserAccessLevel
.
-
isAnonymous
public boolean isAnonymous()
Description copied from interface:User
Indicates if the user is an anonymous one.- Specified by:
isAnonymous
in interfaceUser
- Overrides:
isAnonymous
in classUserDetail
- Returns:
- true if anonymous, false otherwise.
-
isSystem
public boolean isSystem()
Description copied from interface:User
Is this user the system one? A system user is a virtual one played by the Silverpeas platform to perform tasks that aren't invoked explicitly by a user in Silverpeas but triggered either by a scheduler or a batch process like a workflow.- Specified by:
isSystem
in interfaceUser
- Overrides:
isSystem
in classUserDetail
- Returns:
- true if this user is the virtual system one. False otherwise.
-
isBlanked
public boolean isBlanked()
Description copied from interface:User
Indicates if the user was blanked after its deletion. Blank a user means its data has been blanked and therefore any of his contributions in Silverpeas can be figured out; his contributions were anonymized.- Specified by:
isBlanked
in interfaceUser
- Overrides:
isBlanked
in classUserDetail
- Returns:
- true if the user was blanked.
-
isAccessAdmin
public boolean isAccessAdmin()
Description copied from interface:User
Indicates if the user has admin access on the platform.- Specified by:
isAccessAdmin
in interfaceUser
- Overrides:
isAccessAdmin
in classUserDetail
- Returns:
- true if admin access, false otherwise.
-
isAccessDomainManager
public boolean isAccessDomainManager()
Description copied from interface:User
Indicates if the user has domain manager access on the platform.- Specified by:
isAccessDomainManager
in interfaceUser
- Overrides:
isAccessDomainManager
in classUserDetail
- Returns:
- true if domain manager access, false otherwise.
-
isAccessPdcManager
public boolean isAccessPdcManager()
Description copied from interface:User
Indicates if the user has PDC manager access on the platform.- Specified by:
isAccessPdcManager
in interfaceUser
- Overrides:
isAccessPdcManager
in classUserDetail
- Returns:
- true if PDC manager access, false otherwise.
-
isAccessUser
public boolean isAccessUser()
Description copied from interface:User
Indicates if the user has user access on the platform.- Specified by:
isAccessUser
in interfaceUser
- Overrides:
isAccessUser
in classUserDetail
- Returns:
- true if user access, false otherwise.
-
isAccessGuest
public boolean isAccessGuest()
Description copied from interface:User
Indicates if the user has guest access on the platform.- Specified by:
isAccessGuest
in interfaceUser
- Overrides:
isAccessGuest
in classUserDetail
- Returns:
- true if guest access, false otherwise.
-
isAccessUnknown
public boolean isAccessUnknown()
Description copied from interface:User
Indicates if the user has unknown access on the platform.- Specified by:
isAccessUnknown
in interfaceUser
- Overrides:
isAccessUnknown
in classUserDetail
- Returns:
- true if unknown access, false otherwise.
-
isPlayingAdminRole
public boolean isPlayingAdminRole(String instanceId)
Description copied from interface:User
Indicates if either the user is an administrator or he plays the administrator role in the specified component instance. The roles the user can play are different from the privileges he has in the given component instance. The privileges for a component instance are controlled by theComponentAccessControl
service, based upon the roles the user has specifically in the given component instance.- Specified by:
isPlayingAdminRole
in interfaceUser
- Overrides:
isPlayingAdminRole
in classUserDetail
- Parameters:
instanceId
- the unique identifier of a component instance in Silverpeas.- Returns:
- true if the user has an admin access on the platform or if he plays the administrator role in the given component instance. False otherwise.
-
getState
public UserState getState()
Description copied from interface:User
Please useUser.isValidState()
to retrieve user validity information. Please useUser.isDeletedState()
to retrieve user deletion information. Please useUser.isBlockedState()
to retrieve user blocked information. Please useUser.isDeactivatedState()
to retrieve user deactivated information. Please useUser.isExpiredState()
to retrieve user expiration information. This method returns the stored state information but not the functional information.- Specified by:
getState
in interfaceUser
- Overrides:
getState
in classUserDetail
- Returns:
- the state of the user (account)
-
isActivatedState
public boolean isActivatedState()
Description copied from interface:User
This method indicates if the user is activated. The returned value is a combination of following method call result :- not
User.isAnonymous()
- and not
User.isDeletedState()
- and not
User.isDeactivatedState()
- Specified by:
isActivatedState
in interfaceUser
- Overrides:
isActivatedState
in classUserDetail
- Returns:
- true if activated state, false otherwise.
- not
-
isValidState
public boolean isValidState()
Description copied from interface:User
This method is the only one able to indicate the user validity state. Please do not useUser.getState()
to retrieve user validity information.- Specified by:
isValidState
in interfaceUser
- Overrides:
isValidState
in classUserDetail
- Returns:
- true if valid state, false otherwise.
-
isDeletedState
public boolean isDeletedState()
Description copied from interface:User
This method is the only one able to indicate the user deletion state. Please do not useUser.getState()
to retrieve user deletion information.- Specified by:
isDeletedState
in interfaceUser
- Overrides:
isDeletedState
in classUserDetail
- Returns:
- true if deleted state, false otherwise.
-
isRemovedState
public boolean isRemovedState()
Description copied from interface:User
This method is the only one able to indicate the user removed state. Please do not useUser.getState()
to retrieve user removed information.- Specified by:
isRemovedState
in interfaceUser
- Overrides:
isRemovedState
in classUserDetail
- Returns:
- true if deleted state, false otherwise.
-
isBlockedState
public boolean isBlockedState()
Description copied from interface:User
This method is the only one able to indicate the user blocked state. Please do not useUser.getState()
to retrieve user blocked information.- Specified by:
isBlockedState
in interfaceUser
- Overrides:
isBlockedState
in classUserDetail
- Returns:
- true if blocked state, false otherwise.
-
isDeactivatedState
public boolean isDeactivatedState()
Description copied from interface:User
This method is the only one able to indicate the user deactivated state. Please do not useUser.getState()
to retrieve user deactivated information.- Specified by:
isDeactivatedState
in interfaceUser
- Overrides:
isDeactivatedState
in classUserDetail
- Returns:
- true if deactivated state, false otherwise.
-
isExpiredState
public boolean isExpiredState()
Description copied from interface:User
This method is the only one able to indicate the user expiration state. Please do not useUser.getState()
to retrieve user expiration information.- Specified by:
isExpiredState
in interfaceUser
- Overrides:
isExpiredState
in classUserDetail
- Returns:
- true if user is expired.
-
isConnected
public boolean isConnected()
Description copied from interface:User
Indicates if the user is currently connected to Silverpeas.- Specified by:
isConnected
in interfaceUser
- Overrides:
isConnected
in classUserDetail
- Returns:
- true if the user is currently connected to Silverpeas, false otherwise.
-
getUserPreferences
public UserPreferences getUserPreferences()
Description copied from interface:User
Gets the preferences of this user.- Specified by:
getUserPreferences
in interfaceUser
- Overrides:
getUserPreferences
in classUserDetail
- Returns:
- the user preferences.
-
getAvatar
public String getAvatar()
Description copied from interface:User
Gets the avatar URL of the user.- Specified by:
getAvatar
in interfaceUser
- Overrides:
getAvatar
in classUserDetail
- Returns:
- the avatar URL as string.
-
getSmallAvatar
public String getSmallAvatar()
Description copied from interface:User
Gets the URL of a smaller version of avatar than the one provided byUser.getAvatar()
method.- Specified by:
getSmallAvatar
in interfaceUser
- Overrides:
getSmallAvatar
in classUserDetail
- Returns:
- the small avatar URL as string.
-
getStatus
public String getStatus()
Description copied from interface:User
Gets the current status filled by the user itself.- Specified by:
getStatus
in interfaceUser
- Overrides:
getStatus
in classUserDetail
- Returns:
- current status as string.
-
getDurationOfCurrentSession
public String getDurationOfCurrentSession()
Description copied from interface:User
Gets the duration of the current user session since its last registered login date.- Specified by:
getDurationOfCurrentSession
in interfaceUser
- Overrides:
getDurationOfCurrentSession
in classUserDetail
- Returns:
- the formatted duration of the current user session, or empty string if the user is not connected.
-
equals
public boolean equals(Object other)
- Overrides:
equals
in classUserDetail
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classUserDetail
-
-