fr.paris.lutece.portal.business.user
Class AdminUserDAO

java.lang.Object
  extended by fr.paris.lutece.portal.business.user.AdminUserDAO
All Implemented Interfaces:
IAdminUserDAO

public class AdminUserDAO
extends java.lang.Object
implements IAdminUserDAO

This class porvides Data Access methods for AdminUser objects


Constructor Summary
AdminUserDAO()
           
 
Method Summary
 int checkAccessCodeAlreadyInUse(java.lang.String strAccessCode)
          Check weather the access code already exists or not
 int checkEmailAlreadyInUse(java.lang.String strEmail)
          Checks the availibility of an email
 boolean checkRoleAttributed(java.lang.String strRoleKey)
          Checks wether the role is in use or not
 int countUserPasswordHistoryFromDate(java.sql.Timestamp minDate, int nUserId)
          Get the number of password change done by a user since the given date.
 void delete(int nUserId)
          Delete a admin user
 void deleteAllDelegatedRightsForUser(int nUserId, int nUserLevel)
          Deletes rights delegated by user ie rights with level < userlevel
 void deleteAllOwnRightsForUser(int nUserId, int nUserLevel)
          Deletes rights own by user ie rights with level >= userlevel
 void deleteAllRightsForUser(int nUserId)
          Delete all rights for an user
 void deleteAllRolesForUser(int nUserId)
          Remove all roles from an user
 void deleteRightForUser(int nUserId, java.lang.String strIdRight)
          Remove a right for an user
 void deleteRoleForUser(int nUserId, java.lang.String strRoleKey)
          Remove role for an user
 java.util.List<java.lang.Integer> findAllExpiredUserId()
          Get the list of id of user with the expired status.
 java.util.List<java.lang.Integer> getIdUsersToSendFirstAlert(java.sql.Timestamp alertMaxDate)
          Get the list of id of users that need to receive their first alert
 java.util.List<java.lang.Integer> getIdUsersToSendOtherAlert(java.sql.Timestamp alertMaxDate, java.sql.Timestamp timeBetweenAlerts, int maxNumberAlerts)
          Get the list of id of users that need to receive their first alert
 java.util.List<java.lang.Integer> getIdUsersWithExpiredLifeTimeList(java.sql.Timestamp currentTimestamp)
          Get the list of id of users that have an expired time life but not the expired status
 boolean hasRight(int nUserId, java.lang.String strIdRight)
          Check if the user has the given right
 boolean hasRole(int nUserId, java.lang.String strRoleKey)
          Check if the user has the role
 void insert(AdminUser user)
          Insert a new record in the table.
 void insert(LuteceDefaultAdminUser user)
          Insert a new record in the table.
 void insertNewPasswordInHistory(java.lang.String strPassword, int nUserId)
          Log a password change in the password history
 void insertRightsListForUser(int nUserId, java.lang.String strRightId)
          Insert a right for a user
 void insertRolesListForUser(int nUserId, java.lang.String strRoleKey)
          Add a role to an user
 AdminUser load(int nUserId)
          Load an AdminUser
 LuteceDefaultAdminUser loadDefaultAdminUser(int nUserId)
          Gets a default admin user
 int newPrimaryKey()
          Generates a new primary key
 void removeAllPasswordHistoryForUser(int nUserId)
          Remove every password saved in the password history for a user.
 java.util.Map<java.lang.String,java.lang.Boolean> selectAnonymizationStatusUserStaticField()
          Get the anonymization status of a user field.
 java.util.Map<java.lang.String,Right> selectRightsListForUser(int nUserId)
          Get the right list associated to a given user id
 java.util.Map<java.lang.String,AdminRole> selectRolesListForUser(int nUserId)
          Get the role list associated to a given user id
 AdminUser selectUserByAccessCode(java.lang.String strUserAccessCode)
          Get an user by its access code (login)
 java.util.Collection<AdminUser> selectUserList()
          Get a list of all admin users
 java.util.List<java.lang.String> selectUserPasswordHistory(int nUserID)
          Gets the history of password of the given user
 java.util.Collection<AdminUser> selectUsersByFilter(AdminUserFilter auFilter)
          Gets a collection of AdminUser by using a filter.
 java.util.Collection<AdminUser> selectUsersByLevel(int nIdLevel)
          Select all user that own a given level
 java.util.Collection<AdminUser> selectUsersByRight(java.lang.String strIdRight)
          Get all users having a given right
 java.util.Collection<AdminUser> selectUsersByRole(java.lang.String strRoleKey)
          Select all user that own a given role
 void store(AdminUser user)
          Store an admin user
 void store(LuteceDefaultAdminUser user)
          Store an admin user
 void storeUsersRole(java.lang.String strOldRoleKey, AdminRole role)
          Update role key if role key name has change
 void updateAnonymizationStatusUserStaticField(java.lang.String strFieldName, boolean bAnonymizeFiled)
          Update the anonymization status of a user field.
 void updateNbAlert(java.util.List<java.lang.Integer> listIdUser)
          Increment the number of alert send to users by 1
 void updateUserExpirationDate(int nIdUser, java.sql.Timestamp newExpirationDate)
          Update the admin user expiration date with the new values.
 void updateUserStatus(java.util.List<java.lang.Integer> listIdUser, int nNewStatus)
          Update status of a list of user accounts
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdminUserDAO

