Class OfBizUserDao

java.lang.Object
com.atlassian.jira.crowd.embedded.ofbiz.OfBizUserDao
All Implemented Interfaces:
com.atlassian.crowd.embedded.spi.UserDao, ExtendedUserDao

public class OfBizUserDao extends Object implements ExtendedUserDao
Implementation of the user DAO that works with OfBiz
  • Constructor Details

  • Method Details

    • onBeforeUserAuthenticate

      @EventListener public void onBeforeUserAuthenticate(BeforeUserAuthenticate beforeUserAuthenticate)
    • findByLoginInDb

      @Nonnull public List<OfBizUser> findByLoginInDb(String username)
    • useFullCache

      public boolean useFullCache()
      Specified by:
      useFullCache in interface ExtendedUserDao
    • useInternedUserValues

      public boolean useInternedUserValues()
      Specified by:
      useInternedUserValues in interface ExtendedUserDao
    • findByName

      @Nonnull public com.atlassian.crowd.model.user.TimestampedUser findByName(long directoryId, String userName) throws UserNotFoundException
      Specified by:
      findByName in interface com.atlassian.crowd.embedded.spi.UserDao
      Throws:
      UserNotFoundException
    • findOfBizUser

      @Nonnull public OfBizUser findOfBizUser(long directoryId, String userName) throws UserNotFoundException
      Specified by:
      findOfBizUser in interface ExtendedUserDao
      Throws:
      UserNotFoundException
    • findByNameOrNull

      @Nullable public OfBizUser findByNameOrNull(long directoryId, @Nonnull String userName)
      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 interface ExtendedUserDao
      Parameters:
      directoryId - Directory ID
      userName - the username
      Returns:
      the user, or null if the user does not exist
    • findAllByNameOrNull

      @Nonnull public List<OfBizUser> findAllByNameOrNull(long directoryId, @Nonnull Collection<String> userNames)
      Specified by:
      findAllByNameOrNull in interface ExtendedUserDao
    • findDirectoryIdsContainingUserName

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

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

      @Nonnull public OfBizUser findByExternalId(long directoryId, String externalId) throws UserNotFoundException
      Specified by:
      findByExternalId in interface com.atlassian.crowd.embedded.spi.UserDao
      Throws:
      UserNotFoundException
    • findById

      @Nullable public OfBizUser findById(long internalUserId)
      Description copied from interface: ExtendedUserDao
      Finds a user by internal user ID.
      Specified by:
      findById in interface ExtendedUserDao
      Parameters:
      internalUserId - the user ID.
      Returns:
      the found user, or null if not found.
    • findByNameWithAttributes

      @Nonnull public com.atlassian.crowd.model.user.UserWithAttributes findByNameWithAttributes(long directoryId, String userName) throws UserNotFoundException
      Specified by:
      findByNameWithAttributes in interface com.atlassian.crowd.embedded.spi.UserDao
      Throws:
      UserNotFoundException
    • getCredential

      @Nullable public com.atlassian.crowd.embedded.api.PasswordCredential getCredential(long directoryId, String userName) throws UserNotFoundException
      Specified by:
      getCredential in interface com.atlassian.crowd.embedded.spi.UserDao
      Throws:
      UserNotFoundException
    • getCredentialHistory

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

      @Nonnull 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
    • storeAttributes

      public void storeAttributes(com.atlassian.crowd.model.user.User user, Map<String,Set<String>> attributes, boolean updateTimestamp) throws UserNotFoundException
      Specified by:
      storeAttributes in interface com.atlassian.crowd.embedded.spi.UserDao
      Throws:
      UserNotFoundException
    • setAttributeForAllInDirectory

      public void setAttributeForAllInDirectory(long directoryId, String attrName, String attrValue)
      Specified by:
      setAttributeForAllInDirectory 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 UserNotFoundException
      Specified by:
      update in interface com.atlassian.crowd.embedded.spi.UserDao
      Throws:
      UserNotFoundException
    • 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 see UserDao.update(com.atlassian.crowd.model.user.User).
      Specified by:
      update in interface ExtendedUserDao
      Parameters:
      user - the user details, which should have the same name as the user to modify
      useJiraExtensions - 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:
      • UserDao.update(com.atlassian.crowd.model.user.User)
    • updateCredential

      public void updateCredential(com.atlassian.crowd.model.user.User user, com.atlassian.crowd.embedded.api.PasswordCredential credential, int credentialHistory) throws UserNotFoundException
      Specified by:
      updateCredential in interface com.atlassian.crowd.embedded.spi.UserDao
      Throws:
      UserNotFoundException
    • rename

      public com.atlassian.crowd.model.user.User rename(com.atlassian.crowd.model.user.User oldUser, String newName) throws UserNotFoundException
      Specified by:
      rename in interface com.atlassian.crowd.embedded.spi.UserDao
      Throws:
      UserNotFoundException
    • updateGroupMembership

      protected void updateGroupMembership(long directoryId, String oldName, String newName)
    • 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
    • getAllExternalIds

      public Set<String> getAllExternalIds(long directoryId) throws com.atlassian.crowd.exception.DirectoryNotFoundException
      Specified by:
      getAllExternalIds in interface com.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 interface com.atlassian.crowd.embedded.spi.UserDao
      Throws:
      com.atlassian.crowd.exception.DirectoryNotFoundException
    • getUniqueUserCount

      public long getUniqueUserCount(Set<Long> directoryIds) throws com.atlassian.crowd.exception.DirectoryNotFoundException
      Specified by:
      getUniqueUserCount in interface ExtendedUserDao
      Throws:
      com.atlassian.crowd.exception.DirectoryNotFoundException
    • removeAttribute

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

      public void remove(com.atlassian.crowd.model.user.User user) throws UserNotFoundException
      Specified by:
      remove in interface com.atlassian.crowd.embedded.spi.UserDao
      Throws:
      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
    • findNamesOfUsersInGroups

      public Collection<String> findNamesOfUsersInGroups(Collection<String> groupNames)
      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 interface ExtendedUserDao
      Parameters:
      groupNames - the names of the groups to search.
      Returns:
      set of all user names in these groups, in lower case.
    • getAllAttributeKeys

      public Collection<String> getAllAttributeKeys()
      Specified by:
      getAllAttributeKeys in interface ExtendedUserDao
    • processUsers

      public void processUsers(Consumer<? super com.atlassian.crowd.model.user.User> userProcessor)
      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 interface ExtendedUserDao
      Parameters:
      userProcessor - the operation to perform on each user.
    • 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 interface ExtendedUserDao
      Parameters:
      internalUserId - the user ID.
      Returns:
      true if user has been deleted from external directory, false otherwise.
    • isDeletedExternally

      public boolean isDeletedExternally(long directoryId, @Nonnull String userName)
      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 interface ExtendedUserDao
      Parameters:
      directoryId - Directory ID
      userName - the username
      Returns:
      true if user has been deleted from external directory, false otherwise.
    • flushCache

      public void flushCache()
      Description copied from interface: ExtendedUserDao
      Invoked by OfBizCacheFlushingManager to ensure caches are being flushed in the right order on XMLRestoreFinishedEvent
      Specified by:
      flushCache in interface ExtendedUserDao