public class UserService extends Object
Modifier and Type | Class and Description |
---|---|
static class |
UserService.UserServiceRetrievalFlag
These flags allow to control the retrieval process of a user in the UserService.
|
Constructor and Description |
---|
UserService() |
Modifier and Type | Method and Description |
---|---|
void |
anonymizeUser(Long userId,
Long[] blogIds,
boolean becomeManager)
Delete a user by anonymizing his profile and removing the content (notes, topics if possible)
he created.
|
Collection<ExternalUserRepository> |
getActiveUserRepositories()
Returns all active user repositories.
|
ExternalUserRepository |
getAvailableUserRepository(String systemId)
Get the available repository for the given system id.
|
Collection<StringPropertyTO> |
getExternalLoginProperties(Long userId,
ExternalUserAuthentication externalUserAuthentication)
External Repos can return additional properties that will be included e.g.
|
ExternalSystemConfiguration |
getExternalSystemConfiguration(String externalSystemId) |
ExternalUserRepository |
getExternalUserRepository(String externalSystemId)
Get the external user repository based on the repository mode.
|
Group |
getGroup(String alias)
Get a group by its alias.
|
Group |
getGroup(String externalGroupId,
String externalSystemId)
Get group specific from external system
|
Collection<UserProfileFields> |
getImmutableProfileFieldsOfUser(Long userId)
Get the names of the user profile fields that cannot be changed by the user.
|
Collection<ExternalUserRepository> |
getRegistedExternalUserRepositories() |
User |
getUser(String alias)
Get a user by its alias.
|
User |
getUser(String externalUserId,
String externalSystemId)
Get a user that originates from a specific external system.
|
User |
getUser(UserIdentification userIdentification,
UserService.UserServiceRetrievalFlag... flags)
Get a user specified by the given
UserIdentification . |
boolean |
hasRole(Long userId,
UserRole role)
Return whether the provided user has the given role.
|
boolean |
isUserRepositoryActive(String externalSystemId) |
void |
registerRepository(String externalSystemId,
ExternalUserRepository externalUserRepository)
Register an external user repository.
|
void |
setDefaultRepositories(Map<String,ExternalUserRepository> defaultRepositories)
Set the default repositories
|
void |
unregisterRepository(String externalSystemId)
Unregister an external user repository if is not an default repository
|
public void anonymizeUser(Long userId, Long[] blogIds, boolean becomeManager) throws AuthorizationException, NoClientManagerLeftException, UserDeletionDisabledException, NoBlogManagerLeftException
userId
- ID of the user to removeblogIds
- an array of IDs of topics in which the user to remove is the only manager. If the
current user is not a client manager this parameter is ignored.becomeManager
- whether the current user, which has to be a client manager, should become manager
of the topics identified by the IDs in blogIds array. If false the topics will be
deleted.AuthorizationException
- in case the current user is not a client manager or the user to removeNoClientManagerLeftException
- in case the user to delete is the last active client managerUserDeletionDisabledException
- in case the anonymization of users is disabled and the current user is not a
client managerNoBlogManagerLeftException
- in case there are topics which are managed by the user to remove and have
additional users with read access but no other managers. If the current user is
client manager this exception will only be thrown if the IDs of the topics are
not in the blogIds array. The exception will contain the IDs of the topics that
would become manager-less.public Collection<ExternalUserRepository> getActiveUserRepositories()
public ExternalUserRepository getAvailableUserRepository(String systemId)
systemId
- the system id to get the repository ofpublic Collection<StringPropertyTO> getExternalLoginProperties(Long userId, ExternalUserAuthentication externalUserAuthentication) throws AuthorizationException
userId
- the id of the user the authentication is forexternalUserAuthentication
- the authentication to get additional properties forAuthorizationException
public ExternalSystemConfiguration getExternalSystemConfiguration(String externalSystemId)
public ExternalUserRepository getExternalUserRepository(String externalSystemId)
externalSystemId
- identifier of the external system. Can be null to get the primary repository.ClientProperty.REPOSITORY_MODE
public Group getGroup(String alias) throws GroupNotFoundException
alias
- the alias of the groupGroupNotFoundException
- in case the group was not foundpublic Group getGroup(String externalGroupId, String externalSystemId) throws GroupNotFoundException
externalGroupId
- group identifier of the external systemexternalSystemId
- identifier of the external systemGroup
the found group, never nullGroupNotFoundException
- in case the group can not be foundpublic Collection<UserProfileFields> getImmutableProfileFieldsOfUser(Long userId)
userId
- the id of user to get the fixed fields forpublic Collection<ExternalUserRepository> getRegistedExternalUserRepositories()
public User getUser(String alias) throws UserNotFoundException
alias
- the alias of the userUserNotFoundException
- in case there is no matching user or a matching external user cannot be createdpublic User getUser(String externalUserId, String externalSystemId) throws UserNotFoundException
externalUserId
- identifier of the user in the external systemexternalSystemId
- identifier of the external systemUserNotFoundException
- in case there is no matching user or a matching external user cannot be createdpublic User getUser(UserIdentification userIdentification, UserService.UserServiceRetrievalFlag... flags) throws UserNotFoundException
UserIdentification
. Depending on configuration and
retrieval flags this can lead to a lookup of the user in an external repository.userIdentification
- identification of the userflags
- optional flags to configure how the user should be retrievedUserNotFoundException
- in case the user does not exist or in case the user cannot be created or updated
after a successful lookup in an external repositorypublic boolean hasRole(Long userId, UserRole role)
userId
- the ID of the user to testrole
- the role to test forpublic boolean isUserRepositoryActive(String externalSystemId)
public void registerRepository(String externalSystemId, ExternalUserRepository externalUserRepository)
externalSystemId
- identifier of the external repository (LDAP, Confluence, ...)externalUserRepository
- the repository to registerpublic void setDefaultRepositories(Map<String,ExternalUserRepository> defaultRepositories)
defaultRepositories
- map of repositoriespublic void unregisterRepository(String externalSystemId)
externalSystemId
- of the external repository (LDAP, Confluence, Sharepoint, ...)Copyright © 2019 Communote team. All rights reserved.