This commit is contained in:
Maxime Dagnicourt
2008-01-10 16:29:12 +00:00
parent 0a1a20437c
commit 4067e5e96c
4 changed files with 33 additions and 9 deletions

View File

@@ -8,11 +8,17 @@ import org.yacos.core.exceptions.PKAlreadyUsedException;
@Remote @Remote
public interface IUserManager { public interface IUserManager {
//crud methode
public Collection<User> getUsers(); public Collection<User> getUsers();
public void addUser(User user) throws PKAlreadyUsedException; public User addUser(String login, String password, String firstName,
String lastName, String organization, String email) throws PKAlreadyUsedException;
public void removeUser(User user); public void removeUser(User user);
public User getUser(String login); public User getUser(String login);
public void UpdateUser(User user); public void UpdateUser(User user);
public Boolean exists(User user); public Boolean exists(String login);
//role methode
public Collection<Role> getRoles();
} }

View File

@@ -45,6 +45,7 @@ public class Role {
AUTHOR,CHAIRMAN,PCMEMBER,REFEREE AUTHOR,CHAIRMAN,PCMEMBER,REFEREE
} }
@Id
@Enumerated(EnumType.ORDINAL) @Enumerated(EnumType.ORDINAL)
private RoleType type; private RoleType type;

View File

@@ -3,6 +3,7 @@ package org.yacos.core.users;
import java.io.Serializable; import java.io.Serializable;
import org.yacos.core.conferences.Conference; import org.yacos.core.conferences.Conference;
import org.yacos.core.users.Role.RoleType;
public class RolePK implements Serializable{ public class RolePK implements Serializable{
@@ -11,8 +12,18 @@ public class RolePK implements Serializable{
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private RoleType type;
private User user; private User user;
private Conference conference; private Conference conference;
public RoleType getType() {
return type;
}
public void setType(RoleType type) {
this.type = type;
}
public User getUser() { public User getUser() {
return user; return user;
} }

View File

@@ -32,13 +32,15 @@ public class UserManagerBean implements IUserManager{
* throw PKAlreadyUsedException if login exist in the DB * throw PKAlreadyUsedException if login exist in the DB
* @param user * @param user
*/ */
public void addUser(User user) throws PKAlreadyUsedException{ public User addUser(String login, String password, String firstName,
if (!this.exists(user)){ String lastName, String organization, String email) throws PKAlreadyUsedException{
if (!this.exists(login)){
User user = new User(login, password, firstName, lastName, organization, email);
em.persist(user); em.persist(user);
return user;
} }
else{ else{ throw new PKAlreadyUsedException(); }
throw new PKAlreadyUsedException();
}
} }
/** /**
@@ -58,9 +60,13 @@ public class UserManagerBean implements IUserManager{
em.merge(user); em.merge(user);
} }
public Boolean exists(User user){ public Boolean exists(String login){
return (this.getUser(user.getLogin())!= null); return (this.getUser(login)!= null);
} }
public Collection<Role> getRoles() {
// TODO Auto-generated method stub
return null;
}
} }