com.atlassian.crowd.dao.user
Class UserDAOHibernate

java.lang.Object
  extended by org.springframework.dao.support.DaoSupport
      extended by org.springframework.orm.hibernate3.support.HibernateDaoSupport
          extended by com.atlassian.crowd.util.persistence.hibernate.HibernateDao
              extended by com.atlassian.crowd.dao.user.UserDAOHibernate
All Implemented Interfaces:
InternalUserDao, UserDao, org.springframework.beans.factory.InitializingBean

public class UserDAOHibernate
extends HibernateDao
implements InternalUserDao, UserDao


Field Summary
 
Fields inherited from class com.atlassian.crowd.util.persistence.hibernate.HibernateDao
batchFinder, batchProcessor, logger
 
Constructor Summary
UserDAOHibernate()
           
 
Method Summary
 InternalUser add(User user, PasswordCredential credential)
          Creates a new user with the given details and credentials.
 BatchResultWithIdReferences<User> addAll(java.util.Collection<UserTemplateWithCredentialAndAttributes> users)
           
 BatchResult<User> addAll(java.util.Set<UserTemplateWithCredentialAndAttributes> users)
          Bulk add of users using JDBC batch support.
 InternalUser findByName(long directoryId, java.lang.String username)
          Finds and returns the user with the given name and directory ID.
 java.util.Collection<InternalUser> findByNames(long directoryID, java.util.Collection<java.lang.String> usernames)
          Bulk find of users using SQL disjunction.
 InternalUserWithAttributes findByNameWithAttributes(long directoryId, java.lang.String username)
          Finds and returns the user with attributes with the given name and directory ID.
 java.util.Set<InternalUserAttribute> findUserAttributes(long userID)
           
 PasswordCredential getCredential(long directoryId, java.lang.String username)
          Returns the credential for the given user.
 java.util.List<PasswordCredential> getCredentialHistory(long directoryId, java.lang.String username)
          Returns the previous credentials for the given user, starting with the oldest.
 java.lang.Class getPersistentClass()
          All subclasses of HibernateDAO must implement this method for HibernateDao.load(long) to work correctly
 void remove(User user)
          Removes the user.
 void removeAll(long directoryId)
           
 void removeAllUsers(long directoryId, java.util.Set<java.lang.String> userNames)
           
 void removeAttribute(User user, java.lang.String attributeName)
          Removes the attributes for the user with the given name.
 InternalUser rename(User user, java.lang.String newUsername)
          Changes the user's name to the provided new name.
<T> java.util.List<T>
search(long directoryID, EntityQuery<T> query)
          Returns users matching the search query in the given directory, ordered by name.
 void setDirectoryDAO(DirectoryDAOHibernate directoryDAO)
           
 void setHqlQueryTranslater(HQLQueryTranslater hqlQueryTranslater)
           
 void setInternalAttributesHelper(InternalAttributesHelper internalAttributesHelper)
           
 void setMembershipDAO(InternalMembershipDao internalMembershipDao)
           
 void storeAttributes(User user, java.util.Map<java.lang.String,java.util.Set<java.lang.String>> attributes)
          Adds or updates a user's attributes with the new Map of attribute values.
 InternalUser update(User user)
          Updates all the user properties of the user with the same directory and case-insensitive name.
 void updateCredential(User user, PasswordCredential credential, int maxPasswordHistory)
          Updates the credential (password) of the user with the same directory and case-insensitive name.
 
Methods inherited from class com.atlassian.crowd.util.persistence.hibernate.HibernateDao
load, loadReference, remove, save, saveOrUpdate, setBatchFinder, setBatchProcessor, update
 
Methods inherited from class org.springframework.orm.hibernate3.support.HibernateDaoSupport
checkDaoConfig, convertHibernateAccessException, createHibernateTemplate, getHibernateTemplate, getSession, getSession, getSessionFactory, releaseSession, setHibernateTemplate, setSessionFactory
 
Methods inherited from class org.springframework.dao.support.DaoSupport
afterPropertiesSet, initDao
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserDAOHibernate

public UserDAOHibernate()
Method Detail

getPersistentClass

public java.lang.Class getPersistentClass()
Description copied from class: HibernateDao
All subclasses of HibernateDAO must implement this method for HibernateDao.load(long) to work correctly

Specified by:
getPersistentClass in class HibernateDao
Returns:
Class

findByName

public InternalUser findByName(long directoryId,
                               java.lang.String username)
                        throws UserNotFoundException
Description copied from interface: UserDao
Finds and returns the user with the given name and directory ID.

Specified by:
findByName in interface UserDao
Throws:
UserNotFoundException - if the user could not be found

getCredential

public PasswordCredential getCredential(long directoryId,
                                        java.lang.String username)
                                 throws UserNotFoundException
Description copied from interface: UserDao
Returns the credential for the given user. It will always be encrypted.

Specified by:
getCredential in interface UserDao
Throws:
UserNotFoundException - if the user could not be found

getCredentialHistory

public java.util.List<PasswordCredential> getCredentialHistory(long directoryId,
                                                               java.lang.String username)
                                                        throws UserNotFoundException
Description copied from interface: UserDao
Returns the previous credentials for the given user, starting with the oldest. May be an empty list if there are no historical credentials.

Specified by:
getCredentialHistory in interface UserDao
Throws:
UserNotFoundException - if the user could not be found

findByNameWithAttributes

public InternalUserWithAttributes findByNameWithAttributes(long directoryId,
                                                           java.lang.String username)
                                                    throws UserNotFoundException