public AdminUserDAO()
Method Detail

load

public AdminUser load(int nUserId)
Description copied from interface: IAdminUserDAO
Load an AdminUser

Specified by:
load in interface IAdminUserDAO
Parameters:
nUserId - th user id
Returns:
user

selectUserByAccessCode

public AdminUser selectUserByAccessCode(java.lang.String strUserAccessCode)
Description copied from interface: IAdminUserDAO
Get an user by its access code (login)

Specified by:
selectUserByAccessCode in interface IAdminUserDAO
Parameters:
strUserAccessCode - the login
Returns:
user The admin User

selectUserList

public java.util.Collection<AdminUser> selectUserList()
Get a list of all admin users

Specified by:
selectUserList in interface IAdminUserDAO
Returns:
userList The list

newPrimaryKey

public int newPrimaryKey()
Generates a new primary key

Specified by:
newPrimaryKey in interface IAdminUserDAO
Returns:
nKey

insert

public void insert(AdminUser user)
Insert a new record in the table.

Specified by:
insert in interface IAdminUserDAO
Parameters:
user - The AdminUser

store

public void store(AdminUser user)
Store an admin user

Specified by:
store in interface IAdminUserDAO
Parameters:
user - The AdminUser

delete

public void delete(int nUserId)
Delete a admin user

Specified by:
delete in interface IAdminUserDAO
Parameters:
nUserId - the user id

selectRightsListForUser

public java.util.Map<java.lang.String,Right> selectRightsListForUser(int nUserId)
Get the right list associated to a given user id

Specified by:
selectRightsListForUser in interface IAdminUserDAO
Parameters:
nUserId - the id of the user to retrieve rights
Returns:
the right list as a collection of strings

insertRightsListForUser

public void insertRightsListForUser(int nUserId,
                                    java.lang.String strRightId)
Insert a right for a user

Specified by:
insertRightsListForUser in interface IAdminUserDAO
Parameters:
nUserId - the user id
strRightId - the right id

deleteAllRightsForUser

public void deleteAllRightsForUser(int nUserId)
Delete all rights for an user

Specified by:
deleteAllRightsForUser in interface IAdminUserDAO
Parameters:
nUserId - the user id

selectRolesListForUser

public java.util.Map<java.lang.String,AdminRole> selectRolesListForUser(int nUserId)
Get the role list associated to a given user id

Specified by:
selectRolesListForUser in interface IAdminUserDAO
Parameters:
nUserId - the id of the user to retrieve roles
Returns:
the role list

insertRolesListForUser

public void insertRolesListForUser(int nUserId,
                                   java.lang.String strRoleKey)
Add a role to an user

Specified by:
insertRolesListForUser in interface IAdminUserDAO
Parameters:
nUserId - the user id
strRoleKey - the key role

deleteAllRolesForUser

public void deleteAllRolesForUser(int nUserId)
Remove all roles from an user

Specified by:
deleteAllRolesForUser in interface IAdminUserDAO
Parameters:
nUserId - the user id

checkRoleAttributed

public boolean checkRoleAttributed(java.lang.String strRoleKey)
Checks wether the role is in use or not

Specified by:
checkRoleAttributed in interface IAdminUserDAO
Parameters:
strRoleKey - the role key to check
Returns:
true if the role is attributed, false otherwise

checkAccessCodeAlreadyInUse

public int checkAccessCodeAlreadyInUse(java.lang.String strAccessCode)
Check weather the access code already exists or not

Specified by:
checkAccessCodeAlreadyInUse in interface IAdminUserDAO
Parameters:
strAccessCode - The access code
Returns:
user ID if the access code is already used by another user, -1 otherwise

