Class HibernateUserDao

java.lang.Object
com.atlassian.confluence.impl.user.crowd.hibernate.HibernateUserDao
All Implemented Interfaces:
InternalUserDao<com.atlassian.crowd.model.user.InternalUser>, com.atlassian.crowd.embedded.spi.UserDao

public final class HibernateUserDao extends Object implements InternalUserDao<com.atlassian.crowd.model.user.InternalUser>
Implementation of UserDao which uses Hibernate 5.
Since:
7.20.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    HibernateUserDao(org.hibernate.SessionFactory sessionFactory, Supplier<com.atlassian.crowd.embedded.spi.DirectoryDao> directoryDao, InternalMembershipDao membershipDao, ConfluenceUserDao confluenceUserDao, com.atlassian.crowd.util.persistence.hibernate.batch.BatchProcessor<org.hibernate.Session> batchProcessor, com.atlassian.crowd.util.persistence.hibernate.batch.BatchFinder batchFinder, BatchOperationManager batchOperationManager)
     
  • Method Summary

    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)
     
    com.atlassian.crowd.model.user.TimestampedUser
    findByExternalId(long directoryId, String externalId)
     
    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 usernames
    com.atlassian.crowd.model.user.UserWithAttributes
    findByNameWithAttributes(long directoryId, String userName)
     
     
    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 username
    com.atlassian.crowd.model.user.InternalUser
    internalFindByUser(com.atlassian.crowd.model.user.User user)
    Find the persistent user object that corresponds to the provided user.
    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)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HibernateUserDao

      public HibernateUserDao(org.hibernate.SessionFactory sessionFactory, Supplier<com.atlassian.crowd.embedded.spi.DirectoryDao> directoryDao, InternalMembershipDao membershipDao, ConfluenceUserDao confluenceUserDao, com.atlassian.crowd.util.persistence.hibernate.batch.BatchProcessor<org.hibernate.Session> batchProcessor, com.atlassian.crowd.util.persistence.hibernate.batch.BatchFinder batchFinder, BatchOperationManager batchOperationManager)
  • Method Details

    • remove

      public void remove(com.atlassian.crowd.model.user.User user) throws com.atlassian.crowd.exception.UserNotFoundException
      Specified by:
      remove in interface com.atlassian.crowd.embedded.spi.UserDao
      Throws:
      com.atlassian.crowd.exception.UserNotFoundException
    • removeAttribute

      public void removeAttribute(com.atlassian.crowd.model.user.User user, String attributeName) throws com.atlassian.crowd.exception.UserNotFoundException
      Specified by:
      removeAttribute in interface com.atlassian.crowd.embedded.spi.UserDao
      Throws:
      com.atlassian.crowd.exception.UserNotFoundException
    • 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
      Specified by:
      rename in interface com.atlassian.crowd.embedded.spi.UserDao
      Throws:
      com.atlassian.crowd.exception.UserNotFoundException
      com.atlassian.crowd.exception.UserAlreadyExistsException
    • 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 interface InternalUserDao<com.atlassian.crowd.model.user.InternalUser>
      Throws:
      com.atlassian.crowd.exception.UserNotFoundException
    • removeAllUsers

      public com.atlassian.crowd.util.BatchResult<String> removeAllUsers(long directoryId, Set<String> userNames)
      Specified by:
      removeAllUsers in interface com.atlassian.crowd.embedded.spi.UserDao
    • 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 interface InternalUserDao<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 interface InternalUserDao<com.atlassian.crowd.model.user.InternalUser>
      Returns:
    • 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
      Specified by:
      updateCredential in interface com.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 interface com.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 interface com.atlassian.crowd.embedded.spi.UserDao
    • update

      public com.atlassian.crowd.model.user.User update(com.atlassian.crowd.model.user.User user) throws com.atlassian.crowd.exception.UserNotFoundException
      Specified by:
      update in interface com.atlassian.crowd.embedded.spi.UserDao
      Throws:
      com.atlassian.crowd.exception.UserNotFoundException
    • 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 interface com.atlassian.crowd.embedded.spi.UserDao
      Throws:
      com.atlassian.crowd.exception.UserNotFoundException
    • 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 interface InternalUserDao<com.atlassian.crowd.model.user.InternalUser>
      Specified by:
      add in interface com.atlassian.crowd.embedded.spi.UserDao
      Throws:
      com.atlassian.crowd.exception.UserAlreadyExistsException
      IllegalArgumentException
      com.atlassian.crowd.exception.DirectoryNotFoundException
    • getCredentialHistory

      public List<com.atlassian.crowd.embedded.api.PasswordCredential> getCredentialHistory(long directoryId, String userName) throws com.atlassian.crowd.exception.UserNotFoundException
      Specified by:
      getCredentialHistory in interface com.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 interface com.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 interface com.atlassian.crowd.embedded.spi.UserDao
      Throws:
      com.atlassian.crowd.exception.UserNotFoundException
    • findByName

      public com.atlassian.crowd.model.user.TimestampedUser findByName(long directoryId, String userName) throws com.atlassian.crowd.exception.UserNotFoundException
      Specified by:
      findByName in interface com.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 interface com.atlassian.crowd.embedded.spi.UserDao
      Throws:
      com.atlassian.crowd.exception.UserNotFoundException
    • 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 interface InternalUserDao<com.atlassian.crowd.model.user.InternalUser>
      Throws:
      com.atlassian.crowd.exception.UserNotFoundException - if the user is not found
    • setAttributeForAllInDirectory

      public void setAttributeForAllInDirectory(long directoryId, String attrName, String attrValue)
      Specified by:
      setAttributeForAllInDirectory in interface com.atlassian.crowd.embedded.spi.UserDao
    • getAllExternalIds

      public Set<String> getAllExternalIds(long directoryId)
      Specified by:
      getAllExternalIds in interface com.atlassian.crowd.embedded.spi.UserDao
    • getUserCount

      public long getUserCount(long directoryId)
      Specified by:
      getUserCount in interface com.atlassian.crowd.embedded.spi.UserDao
    • findDirectoryIdsContainingUserName

      public Set<Long> findDirectoryIdsContainingUserName(String username)
      Specified by:
      findDirectoryIdsContainingUserName in interface com.atlassian.crowd.embedded.spi.UserDao
    • findByExternalIds

      public Map<String,String> findByExternalIds(long directoryId, Set<String> externalIds)
      Specified by:
      findByExternalIds in interface com.atlassian.crowd.embedded.spi.UserDao