From 7857b477d43e5312dea935b781ff67e2a223dca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garcia=20Nu=C3=B1ez?= Date: Mon, 9 Dec 2019 21:17:51 +0100 Subject: [PATCH] =?UTF-8?q?Limpieza=20de=20c=C3=B3digo.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profile/UpdateProfileMBean.java | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/1.sources/MyHealth/src/managedbean/profile/UpdateProfileMBean.java b/1.sources/MyHealth/src/managedbean/profile/UpdateProfileMBean.java index 32d6481..08daeb5 100644 --- a/1.sources/MyHealth/src/managedbean/profile/UpdateProfileMBean.java +++ b/1.sources/MyHealth/src/managedbean/profile/UpdateProfileMBean.java @@ -55,7 +55,6 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable private String password; private String email; - // private HashMap userTypes; private List userTypes; private String userType; private PrimaryHealthCareCenterTO primaryHealthCareCenter; @@ -63,11 +62,6 @@ public class UpdateProfileMBean extends ManagedBeanBase implements Serializable private Collection medicalSpecialitiesList; private Collection 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);