checkEmailAlreadyInUse

public int checkEmailAlreadyInUse(java.lang.String strEmail)
Checks the availibility of an email

Specified by:
checkEmailAlreadyInUse in interface IAdminUserDAO
Parameters:
strEmail - The email
Returns:
user ID if the email is already used by another user, -1 otherwise

insert

public void insert(LuteceDefaultAdminUser user)
Insert a new record in the table.

Specified by:
insert in interface IAdminUserDAO
Parameters:
user - The AdminUser

store

public void store(LuteceDefaultAdminUser user)
Store an admin user

Specified by:
store in interface IAdminUserDAO
Parameters:
user - The AdminUser

loadDefaultAdminUser

public LuteceDefaultAdminUser loadDefaultAdminUser(int nUserId)
Gets a default admin user

Specified by:
loadDefaultAdminUser in interface IAdminUserDAO
Parameters:
nUserId - the user id
Returns:
The user

selectUsersByRole

public java.util.Collection<AdminUser> selectUsersByRole(java.lang.String strRoleKey)
Select all user that own a given role

Specified by:
selectUsersByRole in interface IAdminUserDAO
Parameters:
strRoleKey - The role
Returns:
userList The user's list

selectUsersByLevel

public java.util.Collection<AdminUser> selectUsersByLevel(int nIdLevel)
Select all user that own a given level

Specified by:
selectUsersByLevel in interface IAdminUserDAO
Parameters:
nIdLevel - The level
Returns:
userList The user's list

deleteAllOwnRightsForUser

public void deleteAllOwnRightsForUser(int nUserId,
                                      int nUserLevel)
Deletes rights own by user ie rights with level >= userlevel

Specified by:
deleteAllOwnRightsForUser in interface IAdminUserDAO
Parameters:
nUserId - the user id
nUserLevel - the user level

deleteAllDelegatedRightsForUser

public void deleteAllDelegatedRightsForUser(int nUserId,
                                            int nUserLevel)
Deletes rights delegated by user ie rights with level < userlevel

Specified by:
deleteAllDelegatedRightsForUser in interface IAdminUserDAO
Parameters:
nUserId - the user id
nUserLevel - the user level

storeUsersRole

public void storeUsersRole(java.lang.String strOldRoleKey,
                           AdminRole role)
Update role key if role key name has change

Specified by:
storeUsersRole in interface IAdminUserDAO
Parameters:
strOldRoleKey - The old role key name
role - The new role key

hasRole

public boolean hasRole(int nUserId,
                       java.lang.String strRoleKey)
Check if the user has the role

Specified by:
hasRole in interface IAdminUserDAO
Parameters:
nUserId - The ID of the user
strRoleKey - The role Key
Returns:
true if the user has the role

deleteRoleForUser

public void deleteRoleForUser(int nUserId,
                              java.lang.String strRoleKey)
Remove role for an user

Specified by:
deleteRoleForUser in interface IAdminUserDAO
Parameters:
nUserId - The ID of the user
strRoleKey - The role key

selectUsersByFilter

public java.util.Collection<AdminUser> selectUsersByFilter(AdminUserFilter auFilter)
Gets a collection of AdminUser by using a filter.

Specified by:
selectUsersByFilter in interface IAdminUserDAO
Parameters:
auFilter - The filter
Returns:
The user List

selectUsersByRight

public java.util.Collection<AdminUser> selectUsersByRight(java.lang.String strIdRight)
Get all users having a given right

Specified by:
selectUsersByRight in interface IAdminUserDAO
Parameters:
strIdRight - The ID right
Returns:
A collection of AdminUser

hasRight

public boolean hasRight(int nUserId,
                        java.lang.String strIdRight)
Check if the user has the given right

Specified by:
hasRight in interface IAdminUserDAO
Parameters:
nUserId - The ID of the user
strIdRight - The ID right
Returns:
true if the user has the right

deleteRightForUser

public void deleteRightForUser(int nUserId,
                               java.lang.String strIdRight)
Remove a right for an user

Specified by:
deleteRightForUser in interface IAdminUserDAO
Parameters:
nUserId - The user ID
strIdRight - The right ID

selectUserPasswordHistory

public java.util.List<java.lang.String> selectUserPasswordHistory(int nUserID)
Gets the history of password of the given user

Specified by:
selectUserPasswordHistory in interface IAdminUserDAO
Parameters:
nUserID - Id of the user
Returns:
The collection of recent passwords used by the user.

countUserPasswordHistoryFromDate

