/**
* Copyright (C) 2008-2010, Squale Project - http://www.squale.org
*
* This file is part of Squale.
*
* Squale is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or any later version.
*
* Squale is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Squale. If not, see <http://www.gnu.org/licenses/>.
*/
//Source file: D:\\CC_VIEWS\\SQUALE_V0_0_ACT\\SQUALE\\SRC\\squaleCommon\\src\\org\\squale\\squalecommon\\enterpriselayer\\applicationcomponent\\LoginApplicationComponentAccess.java
package org.squale.squalecommon.enterpriselayer.applicationcomponent.administration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import org.squale.jraf.commons.exception.JrafEnterpriseException;
import org.squale.jraf.provider.accessdelegate.DefaultExecuteComponent;
import org.squale.squalecommon.datatransfertobject.component.UserDTO;
import org.squale.squalecommon.enterpriselayer.businessobject.profile.ProfileBO;
import org.squale.squalecommon.enterpriselayer.facade.component.UserFacade;
/**
* <p>
* Title : LoginApplicationComponentAccess.java
* </p>
* <p>
* Description : Application component login
* </p>
*/
public class LoginApplicationComponentAccess
extends DefaultExecuteComponent
{
/**
* Permet d'authentifier une utilisateur au sein d'AF V�rifie aussi si l'utilisateur est administrateur portail
*
* @param pUser objet UserDTO avec login et mot de passe � v�rifier
* @param pAdmin indique si l'utilisateur a un privil�ge administrateur
* @return <code>true</code> si l'utilisateur est correctement authentifi�, sinon <code>false</code>
* @throws JrafEnterpriseException exception JRAF
* @roseuid 42CBFC0001EE
*/
public UserDTO verifyUser( UserDTO pUser, Boolean pAdmin )
throws JrafEnterpriseException
{
UserDTO userDTO = null; // Initialisation du retour
userDTO = UserFacade.getUser( pUser, pAdmin );
return userDTO;
}
/**
* This method authenticate a user if the user is authenticate this method return the user with all his information
* in the userDTO if the user is not authenticate, the method return a null userDTO
*
* @param pUser : userDTO containing only identifier and password
* @return userDTO return a user with all his information if he is authenticated, otherwise the method return a null
* userDTO
* @throws JrafEnterpriseException exception happened during the search in the data base
*/
public UserDTO userAuthentication( UserDTO pUser )
throws JrafEnterpriseException
{
UserDTO userDTO = null; // Initialisation du retour
userDTO = UserFacade.getUserByMatriculeAndPassword( pUser );
return userDTO;
}
/**
* This method try to retrieve the userDto by its identifier. This method return null if no user has the identifier
*
* @param pUser The UserDto with itys identifier filled
* @return The UserDto found
* @throws JrafEnterpriseException exception occurs the search of the user
*/
public UserDTO getUserByIdentifier(UserDTO pUser) throws JrafEnterpriseException
{
UserDTO userDTO = null; // Initialisation du retour
userDTO = UserFacade.getUserByMatricule( pUser );
return userDTO;
}
/**
* Permet de mettre � jour les informations d'un utilisateur Cr�e l'utilisateur dans la base de donn�es le cas
* �ch�ant
*
* @param pUser objet UserDTO avec nom et email �ventuellementy mis � jour
* @param pAdmin indique si l'utilisateur a un privil�ge administrateur
* @return <code>true</code> si l'utilisateur est correctement authentifi�, sinon <code>false</code>
* @throws JrafEnterpriseException exception JRAF
*/
public UserDTO createOrUpdateUser( UserDTO pUser, Boolean pAdmin )
throws JrafEnterpriseException
{
UserDTO userDTO = null; // Initialisation du retour
userDTO = UserFacade.createOrUpdateUser( pUser, pAdmin );
return userDTO;
}
/**
* Obtention des utilisateurs avec le profil administrateur
*
* @param pUnsubscribed true si on veut r�cup�rer aussi les utilisateur qui se sont d�sabonn�s de l'envoi
* automatique d'email.
* @return utilisateurs avec le profil administrateur
* @throws JrafEnterpriseException en cas de pb JRAF
*/
public Collection getAdminsWithEmails( Boolean pUnsubscribed )
throws JrafEnterpriseException
{
return UserFacade.getAdminsWithEmails( pUnsubscribed.booleanValue() );
}
/**
* @param pUnsubscribed true si on veut r�cup�rer aussi les utilisateur qui se sont d�sabonn�s de l'envoi
* automatique d'email.
* @return les emails des utilisateurs avec le profil manager pour l'application concern�e
* @throws JrafEnterpriseException en cas de pb JRAF
*/
public Collection getAdminsEmails( Boolean pUnsubscribed )
throws JrafEnterpriseException
{
return getEmails( getAdminsWithEmails( pUnsubscribed ) );
}
/**
* Obtention des utilisateurs avec le profil manager pour l'application
*
* @param pId l'application concern�e
* @param pUnsubscribed true si on veut r�cup�rer aussi les utilisateur qui se sont d�sabonn�s de l'envoi
* automatique d'email.
* @return utilisateurs avec le profil manager pour l'application concern�e
* @throws JrafEnterpriseException en cas de pb JRAF
*/
public Collection getManagersWithEmails( Long pId, Boolean pUnsubscribed )
throws JrafEnterpriseException
{
return UserFacade.getUsersWithEmails( pId, ProfileBO.MANAGER_PROFILE_NAME, pUnsubscribed.booleanValue() );
}
/**
* @param pId l'application concern�e
* @param pUnsubscribed true si on veut r�cup�rer aussi les utilisateur qui se sont d�sabonn�s de l'envoi
* automatique d'email.
* @return les emails des utilisateurs avec le profil manager pour l'application concern�e
* @throws JrafEnterpriseException en cas de pb JRAF
*/
public Collection getManagersEmails( Long pId, Boolean pUnsubscribed )
throws JrafEnterpriseException
{
return getEmails( getManagersWithEmails( pId, pUnsubscribed ) );
}
/**
* Obtention des utilisateurs avec le profil manager pour l'application
*
* @param pId l'application concern�e
* @param pUnsubscribed true si on veut r�cup�rer aussi les utilisateur qui se sont d�sabonn�s de l'envoi
* automatique d'email.
* @return utilisateurs avec le profil manager pour l'application concern�e
* @throws JrafEnterpriseException en cas de pb JRAF
*/
public Collection getReadersWithEmails( Long pId, Boolean pUnsubscribed )
throws JrafEnterpriseException
{
return UserFacade.getUsersWithEmails( pId, ProfileBO.READER_PROFILE_NAME, pUnsubscribed.booleanValue() );
}
/**
* @param pId l'application concern�e
* @param pUnsubscribed true si on veut r�cup�rer aussi les utilisateur qui se sont d�sabonn�s de l'envoi
* automatique d'email.
* @return les emails des utilisateurs avec le profil manager pour l'application concern�e
* @throws JrafEnterpriseException en cas de pb JRAF
*/
public Collection getReadersEmails( Long pId, Boolean pUnsubscribed )
throws JrafEnterpriseException
{
return getEmails( getReadersWithEmails( pId, pUnsubscribed ) );
}
/**
* r�cup�re une liste d'emails sur une collection d'utilisateurs
*
* @param collUsers la collection des utilisateurs
* @return la liste des mails d�fini pour ces utilisateurs
*/
private Collection getEmails( Collection collUsers )
{
Collection result = new ArrayList( 0 );
Iterator it = collUsers.iterator();
while ( it.hasNext() )
{
result.add( ( (UserDTO) it.next() ).getEmail() );
}
return result;
}
/**
* This method returns a list of UserDTO whose IDs start by the given "idStart" parameter.
*
* @param idStart the beginning of the user id
* @return a collection of users whose IDs start by the given paramater
* @throws JrafEnterpriseException en cas de pb JRAF
*/
public Collection<UserDTO> getUsersWithIdStartingBy( String idStart )
throws JrafEnterpriseException
{
return UserFacade.getUsersWithIdStartingBy( idStart );
}
/**
* Constructeur par d�faut
*
* @roseuid 42CBFC00039C
*/
public LoginApplicationComponentAccess()
{
}
}