public class SwitchingUserDao extends Object
UserDao
.
The switch is made on construction time.
This is a smell, because constructors should be lightweight have no side effects.
Unfortunately, we cannot do it right, because of the conjunction of the following reasons:
OfBizUserDao
has a dirty constructorConstructor and Description |
---|
SwitchingUserDao(UserIndexer indexer,
CrowdQueryTranslator translator,
ClusterMessagingService clusterMessagingService,
OfBizTransactionManager ofBizTransactionManager,
int maxBatchSize,
OfBizDelegator ofBizDelegator,
com.atlassian.crowd.embedded.spi.DirectoryDao directoryDao,
InternalMembershipDao membershipDao,
UserKeyStore userKeyStore,
UserDeleteVeto userDeleteVeto,
com.atlassian.cache.CacheManager cacheManager,
com.atlassian.beehive.ClusterLockService clusterLockService,
ApplicationProperties applicationProperties,
DatabaseConfigurationManager databaseConfigurationManager,
com.atlassian.event.api.EventPublisher eventPublisher) |
Modifier and Type | Method and Description |
---|---|
com.atlassian.crowd.model.user.User |
add(com.atlassian.crowd.model.user.User user,
com.atlassian.crowd.embedded.api.PasswordCredential credential) |
com.atlassian.crowd.util.BatchResult<com.atlassian.crowd.model.user.User> |
addAll(Set<com.atlassian.crowd.model.user.UserTemplateWithCredentialAndAttributes> users) |
protected ExtendedUserDao |
delegate() |
List<OfBizUser> |
findAllByNameOrNull(long directoryId,
Collection<String> userNames) |
com.atlassian.crowd.model.user.TimestampedUser |
findByExternalId(long directoryId,
String externalId) |
Map<String,String> |
findByExternalIds(long directoryId,
Set<String> externalIds) |
OfBizUser |
findById(long internalUserId)
Finds a user by internal user ID.
|
com.atlassian.crowd.model.user.TimestampedUser |
findByName(long directoryId,
String userName) |
OfBizUser |
findByNameOrNull(long directoryId,
String userName)
Tries to find the user by name and returns null if not found.
|
com.atlassian.crowd.model.user.UserWithAttributes |
findByNameWithAttributes(long directoryId,
String userName) |
Set<Long> |
findDirectoryIdsContainingUserName(String username) |
Collection<String> |
findNamesOfUsersInGroups(Collection<String> groupNames)
Returns the lower-cased names of all users in the specified groups.
|
OfBizUser |
findOfBizUser(long directoryId,
String userName) |
void |
flushCache()
Invoked by
OfBizCacheFlushingManager to ensure caches are being flushed in the right order on XMLRestoreFinishedEvent |
Collection<String> |
getAllAttributeKeys() |
Set<String> |
getAllExternalIds(long directoryId) |
com.atlassian.crowd.embedded.api.PasswordCredential |
getCredential(long directoryId,
String userName) |
List<com.atlassian.crowd.embedded.api.PasswordCredential> |
getCredentialHistory(long directoryId,
String userName) |
long |
getUniqueUserCount(Set<Long> directoryIds) |
long |
getUserCount(long directoryId) |
boolean |
isDeletedExternally(long internalUserId)
Checks if user (identified by internal user ID) has been deleted from external user directory.
|
boolean |
isDeletedExternally(long directoryId,
String userName)
Checks if user (identified by directory ID and user name) has been deleted from external user directory.
|
void |
processUsers(java.util.function.Consumer<? super com.atlassian.crowd.model.user.User> userProcessor)
Performs an operation on every user in the system.
|
void |
remove(com.atlassian.crowd.model.user.User user) |
com.atlassian.crowd.util.BatchResult<String> |
removeAllUsers(long directoryId,
Set<String> userNames) |
void |
removeAttribute(com.atlassian.crowd.model.user.User user,
String attributeName) |
com.atlassian.crowd.model.user.User |
rename(com.atlassian.crowd.model.user.User user,
String newName) |
<T> List<T> |
search(long directoryId,
com.atlassian.crowd.search.query.entity.EntityQuery<T> query) |
void |
setAttributeForAllInDirectory(long directoryId,
String attrName,
String attrValue) |
void |
storeAttributes(com.atlassian.crowd.model.user.User user,
Map<String,Set<String>> attributes,
boolean updateTimestamp) |
com.atlassian.crowd.model.user.User |
update(com.atlassian.crowd.model.user.User user) |
com.atlassian.crowd.model.user.User |
update(com.atlassian.crowd.model.user.User user,
boolean useJiraExtensions)
Updates user, for detailed description see
UserDao.update(com.atlassian.crowd.model.user.User) . |
void |
updateCredential(com.atlassian.crowd.model.user.User user,
com.atlassian.crowd.embedded.api.PasswordCredential credential,
int maxCredentialHistory) |
boolean |
useFullCache() |
boolean |
useInternedUserValues() |
public SwitchingUserDao(UserIndexer indexer, CrowdQueryTranslator translator, ClusterMessagingService clusterMessagingService, OfBizTransactionManager ofBizTransactionManager, int maxBatchSize, OfBizDelegator ofBizDelegator, com.atlassian.crowd.embedded.spi.DirectoryDao directoryDao, InternalMembershipDao membershipDao, UserKeyStore userKeyStore, UserDeleteVeto userDeleteVeto, com.atlassian.cache.CacheManager cacheManager, com.atlassian.beehive.ClusterLockService clusterLockService, ApplicationProperties applicationProperties, DatabaseConfigurationManager databaseConfigurationManager, com.atlassian.event.api.EventPublisher eventPublisher)
protected ExtendedUserDao delegate()
public boolean useFullCache()
useFullCache
in interface ExtendedUserDao
public boolean useInternedUserValues()
useInternedUserValues
in interface ExtendedUserDao
public long getUniqueUserCount(Set<Long> directoryIds) throws com.atlassian.crowd.exception.DirectoryNotFoundException
getUniqueUserCount
in interface ExtendedUserDao
com.atlassian.crowd.exception.DirectoryNotFoundException
public Collection<String> findNamesOfUsersInGroups(Collection<String> groupNames)
ExtendedUserDao
findNamesOfUsersInGroups
in interface ExtendedUserDao
groupNames
- the names of the groups to search.public Collection<String> getAllAttributeKeys()
getAllAttributeKeys
in interface ExtendedUserDao
public void processUsers(java.util.function.Consumer<? super com.atlassian.crowd.model.user.User> userProcessor)
ExtendedUserDao
This can be a time-consuming operation on JIRA instances that contain many users. It is recommended to use one of the search methods where possible.
This method performs a live iteration over a database result set. Care must be taken if additional database
operations are performed within the userProcessor
consumer.
processUsers
in interface ExtendedUserDao
userProcessor
- the operation to perform on each user.public void flushCache()
ExtendedUserDao
OfBizCacheFlushingManager
to ensure caches are being flushed in the right order on XMLRestoreFinishedEvent
flushCache
in interface ExtendedUserDao
public com.atlassian.crowd.model.user.TimestampedUser findByName(long directoryId, String userName) throws com.atlassian.crowd.exception.UserNotFoundException
findByName
in interface com.atlassian.crowd.embedded.spi.UserDao
com.atlassian.crowd.exception.UserNotFoundException
public com.atlassian.crowd.model.user.TimestampedUser findByExternalId(long directoryId, String externalId) throws com.atlassian.crowd.exception.UserNotFoundException
findByExternalId
in interface com.atlassian.crowd.embedded.spi.UserDao
com.atlassian.crowd.exception.UserNotFoundException
public com.atlassian.crowd.model.user.UserWithAttributes findByNameWithAttributes(long directoryId, String userName) throws com.atlassian.crowd.exception.UserNotFoundException
findByNameWithAttributes
in interface com.atlassian.crowd.embedded.spi.UserDao
com.atlassian.crowd.exception.UserNotFoundException
public com.atlassian.crowd.embedded.api.PasswordCredential getCredential(long directoryId, String userName) throws com.atlassian.crowd.exception.UserNotFoundException
getCredential
in interface com.atlassian.crowd.embedded.spi.UserDao
com.atlassian.crowd.exception.UserNotFoundException
public List<com.atlassian.crowd.embedded.api.PasswordCredential> getCredentialHistory(long directoryId, String userName) throws com.atlassian.crowd.exception.UserNotFoundException
getCredentialHistory
in interface com.atlassian.crowd.embedded.spi.UserDao
com.atlassian.crowd.exception.UserNotFoundException
public com.atlassian.crowd.model.user.User add(com.atlassian.crowd.model.user.User user, com.atlassian.crowd.embedded.api.PasswordCredential credential) throws com.atlassian.crowd.exception.UserAlreadyExistsException, IllegalArgumentException, com.atlassian.crowd.exception.DirectoryNotFoundException
add
in interface com.atlassian.crowd.embedded.spi.UserDao
com.atlassian.crowd.exception.UserAlreadyExistsException
IllegalArgumentException
com.atlassian.crowd.exception.DirectoryNotFoundException
public com.atlassian.crowd.model.user.User update(com.atlassian.crowd.model.user.User user) throws com.atlassian.crowd.exception.UserNotFoundException, IllegalArgumentException
update
in interface com.atlassian.crowd.embedded.spi.UserDao
com.atlassian.crowd.exception.UserNotFoundException
IllegalArgumentException
public void updateCredential(com.atlassian.crowd.model.user.User user, com.atlassian.crowd.embedded.api.PasswordCredential credential, int maxCredentialHistory) throws com.atlassian.crowd.exception.UserNotFoundException, IllegalArgumentException
updateCredential
in interface com.atlassian.crowd.embedded.spi.UserDao
com.atlassian.crowd.exception.UserNotFoundException
IllegalArgumentException
public com.atlassian.crowd.model.user.User rename(com.atlassian.crowd.model.user.User user, String newName) throws com.atlassian.crowd.exception.UserNotFoundException, com.atlassian.crowd.exception.UserAlreadyExistsException, IllegalArgumentException
rename
in interface com.atlassian.crowd.embedded.spi.UserDao
com.atlassian.crowd.exception.UserNotFoundException
com.atlassian.crowd.exception.UserAlreadyExistsException
IllegalArgumentException
public void removeAttribute(com.atlassian.crowd.model.user.User user, String attributeName) throws com.atlassian.crowd.exception.UserNotFoundException
removeAttribute
in interface com.atlassian.crowd.embedded.spi.UserDao
com.atlassian.crowd.exception.UserNotFoundException
public void remove(com.atlassian.crowd.model.user.User user) throws com.atlassian.crowd.exception.UserNotFoundException
remove
in interface com.atlassian.crowd.embedded.spi.UserDao
com.atlassian.crowd.exception.UserNotFoundException
public <T> List<T> search(long directoryId, com.atlassian.crowd.search.query.entity.EntityQuery<T> query)
search
in interface com.atlassian.crowd.embedded.spi.UserDao
public com.atlassian.crowd.util.BatchResult<com.atlassian.crowd.model.user.User> addAll(Set<com.atlassian.crowd.model.user.UserTemplateWithCredentialAndAttributes> users)
addAll
in interface com.atlassian.crowd.embedded.spi.UserDao
public com.atlassian.crowd.util.BatchResult<String> removeAllUsers(long directoryId, Set<String> userNames)
removeAllUsers
in interface com.atlassian.crowd.embedded.spi.UserDao
public void setAttributeForAllInDirectory(long directoryId, String attrName, String attrValue)
setAttributeForAllInDirectory
in interface com.atlassian.crowd.embedded.spi.UserDao
public OfBizUser findOfBizUser(long directoryId, String userName) throws UserNotFoundException
findOfBizUser
in interface ExtendedUserDao
UserNotFoundException
public List<OfBizUser> findAllByNameOrNull(long directoryId, @Nonnull Collection<String> userNames)
findAllByNameOrNull
in interface ExtendedUserDao
@Nullable public OfBizUser findByNameOrNull(long directoryId, @Nonnull String userName)
ExtendedUserDao
findByNameOrNull
in interface ExtendedUserDao
directoryId
- Directory IDuserName
- the usernamenull
if the user does not existpublic Set<String> getAllExternalIds(long directoryId) throws com.atlassian.crowd.exception.DirectoryNotFoundException
getAllExternalIds
in interface com.atlassian.crowd.embedded.spi.UserDao
com.atlassian.crowd.exception.DirectoryNotFoundException
public long getUserCount(long directoryId) throws com.atlassian.crowd.exception.DirectoryNotFoundException
getUserCount
in interface com.atlassian.crowd.embedded.spi.UserDao
com.atlassian.crowd.exception.DirectoryNotFoundException
@Nullable public OfBizUser findById(long internalUserId)
ExtendedUserDao
findById
in interface ExtendedUserDao
internalUserId
- the user ID.public boolean isDeletedExternally(long internalUserId)
ExtendedUserDao
isDeletedExternally
in interface ExtendedUserDao
internalUserId
- the user ID.public boolean isDeletedExternally(long directoryId, @Nonnull String userName)
ExtendedUserDao
isDeletedExternally
in interface ExtendedUserDao
directoryId
- Directory IDuserName
- the usernamepublic com.atlassian.crowd.model.user.User update(com.atlassian.crowd.model.user.User user, boolean useJiraExtensions) throws UserNotFoundException
ExtendedUserDao
UserDao.update(com.atlassian.crowd.model.user.User)
.update
in interface ExtendedUserDao
user
- the user details, which should have the same name as the user to modifyuseJiraExtensions
- Whether jira extensions should be run.
Currently only extension is that when externally deleted user is updated (inactive and flagged)
"externally deleted" flag is cleared and user is made active.UserNotFoundException
- if there is no user with the same name (case-insensitive) and directory as the
user providedUserDao.update(com.atlassian.crowd.model.user.User)
public void storeAttributes(com.atlassian.crowd.model.user.User user, Map<String,Set<String>> attributes, boolean updateTimestamp) throws com.atlassian.crowd.exception.UserNotFoundException
storeAttributes
in interface com.atlassian.crowd.embedded.spi.UserDao
com.atlassian.crowd.exception.UserNotFoundException
public Set<Long> findDirectoryIdsContainingUserName(String username)
findDirectoryIdsContainingUserName
in interface com.atlassian.crowd.embedded.spi.UserDao
Copyright © 2002-2021 Atlassian. All Rights Reserved.