Class CachedCrowdUserDao
- java.lang.Object
-
- com.atlassian.confluence.impl.user.crowd.CachedCrowdUserDao
-
- All Implemented Interfaces:
UserPrefetcher.PrefetchDao
,InternalUserDao<com.atlassian.crowd.model.user.InternalUser>
,com.atlassian.crowd.embedded.spi.UserDao
,org.springframework.beans.factory.InitializingBean
public class CachedCrowdUserDao extends Object implements InternalUserDao<com.atlassian.crowd.model.user.InternalUser>, org.springframework.beans.factory.InitializingBean, UserPrefetcher.PrefetchDao
A caching decorator for an InternalUserDao.
-
-
Constructor Summary
Constructors Constructor Description CachedCrowdUserDao(InternalUserDao<com.atlassian.crowd.model.user.InternalUser> delegate, TransactionAwareCacheFactory txCacheFactory, com.atlassian.cache.CacheFactory nonTxCacheFactory, com.atlassian.event.api.EventPublisher eventPublisher)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.atlassian.crowd.model.user.InternalUser
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)
Removes all the adding users from the cache if they exist and delegates to the addAll method of the delegate DAO.void
afterPropertiesSet()
com.atlassian.crowd.model.user.TimestampedUser
findByExternalId(long directoryId, String externalId)
Map<String,String>
findByExternalIds(long directoryId, Set<String> externalIds)
com.atlassian.crowd.model.user.TimestampedUser
findByName(long directoryId, String userName)
Collection<com.atlassian.crowd.model.user.InternalUser>
findByNames(long directoryId, Collection<String> userNames)
Find all users from the list of usernamescom.atlassian.crowd.model.user.UserWithAttributes
findByNameWithAttributes(long directoryId, String userName)
Set<Long>
findDirectoryIdsContainingUserName(String username)
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
getUserCount(long directoryId)
com.atlassian.crowd.model.user.InternalUser
internalFindByName(long directoryId, String userName)
Find a persistent user object from a given directory and usernamecom.atlassian.crowd.model.user.InternalUser
internalFindByUser(com.atlassian.crowd.model.user.User user)
Find the persistent user object that corresponds to the provided user.int
prefetchAndCacheUsers(long directoryId, Collection<String> usernames)
Provides an implementation ofUserPrefetcher.PrefetchDao
for optimised prefetch and caching of multiple users at once.void
remove(com.atlassian.crowd.model.user.User user)
void
removeAllUsers(long directoryId)
Remove all users from a particular directory (used when deleting an internal directory)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)
void
updateCredential(com.atlassian.crowd.model.user.User user, com.atlassian.crowd.embedded.api.PasswordCredential credential, int maxCredentialHistory)
-
-
-
Constructor Detail
-
CachedCrowdUserDao
public CachedCrowdUserDao(InternalUserDao<com.atlassian.crowd.model.user.InternalUser> delegate, TransactionAwareCacheFactory txCacheFactory, com.atlassian.cache.CacheFactory nonTxCacheFactory, com.atlassian.event.api.EventPublisher eventPublisher)
- Since:
- 7.5
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet() throws Exception
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
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
-
addAll
public com.atlassian.crowd.util.BatchResult<com.atlassian.crowd.model.user.User> addAll(Set<com.atlassian.crowd.model.user.UserTemplateWithCredentialAndAttributes> users)
Removes all the adding users from the cache if they exist and delegates to the addAll method of the delegate DAO.This method will not try and update the cache like
add(User, PasswordCredential)
because:- We want to delegate to the "addAll" method on the delegate as its the fastest way to add a large number of users, we can't just delegate to add method
- Unlike the add method, we don't get a reference to the added user so we can't reliably update the cache, so we just remove it.
- Specified by:
addAll
in interfacecom.atlassian.crowd.embedded.spi.UserDao
- Parameters:
users
- the users to add- Returns:
- a BatchResult describing the result
-
add
public com.atlassian.crowd.model.user.InternalUser 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 interfaceInternalUserDao<com.atlassian.crowd.model.user.InternalUser>
- Specified by:
add
in interfacecom.atlassian.crowd.embedded.spi.UserDao
- Throws:
com.atlassian.crowd.exception.UserAlreadyExistsException
IllegalArgumentException
com.atlassian.crowd.exception.DirectoryNotFoundException
-
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
-
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
-
internalFindByName
public com.atlassian.crowd.model.user.InternalUser internalFindByName(long directoryId, String userName) throws com.atlassian.crowd.exception.UserNotFoundException
Description copied from interface:InternalUserDao
Find a persistent user object from a given directory and username- Specified by:
internalFindByName
in interfaceInternalUserDao<com.atlassian.crowd.model.user.InternalUser>
- Throws:
com.atlassian.crowd.exception.UserNotFoundException
-
internalFindByUser
public com.atlassian.crowd.model.user.InternalUser internalFindByUser(com.atlassian.crowd.model.user.User user) throws com.atlassian.crowd.exception.UserNotFoundException
Description copied from interface:InternalUserDao
Find the persistent user object that corresponds to the provided user.- Specified by:
internalFindByUser
in interfaceInternalUserDao<com.atlassian.crowd.model.user.InternalUser>
- Throws:
com.atlassian.crowd.exception.UserNotFoundException
-
removeAllUsers
public void removeAllUsers(long directoryId)
Description copied from interface:InternalUserDao
Remove all users from a particular directory (used when deleting an internal directory)- Specified by:
removeAllUsers
in interfaceInternalUserDao<com.atlassian.crowd.model.user.InternalUser>
-
findByNames
public Collection<com.atlassian.crowd.model.user.InternalUser> findByNames(long directoryId, Collection<String> userNames)
Description copied from interface:InternalUserDao
Find all users from the list of usernames- Specified by:
findByNames
in interfaceInternalUserDao<com.atlassian.crowd.model.user.InternalUser>
- Returns:
-
prefetchAndCacheUsers
public int prefetchAndCacheUsers(long directoryId, Collection<String> usernames)
Provides an implementation ofUserPrefetcher.PrefetchDao
for optimised prefetch and caching of multiple users at once.- Specified by:
prefetchAndCacheUsers
in interfaceUserPrefetcher.PrefetchDao
- Returns:
- the number of users that were prefetched, either from the cache or database
- See Also:
UserPrefetcher
-
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
public void setAttributeForAllInDirectory(long directoryId, String attrName, String attrValue)
- Specified by:
setAttributeForAllInDirectory
in interfacecom.atlassian.crowd.embedded.spi.UserDao
-
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
-
findDirectoryIdsContainingUserName
public Set<Long> findDirectoryIdsContainingUserName(String username)
- Specified by:
findDirectoryIdsContainingUserName
in interfacecom.atlassian.crowd.embedded.spi.UserDao
-
-