Policy failures:
Code warning - failed on resource RolePK.java. Reason: The assignment to variable conference has no effect, line 26 - failed on resource User.java. Reason: The serializable class User does not declare a static final serialVersionUID field of type long, line 2 Override reason: f
This commit is contained in:
@@ -10,4 +10,7 @@ public interface IUsersManager {
|
|||||||
public void addUser(User user);
|
public void addUser(User user);
|
||||||
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 Boolean existe(User user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,14 @@ package org.yacos.core.users;
|
|||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.EnumType;
|
import javax.persistence.EnumType;
|
||||||
import javax.persistence.Enumerated;
|
import javax.persistence.Enumerated;
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.GenerationType;
|
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.IdClass;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
|
|
||||||
import org.yacos.core.conferences.Conference;
|
import org.yacos.core.conferences.Conference;
|
||||||
import org.yacos.core.users.RoleType.RoleTypeEnum;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An role of a given type (author,chairman,PCmember or referee)
|
* An role of a given type (author,chairman,PCmember or referee)
|
||||||
@@ -18,81 +19,75 @@ import org.yacos.core.users.RoleType.RoleTypeEnum;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
|
@IdClass(RolePK.class)
|
||||||
public class Role {
|
public class Role {
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
|
||||||
private Integer id;
|
|
||||||
/**
|
/**
|
||||||
* User for which this role is defined
|
* User for which this role is defined
|
||||||
|
* Primary Key
|
||||||
*/
|
*/
|
||||||
|
@Id
|
||||||
@ManyToOne(targetEntity=User.class,optional=false)
|
@ManyToOne(targetEntity=User.class,optional=false)
|
||||||
@JoinColumn(name="user_id",nullable=false)
|
@JoinColumn(name="user_id",nullable=false)
|
||||||
private User user;
|
private User user;
|
||||||
/**
|
/**
|
||||||
* Conference for which this role is defined
|
* Conference for which this role is defined
|
||||||
|
* Primary Key
|
||||||
*/
|
*/
|
||||||
|
@Id
|
||||||
@ManyToOne(targetEntity=Conference.class,optional=false)
|
@ManyToOne(targetEntity=Conference.class,optional=false)
|
||||||
@JoinColumn(name="conference_id",nullable=false)
|
@JoinColumn(name="conference_id",nullable=false)
|
||||||
private Conference conference;
|
private Conference conference;
|
||||||
/**
|
/**
|
||||||
* The type of this role
|
* The type of this role
|
||||||
*/
|
*/
|
||||||
@Enumerated(EnumType.ORDINAL)
|
public enum RoleType {
|
||||||
private RoleTypeEnum type;
|
AUTHOR,CHAIRMAN,PCMEMBER,REFEREE
|
||||||
|
}
|
||||||
|
|
||||||
public Role(RoleTypeEnum type,User user, Conference conference) {
|
@Enumerated(EnumType.ORDINAL)
|
||||||
|
private RoleType type;
|
||||||
|
|
||||||
|
public Role(RoleType type,User user, Conference conference) {
|
||||||
super();
|
super();
|
||||||
setType(type);
|
setType(type);
|
||||||
setUser(user);
|
setUser(user);
|
||||||
setConference(conference);
|
setConference(conference);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @return the id
|
|
||||||
*/
|
|
||||||
public Integer getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @param id the id to set
|
|
||||||
*/
|
|
||||||
public void setId(Integer id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return the user who plays this role
|
|
||||||
*/
|
|
||||||
public User getUser() {
|
public User getUser() {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param user the user who is to play this role
|
|
||||||
*/
|
|
||||||
public void setUser(User user) {
|
public void setUser(User user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @return the conference for which this role is defined
|
|
||||||
*/
|
|
||||||
public Conference getConference() {
|
public Conference getConference() {
|
||||||
return conference;
|
return conference;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @param conference the conference for which this role is defined
|
|
||||||
*/
|
|
||||||
public void setConference(Conference conference) {
|
public void setConference(Conference conference) {
|
||||||
this.conference = conference;
|
this.conference = conference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the type of this role
|
* @return the type of this role
|
||||||
*/
|
*/
|
||||||
public RoleTypeEnum getType() {
|
public RoleType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param type the type of this role
|
* @param type the type of this role
|
||||||
*/
|
*/
|
||||||
public void setType(RoleTypeEnum type) {
|
public void setType(RoleType type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
30
YACOSCore/ejbModule/org/yacos/core/users/RolePK.java
Normal file
30
YACOSCore/ejbModule/org/yacos/core/users/RolePK.java
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package org.yacos.core.users;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import org.yacos.core.conferences.Conference;
|
||||||
|
|
||||||
|
public class RolePK implements Serializable{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private User user;
|
||||||
|
private Conference conference;
|
||||||
|
public User getUserId() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
public void setUser(User user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
public Conference getConference() {
|
||||||
|
return conference;
|
||||||
|
}
|
||||||
|
public void setConferenceId(Conference conferenceId) {
|
||||||
|
this.conference = conference;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.yacos.core.users;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author christiancorsano
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class RoleType {
|
|
||||||
// TODO : see what we do with this class
|
|
||||||
public enum RoleTypeEnum {
|
|
||||||
AUTHOR,CHAIRMAN,PCMEMBER,REFEREE
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Author constant role
|
|
||||||
*/
|
|
||||||
static public final RoleType author = new RoleType("author");
|
|
||||||
/**
|
|
||||||
* Chairman constant role
|
|
||||||
*/
|
|
||||||
static public final RoleType chairman = new RoleType("chairman");
|
|
||||||
/**
|
|
||||||
* PCMember constant role
|
|
||||||
*/
|
|
||||||
static public final RoleType PCmember = new RoleType("PCmember");
|
|
||||||
/**
|
|
||||||
* Referee constant role
|
|
||||||
*/
|
|
||||||
static public final RoleType Referee = new RoleType("referee");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Name of this role type
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Private constructor : used to instanciate the constants
|
|
||||||
* @param name Name of the new RoleType
|
|
||||||
*/
|
|
||||||
private RoleType(String name){
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the name of this RoleType
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String getName() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.yacos.core.users;
|
package org.yacos.core.users;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
@@ -52,25 +53,20 @@ public class User implements Serializable{
|
|||||||
private Collection<Role> roles;
|
private Collection<Role> roles;
|
||||||
|
|
||||||
public User(String login, String password, String firstName,
|
public User(String login, String password, String firstName,
|
||||||
String lastName, String organization, String email,
|
String lastName, String organization, String email) {
|
||||||
Collection<Role> roles) {
|
this();
|
||||||
super();
|
|
||||||
this.login = login;
|
this.login = login;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
this.firstName = firstName;
|
this.firstName = firstName;
|
||||||
this.lastName = lastName;
|
this.lastName = lastName;
|
||||||
this.organization = organization;
|
this.organization = organization;
|
||||||
this.email = email;
|
this.email = email;
|
||||||
this.roles = roles;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public User() {
|
public User() {
|
||||||
|
this.roles = new ArrayList<Role>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
public String getLogin() {
|
public String getLogin() {
|
||||||
return login;
|
return login;
|
||||||
@@ -116,7 +112,7 @@ public class User implements Serializable{
|
|||||||
roles.add(role);
|
roles.add(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRoleForConference(RoleType roleType, Conference conference){
|
public void addRoleForConference(Role.RoleType roleType, Conference conference){
|
||||||
if(! hasRoleForConference(roleType,conference)){
|
if(! hasRoleForConference(roleType,conference)){
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -124,7 +120,7 @@ public class User implements Serializable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasRoleForConference(RoleType roleType, Conference conference){
|
public boolean hasRoleForConference(Role.RoleType roleType, Conference conference){
|
||||||
// TODO
|
// TODO
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -156,4 +152,8 @@ public class User implements Serializable{
|
|||||||
this.roles = roles;
|
this.roles = roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddRole(Role role){
|
||||||
|
roles.add(role);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,4 +45,15 @@ public class UsersManagerBean implements IUsersManager{
|
|||||||
public User getUser(String login) {
|
public User getUser(String login) {
|
||||||
return em.find(User.class, login);
|
return em.find(User.class, login);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateUser(User user){
|
||||||
|
em.merge(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean existe(User user){
|
||||||
|
|
||||||
|
return (this.getUser(user.getLogin())!= null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user