Class SwitchingUserDao
java.lang.Object
com.atlassian.jira.crowd.embedded.ofbiz.SwitchingUserDao
- All Implemented Interfaces:
com.atlassian.crowd.embedded.spi.UserDao
,ExtendedUserDao
Switch between indexing and nonindexing
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 constructor- Pico implicitly publishes implementations under all supertypes of the explicit key
- Pico doesn't allow a single implementation under multiple explicit keys
-
Constructor Summary
ConstructorsConstructorDescriptionSwitchingUserDao
(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, OfBizServiceAccountDao serviceAccountDao) -
Method Summary
Modifier and TypeMethodDescriptioncom.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> protected ExtendedUserDao
delegate()
findAllByNameOrNull
(long directoryId, Collection<String> userNames) com.atlassian.crowd.model.user.TimestampedUser
findByExternalId
(long directoryId, String externalId) findByExternalIds
(long directoryId, Set<String> externalIds) findById
(long internalUserId) Finds a user by internal user ID.com.atlassian.crowd.model.user.TimestampedUser
findByName
(long directoryId, String userName) 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) findDirectoryIdsContainingUserName
(String username) findNamesOfUsersInGroups
(Collection<String> groupNames) Returns the lower-cased names of all users in the specified groups.findOfBizUser
(long directoryId, String userName) void
Invoked byOfBizCacheFlushingManager
to ensure caches are being flushed in the right order onXMLRestoreFinishedEvent
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
(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
<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 seeUserDao.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
boolean
-
Constructor Details
-
SwitchingUserDao
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, OfBizServiceAccountDao serviceAccountDao)
-
-
Method Details
-
delegate
-
useFullCache
public boolean useFullCache()- Specified by:
useFullCache
in interfaceExtendedUserDao
-
useInternedUserValues
public boolean useInternedUserValues()- Specified by:
useInternedUserValues
in interfaceExtendedUserDao
-
getUniqueUserCount
public long getUniqueUserCount(Set<Long> directoryIds) throws com.atlassian.crowd.exception.DirectoryNotFoundException - Specified by:
getUniqueUserCount
in interfaceExtendedUserDao
- Throws:
com.atlassian.crowd.exception.DirectoryNotFoundException
-
findNamesOfUsersInGroups
Description copied from interface:ExtendedUserDao
Returns the lower-cased names of all users in the specified groups. Only searches directly in these groups, if a recursive group search is required the caller will need to pre-expand the groups.- Specified by:
findNamesOfUsersInGroups
in interfaceExtendedUserDao
- Parameters:
groupNames
- the names of the groups to search.- Returns:
- set of all user names in these groups, in lower case.
-
getAllAttributeKeys
- Specified by:
getAllAttributeKeys
in interfaceExtendedUserDao
-
processUsers
Description copied from interface:ExtendedUserDao
Performs an operation on every user in the system.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.- Specified by:
processUsers
in interfaceExtendedUserDao
- Parameters:
userProcessor
- the operation to perform on each user.
-
flushCache
public void flushCache()Description copied from interface:ExtendedUserDao
Invoked byOfBizCacheFlushingManager
to ensure caches are being flushed in the right order onXMLRestoreFinishedEvent
- Specified by:
flushCache
in interfaceExtendedUserDao
-
findByName
public com.atlassian.crowd.model.user.TimestampedUser findByName(long directoryId, String userName) throws com.atlassian.crowd.exception.UserNotFoundException - Specified by:
findByName
in interfacecom.atlassian.crowd.embedded.spi.UserDao
- Throws:
com.atlassian.crowd.exception.UserNotFoundException
-
findByExternalId
public com.atlassian.crowd.model.user.TimestampedUser findByExternalId(long directoryId, String externalId) throws com.atlassian.crowd.exception.UserNotFoundException - Specified by:
findByExternalId
in interfacecom.atlassian.crowd.embedded.spi.UserDao
- Throws:
com.atlassian.crowd.exception.UserNotFoundException
-
findByNameWithAttributes
public com.atlassian.crowd.model.user.UserWithAttributes findByNameWithAttributes(long directoryId, String userName) throws com.atlassian.crowd.exception.UserNotFoundException - Specified by:
findByNameWithAttributes
in interfacecom.atlassian.crowd.embedded.spi.UserDao
- Throws:
com.atlassian.crowd.exception.UserNotFoundException
-
getCredential
public com.atlassian.crowd.embedded.api.PasswordCredential getCredential(long directoryId, String userName) throws com.atlassian.crowd.exception.UserNotFoundException - Specified by:
getCredential
in interfacecom.atlassian.crowd.embedded.spi.UserDao
- Throws:
com.atlassian.crowd.exception.UserNotFoundException
-
getCredentialHistory
public List<com.atlassian.crowd.embedded.api.PasswordCredential> getCredentialHistory(long directoryId, String userName) throws com.atlassian.crowd.exception.UserNotFoundException - Specified by:
getCredentialHistory
in interfacecom.atlassian.crowd.embedded.spi.UserDao
- Throws:
com.atlassian.crowd.exception.UserNotFoundException
-
add
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 - Specified by:
add
in interfacecom.atlassian.crowd.embedded.spi.UserDao
- Throws:
com.atlassian.crowd.exception.UserAlreadyExistsException
IllegalArgumentException
com.atlassian.crowd.exception.DirectoryNotFoundException
-
update
public com.atlassian.crowd.model.user.User update(com.atlassian.crowd.model.user.User user) throws com.atlassian.crowd.exception.UserNotFoundException, IllegalArgumentException - Specified by:
update
in interfacecom.atlassian.crowd.embedded.spi.UserDao
- Throws:
com.atlassian.crowd.exception.UserNotFoundException
IllegalArgumentException
-
updateCredential
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 - Specified by:
updateCredential
in interfacecom.atlassian.crowd.embedded.spi.UserDao
- Throws:
com.atlassian.crowd.exception.UserNotFoundException
IllegalArgumentException
-
rename
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 - Specified by:
rename
in interfacecom.atlassian.crowd.embedded.spi.UserDao
- Throws:
com.atlassian.crowd.exception.UserNotFoundException
com.atlassian.crowd.exception.UserAlreadyExistsException
IllegalArgumentException
-
removeAttribute
public void removeAttribute(com.atlassian.crowd.model.user.User user, String attributeName) throws com.atlassian.crowd.exception.UserNotFoundException - Specified by:
removeAttribute
in interfacecom.atlassian.crowd.embedded.spi.UserDao
- Throws:
com.atlassian.crowd.exception.UserNotFoundException
-
remove
public void remove(com.atlassian.crowd.model.user.User user) throws com.atlassian.crowd.exception.UserNotFoundException - Specified by:
remove
in interfacecom.atlassian.crowd.embedded.spi.UserDao
- Throws:
com.atlassian.crowd.exception.UserNotFoundException
-
search
public <T> List<T> search(long directoryId, com.atlassian.crowd.search.query.entity.EntityQuery<T> query) - Specified by:
search
in interfacecom.atlassian.crowd.embedded.spi.UserDao
-
addAll
public com.atlassian.crowd.util.BatchResult<com.atlassian.crowd.model.user.User> addAll(Set<com.atlassian.crowd.model.user.UserTemplateWithCredentialAndAttributes> users) - Specified by:
addAll
in interfacecom.atlassian.crowd.embedded.spi.UserDao
-
removeAllUsers
public com.atlassian.crowd.util.BatchResult<String> removeAllUsers(long directoryId, Set<String> userNames) - Specified by:
removeAllUsers
in interfacecom.atlassian.crowd.embedded.spi.UserDao
-
setAttributeForAllInDirectory
- Specified by:
setAttributeForAllInDirectory
in interfacecom.atlassian.crowd.embedded.spi.UserDao
-
findOfBizUser
- Specified by:
findOfBizUser
in interfaceExtendedUserDao
- Throws:
UserNotFoundException
-
findAllByNameOrNull
- Specified by:
findAllByNameOrNull
in interfaceExtendedUserDao
-
findByNameOrNull
Description copied from interface:ExtendedUserDao
Tries to find the user by name and returns null if not found. Just like the public method should have done in the first place!- Specified by:
findByNameOrNull
in interfaceExtendedUserDao
- Parameters:
directoryId
- Directory IDuserName
- the username- Returns:
- the user, or
null
if the user does not exist
-
getAllExternalIds
public Set<String> getAllExternalIds(long directoryId) throws com.atlassian.crowd.exception.DirectoryNotFoundException - Specified by:
getAllExternalIds
in interfacecom.atlassian.crowd.embedded.spi.UserDao
- Throws:
com.atlassian.crowd.exception.DirectoryNotFoundException
-
getUserCount
public long getUserCount(long directoryId) throws com.atlassian.crowd.exception.DirectoryNotFoundException - Specified by:
getUserCount
in interfacecom.atlassian.crowd.embedded.spi.UserDao
- Throws:
com.atlassian.crowd.exception.DirectoryNotFoundException
-
findById
Description copied from interface:ExtendedUserDao
Finds a user by internal user ID.- Specified by:
findById
in interfaceExtendedUserDao
- Parameters:
internalUserId
- the user ID.- Returns:
- the found user, or null if not found.
-
isDeletedExternally
public boolean isDeletedExternally(long internalUserId) Description copied from interface:ExtendedUserDao
Checks if user (identified by internal user ID) has been deleted from external user directory.- Specified by:
isDeletedExternally
in interfaceExtendedUserDao
- Parameters:
internalUserId
- the user ID.- Returns:
- true if user has been deleted from external directory, false otherwise.
-
isDeletedExternally
Description copied from interface:ExtendedUserDao
Checks if user (identified by directory ID and user name) has been deleted from external user directory.- Specified by:
isDeletedExternally
in interfaceExtendedUserDao
- Parameters:
directoryId
- Directory IDuserName
- the username- Returns:
- true if user has been deleted from external directory, false otherwise.
-
update
public com.atlassian.crowd.model.user.User update(com.atlassian.crowd.model.user.User user, boolean useJiraExtensions) throws UserNotFoundException Description copied from interface:ExtendedUserDao
Updates user, for detailed description seeUserDao.update(com.atlassian.crowd.model.user.User)
.- Specified by:
update
in interfaceExtendedUserDao
- Parameters:
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.- Returns:
- the updated user
- Throws:
UserNotFoundException
- if there is no user with the same name (case-insensitive) and directory as the user provided- See Also:
-
storeAttributes
public void storeAttributes(com.atlassian.crowd.model.user.User user, Map<String, Set<String>> attributes, boolean updateTimestamp) throws com.atlassian.crowd.exception.UserNotFoundException- Specified by:
storeAttributes
in interfacecom.atlassian.crowd.embedded.spi.UserDao
- Throws:
com.atlassian.crowd.exception.UserNotFoundException
-
findDirectoryIdsContainingUserName
- Specified by:
findDirectoryIdsContainingUserName
in interfacecom.atlassian.crowd.embedded.spi.UserDao
-
findByExternalIds
- Specified by:
findByExternalIds
in interfacecom.atlassian.crowd.embedded.spi.UserDao
-