public int countUserPasswordHistoryFromDate(java.sql.Timestamp minDate,
                                            int nUserId)
Get the number of password change done by a user since the given date.

Specified by:
countUserPasswordHistoryFromDate in interface IAdminUserDAO
Parameters:
minDate - Minimum date to consider.
nUserId - Id of the user
Returns:
The number of password change done by the user since the given date.

insertNewPasswordInHistory

public void insertNewPasswordInHistory(java.lang.String strPassword,
                                       int nUserId)
Log a password change in the password history

Specified by:
insertNewPasswordInHistory in interface IAdminUserDAO
Parameters:
strPassword - New password of the user
nUserId - Id of the user

removeAllPasswordHistoryForUser

public void removeAllPasswordHistoryForUser(int nUserId)
Remove every password saved in the password history for a user.

Specified by:
removeAllPasswordHistoryForUser in interface IAdminUserDAO
Parameters:
nUserId - Id of the user

selectAnonymizationStatusUserStaticField

public java.util.Map<java.lang.String,java.lang.Boolean> selectAnonymizationStatusUserStaticField()
Get the anonymization status of a user field.

Specified by:
selectAnonymizationStatusUserStaticField in interface IAdminUserDAO
Returns:
A map containing the associations of user field name and a boolean describing whether the field should be anonymized.

updateAnonymizationStatusUserStaticField

public void updateAnonymizationStatusUserStaticField(java.lang.String strFieldName,
                                                     boolean bAnonymizeFiled)
Update the anonymization status of a user field.

Specified by:
updateAnonymizationStatusUserStaticField in interface IAdminUserDAO
Parameters:
strFieldName - Name of the field to update
bAnonymizeFiled - True if the field should be anonymize, false otherwise

findAllExpiredUserId

public java.util.List<java.lang.Integer> findAllExpiredUserId()
Get the list of id of user with the expired status.

Specified by:
findAllExpiredUserId in interface IAdminUserDAO
Returns:
The list of if of user with the expired status.

getIdUsersWithExpiredLifeTimeList

public java.util.List<java.lang.Integer> getIdUsersWithExpiredLifeTimeList(java.sql.Timestamp currentTimestamp)
Get the list of id of users that have an expired time life but not the expired status

Specified by:
getIdUsersWithExpiredLifeTimeList in interface IAdminUserDAO
Parameters:
currentTimestamp - Timestamp describing the current time.
Returns:
the list of id of users with expired time life

getIdUsersToSendFirstAlert

public java.util.List<java.lang.Integer> getIdUsersToSendFirstAlert(java.sql.Timestamp alertMaxDate)
Get the list of id of users that need to receive their first alert

Specified by:
getIdUsersToSendFirstAlert in interface IAdminUserDAO
Parameters:
alertMaxDate - The maximum date to send alerts.
Returns:
the list of id of users that need to receive their first alert

getIdUsersToSendOtherAlert

public java.util.List<java.lang.Integer> getIdUsersToSendOtherAlert(java.sql.Timestamp alertMaxDate,
                                                                    java.sql.Timestamp timeBetweenAlerts,
                                                                    int maxNumberAlerts)
Get the list of id of users that need to receive their first alert

Specified by:
getIdUsersToSendOtherAlert in interface IAdminUserDAO
Parameters:
alertMaxDate - The maximum date to send alerts.
timeBetweenAlerts - Timestamp describing the time between two alerts.
maxNumberAlerts - Maximum number of alerts to send to a user
Returns:
the list of id of users that need to receive their first alert

updateUserStatus

public void updateUserStatus(java.util.List<java.lang.Integer> listIdUser,
                             int nNewStatus)
Update status of a list of user accounts

Specified by:
updateUserStatus in interface IAdminUserDAO
Parameters:
listIdUser - List of user accounts to update
nNewStatus - New status of the user

updateNbAlert

public void updateNbAlert(java.util.List<java.lang.Integer> listIdUser)
Increment the number of alert send to users by 1

Specified by:
updateNbAlert in interface IAdminUserDAO
Parameters:
listIdUser - The list of users to update

updateUserExpirationDate

public void updateUserExpirationDate(int nIdUser,
                                     java.sql.Timestamp newExpirationDate)
Update the admin user expiration date with the new values. Also update his alert account to 0

Specified by:
updateUserExpirationDate in interface IAdminUserDAO
Parameters:
nIdUser - Id of the admin user to update
newExpirationDate - Id of the user to update


Copyright © 2012 Mairie de Paris. All Rights Reserved.