Description copied from interface: UserDao
Finds and returns the user with attributes with the given name and directory ID.

Specified by:
findByNameWithAttributes in interface UserDao
Throws:
UserNotFoundException - if the user could not be found

findUserAttributes

public java.util.Set<InternalUserAttribute> findUserAttributes(long userID)

add

public InternalUser add(User user,
                        PasswordCredential credential)
                 throws DirectoryNotFoundException
Description copied from interface: UserDao
Creates a new user with the given details and credentials. The user details cannot be null, but the credential can be.

Specified by:
add in interface UserDao
Parameters:
user - the user to create
credential - the encrypted password for the user, which may be null if the user's password is not yet available
Returns:
the newly created user
Throws:
DirectoryNotFoundException

update

public InternalUser update(User user)
                    throws UserNotFoundException
Description copied from interface: UserDao
Updates all the user properties of the user with the same directory and case-insensitive name.

Specified by:
update in interface UserDao
Parameters:
user - the user details, which should have the same name as the user to modify
Returns:
the updated user
Throws:
UserNotFoundException - if there is no user with the same name (case-insensitive) and directory as the user provided

updateCredential

public void updateCredential(User user,
                             PasswordCredential credential,
                             int maxPasswordHistory)
                      throws UserNotFoundException
Description copied from interface: UserDao
Updates the credential (password) of the user with the same directory and case-insensitive name. The credential must be encrypted.

Specified by:
updateCredential in interface UserDao
Parameters:
user - the user whose password will be modified
Throws:
UserNotFoundException - if there is no user with the same name (case-insensitive) and directory as the user provided

rename

public InternalUser rename(User user,
                           java.lang.String newUsername)
                    throws UserNotFoundException
Description copied from interface: UserDao
Changes the user's name to the provided new name.

Specified by:
rename in interface UserDao
Parameters:
user - the user to rename
newUsername - the new name of the user
Returns:
the updated user
Throws:
UserNotFoundException - if the user cannot be found

remove

public void remove(User user)
            throws UserNotFoundException
Description copied from interface: UserDao
Removes the user.

Specified by:
remove in interface UserDao
Parameters:
user - the user to remove
Throws:
UserNotFoundException - if the user does not exist

removeAll

public void removeAll(long directoryId)
Specified by:
removeAll in interface InternalUserDao

storeAttributes

public void storeAttributes(User user,
                            java.util.Map<java.lang.String,java.util.Set<java.lang.String>> attributes)
                     throws UserNotFoundException
Description copied from interface: UserDao
Adds or updates a user's attributes with the new Map of attribute values. The attributes map represents new or updated attributes and does not replace existing attributes unless the key of an attribute matches the key of an existing attribute. Attributes with values of empty sets in the attributes parameter are removed from the user.

Specified by:
storeAttributes in interface UserDao
Parameters:
user - the user to store attributes for
attributes - new or updated attributes (attributes that don't need changing should not appear in this Map).
Throws:
UserNotFoundException - user with supplied username does not exist.

removeAttribute

public void removeAttribute(User user,
                            java.lang.String attributeName)
                     throws UserNotFoundException
Description copied from interface: UserDao
Removes the attributes for the user with the given name. Does nothing if the attribute doesn't exist.

Specified by:
removeAttribute in interface UserDao
Parameters:
user - the user whose attribute will be removed
attributeName - the name of the attribute to be removed
Throws:
UserNotFoundException - if the user cannot be found

search

public <T> java.util.List<T> search(long directoryID,
                                    EntityQuery<T> query)
Description copied from interface: UserDao
Returns users matching the search query in the given directory, ordered by name. Returns an empty list if no users match.

Specified by:
search in interface UserDao
Type Parameters:
T - the type of objects to return, which is normally either User or String
Parameters:
directoryID - the ID of the directory to search
query - the search query
Returns:
the list of matching users, or an empty list if no users match

addAll

public BatchResult<User> addAll(java.util.Set<UserTemplateWithCredentialAndAttributes> users)
Description copied from interface: UserDao
Bulk add of users using JDBC batch support.

Specified by:
addAll in interface UserDao
Parameters:
users - to be added
Returns:
a list of Users that failed to be added

removeAllUsers

public void removeAllUsers(long directoryId,
                           java.util.Set<java.lang.String> userNames)
Specified by:
removeAllUsers in interface UserDao

addAll

public BatchResultWithIdReferences<User> addAll(java.util.Collection<UserTemplateWithCredentialAndAttributes> users)
Specified by:
addAll in interface InternalUserDao

findByNames

public java.util.Collection<InternalUser> findByNames(long directoryID,
                                                      java.util.Collection<java.lang.String> usernames)
Description copied from interface: InternalUserDao
Bulk find of users using SQL disjunction.

Specified by:
findByNames in interface InternalUserDao
Parameters:
directoryID - the directory to search for the users.
usernames - names of users to find
Returns:
collection of found users.

setDirectoryDAO

public void setDirectoryDAO(DirectoryDAOHibernate directoryDAO)

setMembershipDAO

public void setMembershipDAO(InternalMembershipDao internalMembershipDao)

setHqlQueryTranslater

public void setHqlQueryTranslater(HQLQueryTranslater hqlQueryTranslater)

setInternalAttributesHelper

public void setInternalAttributesHelper(InternalAttributesHelper internalAttributesHelper)


Copyright © 2010 Atlassian. All Rights Reserved.