Class DatabaseUserDAO

  • All Implemented Interfaces:
    IDatabaseUserDAO

    public class DatabaseUserDAO
    extends java.lang.Object
    implements IDatabaseUserDAO
    This class provides Data Access methods for databaseUser objects
    • Constructor Summary

      Constructors 
      Constructor Description
      DatabaseUserDAO()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int countUserPasswordHistoryFromDate​(java.sql.Timestamp minDate, int nUserId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Get the number of password change done by a user since the given date.
      void delete​(DatabaseUser databaseUser, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Delete a record from the table
      java.util.List<java.lang.Integer> findAllExpiredUserId​(fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Get the list of id of user with the expired status.
      int findDatabaseUserIdFromLogin​(java.lang.String strLogin, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Get a user id from his login
      java.util.List<java.lang.Integer> getIdUsersToSendFirstAlert​(java.sql.Timestamp alertMaxDate, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      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, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      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, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Get the list of id of users that have an expired time life but not the expired status
      java.util.List<java.lang.Integer> getIdUsersWithExpiredPasswordsList​(java.sql.Timestamp currentTimestamp, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Get the list of id of users that have an expired password but not the change password flag
      int getNbAccountLifeTimeNotification​(int nIdUser, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Get the number of notification send to a user to warn him about the expiration of his account
      void insert​(DatabaseUser databaseUser, fr.paris.lutece.util.password.IPassword password, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Insert a new record in the table.
      void insertNewPasswordInHistory​(fr.paris.lutece.util.password.IPassword password, int nUserId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Log a password change in the password history
      DatabaseUser load​(int nUserId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Load the data of DatabaseUser from the table
      fr.paris.lutece.util.password.IPassword loadPassword​(java.lang.String strLogin, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      load the password for a DatabaseUser
      java.util.List<DatabaseUser> loadUsersByIds​(java.util.List<java.lang.Integer> userIds, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Load multiple users by their IDs
      int newPrimaryKey​(fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Generates a new primary key
      void removeAllPasswordHistoryForUser​(int nUserId, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Remove every password saved in the password history for a user.
      java.util.Collection<DatabaseUser> selectDatabaseUserList​(fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Load the list of databaseUsers
      java.util.Collection<DatabaseUser> selectDatabaseUserListForEmail​(java.lang.String strEmail, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Load the list of DatabaseUsers for a email
      java.util.Collection<DatabaseUser> selectDatabaseUserListForLogin​(java.lang.String strLogin, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Load the list of DatabaseUsers for a login
      java.util.List<DatabaseUser> selectDatabaseUsersListByFilter​(DatabaseUserFilter duFilter, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Load the list of DatabaseUsers by a filter
      java.util.List<fr.paris.lutece.util.password.IPassword> selectUserPasswordHistory​(int nUserID, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Gets the history of password of the given user
      void store​(DatabaseUser databaseUser, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Update the record in the table
      void updateChangePassword​(java.util.List<java.lang.Integer> listIdUser, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Set the "change password" flag of users to true
      void updateNbAlert​(java.util.List<java.lang.Integer> listIdUser, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Increment the number of alert send to users by 1
      void updatePassword​(DatabaseUser databaseUser, fr.paris.lutece.util.password.IPassword newPassword, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Update the record in the table
      void updateResetPassword​(DatabaseUser databaseUser, boolean bNewValue, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Update the record in the table
      void updateUserExpirationDate​(int nIdUser, java.sql.Timestamp newExpirationDate, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Update the user expiration date with the new values.
      void updateUserLastLoginDate​(java.lang.String strLogin, java.sql.Timestamp dateLastLogin, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Update a user last login date
      void updateUserStatus​(java.util.List<java.lang.Integer> listIdUser, int nNewStatus, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Update status of a list of user accounts
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DatabaseUserDAO

        public DatabaseUserDAO()
    • Method Detail

      • newPrimaryKey

        public int newPrimaryKey​(fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Generates a new primary key
        Specified by:
        newPrimaryKey in interface IDatabaseUserDAO
        Parameters:
        plugin - The Plugin using this data access service
        Returns:
        The new primary key
      • insert

        public void insert​(DatabaseUser databaseUser,
                           fr.paris.lutece.util.password.IPassword password,
                           fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Insert a new record in the table.
        Specified by:
        insert in interface IDatabaseUserDAO
        Parameters:
        databaseUser - The databaseUser object
        password - The user password
        plugin - The Plugin using this data access service
      • load

        public DatabaseUser load​(int nUserId,
                                 fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Load the data of DatabaseUser from the table
        Specified by:
        load in interface IDatabaseUserDAO
        Parameters:
        nUserId - The identifier of databaseUser
        plugin - The Plugin using this data access service
        Returns:
        the instance of the DatabaseUser
      • delete

        public void delete​(DatabaseUser databaseUser,
                           fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Delete a record from the table
        Specified by:
        delete in interface IDatabaseUserDAO
        Parameters:
        databaseUser - The databaseUser object
        plugin - The Plugin using this data access service
      • store

        public void store​(DatabaseUser databaseUser,
                          fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Update the record in the table
        Specified by:
        store in interface IDatabaseUserDAO
        Parameters:
        databaseUser - The reference of databaseUser
        plugin - The Plugin using this data access service
      • updatePassword

        public void updatePassword​(DatabaseUser databaseUser,
                                   fr.paris.lutece.util.password.IPassword newPassword,
                                   fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Update the record in the table
        Specified by:
        updatePassword in interface IDatabaseUserDAO
        Parameters:
        databaseUser - The reference of databaseUser
        newPassword - The new password to store
        plugin - The Plugin using this data access service
      • updateResetPassword

        public void updateResetPassword​(DatabaseUser databaseUser,
                                        boolean bNewValue,
                                        fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Update the record in the table
        Specified by:
        updateResetPassword in interface IDatabaseUserDAO
        Parameters:
        databaseUser - The reference of databaseUser
        bNewValue - The new value of the resetPassword attribute
        plugin - The Plugin using this data access service
      • selectDatabaseUserList

        public java.util.Collection<DatabaseUser> selectDatabaseUserList​(fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Load the list of databaseUsers
        Specified by:
        selectDatabaseUserList in interface IDatabaseUserDAO
        Parameters:
        plugin - The Plugin using this data access service
        Returns:
        The Collection of the databaseUsers
      • selectDatabaseUserListForLogin

        public java.util.Collection<DatabaseUser> selectDatabaseUserListForLogin​(java.lang.String strLogin,
                                                                                 fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Load the list of DatabaseUsers for a login
        Specified by:
        selectDatabaseUserListForLogin in interface IDatabaseUserDAO
        Parameters:
        strLogin - The login of DatabaseUser
        plugin - The Plugin using this data access service
        Returns:
        The Collection of the DatabaseUsers
      • selectDatabaseUserListForEmail

        public java.util.Collection<DatabaseUser> selectDatabaseUserListForEmail​(java.lang.String strEmail,
                                                                                 fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Load the list of DatabaseUsers for a email
        Specified by:
        selectDatabaseUserListForEmail in interface IDatabaseUserDAO
        Parameters:
        strEmail - The email of DatabaseUser
        plugin - The Plugin using this data access service
        Returns:
        The Collection of the DatabaseUsers
      • loadPassword

        public fr.paris.lutece.util.password.IPassword loadPassword​(java.lang.String strLogin,
                                                                    fr.paris.lutece.portal.service.plugin.Plugin plugin)
        load the password for a DatabaseUser
        Specified by:
        loadPassword in interface IDatabaseUserDAO
        Parameters:
        strLogin - The user login of DatabaseUser
        plugin - The Plugin using this data access service
        Returns:
        the stored password of the user
      • selectDatabaseUsersListByFilter

        public java.util.List<DatabaseUser> selectDatabaseUsersListByFilter​(DatabaseUserFilter duFilter,
                                                                            fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Load the list of DatabaseUsers by a filter
        Specified by:
        selectDatabaseUsersListByFilter in interface IDatabaseUserDAO
        Parameters:
        duFilter - filter
        plugin - Plugin
        Returns:
        a list of DatabaseUser
      • findDatabaseUserIdFromLogin

        public int findDatabaseUserIdFromLogin​(java.lang.String strLogin,
                                               fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Get a user id from his login
        Specified by:
        findDatabaseUserIdFromLogin in interface IDatabaseUserDAO
        Parameters:
        strLogin - The login of the user
        plugin - The plugin
        Returns:
        The user id, or 0 if no user has this login.
      • selectUserPasswordHistory

        public java.util.List<fr.paris.lutece.util.password.IPassword> selectUserPasswordHistory​(int nUserID,
                                                                                                 fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Gets the history of password of the given user
        Specified by:
        selectUserPasswordHistory in interface IDatabaseUserDAO
        Parameters:
        nUserID - Id of the user
        plugin - The plugin
        Returns:
        The collection of recent passwords used by the user.
      • countUserPasswordHistoryFromDate

        public int countUserPasswordHistoryFromDate​(java.sql.Timestamp minDate,
                                                    int nUserId,
                                                    fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Get the number of password change done by a user since the given date.
        Specified by:
        countUserPasswordHistoryFromDate in interface IDatabaseUserDAO
        Parameters:
        minDate - Minimum date to consider.
        nUserId - Id of the user
        plugin - The plugin
        Returns:
        The number of password change done by the user since the given date.
      • insertNewPasswordInHistory

        public void insertNewPasswordInHistory​(fr.paris.lutece.util.password.IPassword password,
                                               int nUserId,
                                               fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Log a password change in the password history
        Specified by:
        insertNewPasswordInHistory in interface IDatabaseUserDAO
        Parameters:
        password - New password of the user
        nUserId - Id of the user
        plugin - The plugin
      • removeAllPasswordHistoryForUser

        public void removeAllPasswordHistoryForUser​(int nUserId,
                                                    fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Remove every password saved in the password history for a user.
        Specified by:
        removeAllPasswordHistoryForUser in interface IDatabaseUserDAO
        Parameters:
        nUserId - Id of the user
        plugin - The plugin
      • findAllExpiredUserId

        public java.util.List<java.lang.Integer> findAllExpiredUserId​(fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Get the list of id of user with the expired status.
        Specified by:
        findAllExpiredUserId in interface IDatabaseUserDAO
        Parameters:
        plugin - The plugin
        Returns:
        The list of if of user with the expired status.
      • getIdUsersWithExpiredLifeTimeList

        public java.util.List<java.lang.Integer> getIdUsersWithExpiredLifeTimeList​(java.sql.Timestamp currentTimestamp,
                                                                                   fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Get the list of id of users that have an expired time life but not the expired status
        Specified by:
        getIdUsersWithExpiredLifeTimeList in interface IDatabaseUserDAO
        Parameters:
        currentTimestamp - Timestamp describing the current time.
        plugin - The plugin
        Returns:
        the list of id of users with expired time life
      • getIdUsersToSendFirstAlert

        public java.util.List<java.lang.Integer> getIdUsersToSendFirstAlert​(java.sql.Timestamp alertMaxDate,
                                                                            fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Get the list of id of users that need to receive their first alert
        Specified by:
        getIdUsersToSendFirstAlert in interface IDatabaseUserDAO
        Parameters:
        alertMaxDate - The maximum date to send alerts.
        plugin - The plugin
        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,
                                                                            fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Get the list of id of users that need to receive their first alert
        Specified by:
        getIdUsersToSendOtherAlert in interface IDatabaseUserDAO
        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
        plugin - The plugin
        Returns:
        the list of id of users that need to receive their first alert
      • getIdUsersWithExpiredPasswordsList

        public java.util.List<java.lang.Integer> getIdUsersWithExpiredPasswordsList​(java.sql.Timestamp currentTimestamp,
                                                                                    fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Get the list of id of users that have an expired password but not the change password flag
        Specified by:
        getIdUsersWithExpiredPasswordsList in interface IDatabaseUserDAO
        Parameters:
        currentTimestamp - Timestamp describing the current time.
        plugin - The plugin
        Returns:
        the list of id of users with expired passwords
      • updateUserStatus

        public void updateUserStatus​(java.util.List<java.lang.Integer> listIdUser,
                                     int nNewStatus,
                                     fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Update status of a list of user accounts
        Specified by:
        updateUserStatus in interface IDatabaseUserDAO
        Parameters:
        listIdUser - List of user accounts to update
        nNewStatus - New status of the user
        plugin - The plugin
      • updateNbAlert

        public void updateNbAlert​(java.util.List<java.lang.Integer> listIdUser,
                                  fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Increment the number of alert send to users by 1
        Specified by:
        updateNbAlert in interface IDatabaseUserDAO
        Parameters:
        listIdUser - The list of users to update
        plugin - The plugin
      • updateChangePassword

        public void updateChangePassword​(java.util.List<java.lang.Integer> listIdUser,
                                         fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Set the "change password" flag of users to true
        Specified by:
        updateChangePassword in interface IDatabaseUserDAO
        Parameters:
        listIdUser - The list of users to update
        plugin - The plugin
      • updateUserExpirationDate

        public void updateUserExpirationDate​(int nIdUser,
                                             java.sql.Timestamp newExpirationDate,
                                             fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Update the user expiration date with the new values. Also update his alert account to 0
        Specified by:
        updateUserExpirationDate in interface IDatabaseUserDAO
        Parameters:
        nIdUser - Id of the user to update
        newExpirationDate - Id of the user to update
        plugin - The plugin
      • getNbAccountLifeTimeNotification

        public int getNbAccountLifeTimeNotification​(int nIdUser,
                                                    fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Get the number of notification send to a user to warn him about the expiration of his account
        Specified by:
        getNbAccountLifeTimeNotification in interface IDatabaseUserDAO
        Parameters:
        nIdUser - Id of the user
        plugin - The plugin
        Returns:
        The number of notification send to the user
      • updateUserLastLoginDate

        public void updateUserLastLoginDate​(java.lang.String strLogin,
                                            java.sql.Timestamp dateLastLogin,
                                            fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Update a user last login date
        Specified by:
        updateUserLastLoginDate in interface IDatabaseUserDAO
        Parameters:
        strLogin - Login of the user to update
        dateLastLogin - date of the last login of the user
        plugin - The plugin
      • loadUsersByIds

        public java.util.List<DatabaseUser> loadUsersByIds​(java.util.List<java.lang.Integer> userIds,
                                                           fr.paris.lutece.portal.service.plugin.Plugin plugin)
        Load multiple users by their IDs
        Specified by:
        loadUsersByIds in interface IDatabaseUserDAO
        Parameters:
        userIds - The list of user IDs
        plugin - The plugin
        Returns:
        The list of DatabaseUsers found