package org.yacos.core.users;

import java.util.List;

import javax.ejb.Remote;

import org.yacos.core.conferences.Conference;
import org.yacos.core.exceptions.PKAlreadyUsedException;
import org.yacos.core.exceptions.UserEMailAlreadyExistsException;
import org.yacos.core.system.InvitationToken;
import org.yacos.core.system.InvitationTokenPK;
import org.yacos.core.users.Role.RoleType;

/**
 * @author christiancorsano
 *
 */
@Remote
public interface IUserManager {
	
	// crud methods
	public User addUser(String login, String password, String firstName,
			String lastName, String organization, String email)
			throws PKAlreadyUsedException, UserEMailAlreadyExistsException;
	public void removeUser(String login);
	public User getUser(String login);
	public void UpdateUser(User user);
	public Boolean exists(String login);

	// Lists methods
	public List<User> getUsers();
	public List<User> getUsers(int conf_id);
	public List<User> getUsers(int conf_id, Role.RoleType type);
	public List<User> getRefereesOFPCMemberForArticle(String PCMemberLogin, Integer articleId);
	public List<User> getPCMemberForArticle(Integer articleId);
	
	
	//roles methods
	/**
	 * Create and adds a role to a user
	 * @param login The login of the user
	 * @param role The role to grant to the user
	 * @param conferenceId The id of the conference for which the Role is to be granted
	 */
	public void addRoleForConference(String login, RoleType role, Integer conferenceId);
	/**
	 * Remove a role from a user
	 * @param login The login of the user
	 * @param role The role to remove from the user
	 * @param conferenceId The id of the conference for which the Role is to be removed
	 */
	public void removeRole(String userLogin, RoleType roleType, int conferenceId);
	public boolean hasRoleForConference(String userLogin, RoleType roleType, Integer conferenceId);
	public List<Role> getRolesForUser(String userLogin);
	
	// InvitationToken handling methods
	public List<InvitationToken> getInvitationTokensForEmail(String email);
	public void useInvitationTokenOnUser(String userLogin, InvitationTokenPK tokenId);
}
