Limpieza de código.

This commit is contained in:
Marcos Garcia Nuñez
2019-12-09 21:17:51 +01:00
parent 9f0873780b
commit 7857b477d4

View File

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