Limpieza de código.
This commit is contained in:
@@ -55,7 +55,6 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
private String password;
|
||||
private String email;
|
||||
|
||||
// private HashMap<String, String> userTypes;
|
||||
private List<UserType> userTypes;
|
||||
private String userType;
|
||||
private PrimaryHealthCareCenterTO primaryHealthCareCenter;
|
||||
@@ -63,11 +62,6 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
private Collection<MedicalSpecialtyTO> medicalSpecialitiesList;
|
||||
private Collection<PrimaryHealthCareCenterTO> primaryHealthCareCentersList;
|
||||
|
||||
/**
|
||||
* Constructor. Inicializa la conexión con el EJB Remoto
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public UpdateProfileMBean() {
|
||||
|
||||
}
|
||||
@@ -85,7 +79,8 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
usr = SessionUtils.getloggedOnUser();
|
||||
|
||||
if (usr == null)
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Sesión no válida", "Su sesión actual no es válida, por favor cierre su sesión y vuelva a logearse en el sistema.");
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Sesión no válida",
|
||||
"Su sesión actual no es válida, por favor cierre su sesión y vuelva a logearse en el sistema.");
|
||||
else {
|
||||
this.userType = usr.getUserType().getName();
|
||||
this.id = Integer.valueOf(usr.getId());
|
||||
@@ -93,7 +88,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
switch (usr.getUserType()) {
|
||||
case PATIENT:
|
||||
PatientTO pat = this.getRemoteManagerProfile().retrievePatient(this.id);
|
||||
|
||||
|
||||
this.name = pat.getName();
|
||||
this.surname = pat.getName();
|
||||
this.nif = pat.getNif();
|
||||
@@ -114,7 +109,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
case FAMILY_DOCTOR:
|
||||
this.primaryHealthCareCentersList = this.getRemoteManagerSystemAdmin().listAllCAPs();
|
||||
FamilyDoctorTO fd = this.getRemoteManagerProfile().retrieveFamilyDoctor(this.id);
|
||||
|
||||
|
||||
this.name = fd.getName();
|
||||
this.surname = fd.getName();
|
||||
this.nif = fd.getNif();
|
||||
@@ -122,7 +117,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
this.currentPassword = fd.getPassword();
|
||||
this.primaryHealthCareCenter = fd.getPrimaryHealthCareCenter();
|
||||
break;
|
||||
case ADMINISTRADOR:
|
||||
case ADMINISTRATOR:
|
||||
// TODO: Recuperar usuario administrador para editar su perfil ¿?
|
||||
// this.getRemoteManagerProfile().retrievePatient(usr.getId());
|
||||
break;
|
||||
@@ -154,7 +149,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
this.manageException(e);
|
||||
}
|
||||
break;
|
||||
case ADMINISTRADOR:
|
||||
case ADMINISTRATOR:
|
||||
case PATIENT:
|
||||
PrimeFaces.current().ajax().addCallbackParam("pats", true);
|
||||
break;
|
||||
@@ -246,15 +241,17 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
error++;
|
||||
}
|
||||
if (changePassword == true) {
|
||||
// el usuario queire cambiar el password Comprobamos que el password especificado coincide con el guardado
|
||||
// el usuario queire cambiar el password Comprobamos que el password
|
||||
// especificado coincide con el guardado
|
||||
if (this.password == null || this.password.length() < 4) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Nueva contraseña incorrectra", "Su nueva contraseña debe tener al menos 4 caracteres.");
|
||||
error++;
|
||||
} else if (HashUtils.hashMD5(this.oldPassword).equals(this.currentPassword) == false ) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Contraseña actual incorrecta", "Su actual contraseña es incorrecta. Por favor, especifique su contraseña actual.");
|
||||
} else if (HashUtils.hashMD5(this.oldPassword).equals(this.currentPassword) == false) {
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_ERROR, "Contraseña actual incorrecta",
|
||||
"Su actual contraseña es incorrecta. Por favor, especifique su contraseña actual.");
|
||||
error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
try {
|
||||
@@ -274,7 +271,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
this.id = sd.getId();
|
||||
|
||||
break;
|
||||
case ADMINISTRADOR:
|
||||
case ADMINISTRATOR:
|
||||
throw new NotSupportedException("No se soporta la edición de perfiles de tipo administrador.");
|
||||
}
|
||||
|
||||
@@ -283,7 +280,7 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable
|
||||
this.password = "";
|
||||
this.oldPassword = "";
|
||||
}
|
||||
|
||||
|
||||
this.addFacesMessage(FacesMessage.SEVERITY_INFO, "Los datos se han guardado", "Los datos de su perfil se han guardado correctamente.");
|
||||
} catch (Exception e) {
|
||||
this.manageException(e);
|
||||
|
||||
Reference in New Issue
Block a user