From: Roland Haeder Date: Mon, 18 Apr 2016 19:36:41 +0000 (+0200) Subject: moved user instance to admin controller as this is the right one for this purpose X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=83d5399bf679e0564abf30dee5e5a10ed66d637c;p=jjobs-war.git moved user instance to admin controller as this is the right one for this purpose Signed-off-by: Roland Häder --- diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebSessionBean.java index ff0cd4e4..b05c8d1c 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebSessionBean.java @@ -166,6 +166,11 @@ public class JobsAdminUserWebSessionBean implements JobsAdminUserWebSessionContr */ private String street; + /** + * User instance + */ + private User user; + /** * Remote user bean */ @@ -225,10 +230,12 @@ public class JobsAdminUserWebSessionBean implements JobsAdminUserWebSessionContr @Override public void addUser () { // Create new user instance - User user = new LoginUser(); - user.setUserName(this.getUserName()); - user.setUserAccountStatus(UserAccountStatus.CONFIRMED); - user.setUserProfileMode(ProfileMode.INVISIBLE); + User localUser = new LoginUser(); + + // Set user name, CONFIRMED and INVISIBLE + localUser.setUserName(this.getUserName()); + localUser.setUserAccountStatus(UserAccountStatus.CONFIRMED); + localUser.setUserProfileMode(ProfileMode.INVISIBLE); // Generate phone number DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber()); @@ -305,25 +312,25 @@ public class JobsAdminUserWebSessionBean implements JobsAdminUserWebSessionContr contact.setContactComment(this.getComment()); // Set contact in user - user.setUserContact(contact); + localUser.setUserContact(contact); // Init variable for password String password = null; // Is the user name or email address used already? // @TODO Add password length check - if (this.userController.isUserNameRegistered(user)) { + if (this.userController.isUserNameRegistered(localUser)) { // User name is already used - throw new FaceletException(new UserNameAlreadyRegisteredException(user)); - } else if (this.userController.isEmailAddressRegistered(user)) { + throw new FaceletException(new UserNameAlreadyRegisteredException(localUser)); + } else if (this.userController.isEmailAddressRegistered(localUser)) { // Email address is already used - throw new FaceletException(new EmailAddressAlreadyRegisteredException(user)); - } else if ((this.getUserPassword().isEmpty()) && (this.getUserPasswordRepeat().isEmpty())) { + throw new FaceletException(new EmailAddressAlreadyRegisteredException(localUser)); + } else if ((this.getUserPassword() == null && (this.getUserPasswordRepeat() == null)) || ((this.getUserPassword().isEmpty()) && (this.getUserPasswordRepeat().isEmpty()))) { // Empty password entered, then generate one password = UserUtils.createRandomPassword(JobsUserWebSessionController.MINIMUM_PASSWORD_LENGTH); } else if (!this.isSamePasswordEntered()) { // Both passwords don't match - throw new FaceletException(new UserPasswordMismatchException(user)); + throw new FaceletException(new UserPasswordMismatchException(localUser)); } else { // Both match, so get it from this bean password = this.getUserPassword(); @@ -334,14 +341,14 @@ public class JobsAdminUserWebSessionBean implements JobsAdminUserWebSessionContr assert (password.length() >= JobsUserWebSessionController.MINIMUM_PASSWORD_LENGTH) : "Password is not long enough."; //NOI18N // Encrypt password and set it - user.setUserEncryptedPassword(UserUtils.encryptPassword(password)); + localUser.setUserEncryptedPassword(UserUtils.encryptPassword(password)); // Init updated user instance User updatedUser = null; try { // Now, that all is set, call EJB - updatedUser = this.userBean.addUser(user); + updatedUser = this.userBean.addUser(localUser); } catch (final UserNameAlreadyRegisteredException | EmailAddressAlreadyRegisteredException ex) { // Throw again throw new FaceletException(ex); @@ -543,6 +550,16 @@ public class JobsAdminUserWebSessionBean implements JobsAdminUserWebSessionContr this.street = street; } + @Override + public User getUser () { + return this.user; + } + + @Override + public void setUser (final User user) { + this.user = user; + } + @Override public String getUserName () { return this.userName; @@ -652,6 +669,9 @@ public class JobsAdminUserWebSessionBean implements JobsAdminUserWebSessionContr this.setUserPassword(null); this.setUserPasswordRepeat(null); this.setZipCode(null); + + // - user instance + this.setUser(null); } /** diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebSessionController.java b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebSessionController.java index 3580232d..3a853738 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsAdminUserWebSessionController.java @@ -317,6 +317,20 @@ public interface JobsAdminUserWebSessionController extends Serializable { */ void setStreet (final String street); + /** + * Getter for user instance (e.g. from show_user) + *

+ * @return User instance + */ + User getUser (); + + /** + * Setter for user instance (e.g. from show_user) + *

+ * @param user User instance + */ + void setUser (final User user); + /** * Getter for user name *

diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java index 14c133ec..b82e653a 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java @@ -172,11 +172,6 @@ public class JobsUserWebSessionBean implements JobsUserWebSessionController { */ private String street; - /** - * User instance - */ - private User user; - /** * Remote user bean */ @@ -691,16 +686,6 @@ public class JobsUserWebSessionBean implements JobsUserWebSessionController { this.street = street; } - @Override - public User getUser () { - return this.user; - } - - @Override - public void setUser (final User user) { - this.user = user; - } - @Override public Long getUserId () { return this.userId; @@ -928,9 +913,6 @@ public class JobsUserWebSessionBean implements JobsUserWebSessionController { this.setUserName(null); this.setUserPassword(null); this.setUserPasswordRepeat(null); - - // - user instance - this.setUser(null); } /** diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java index 8a01448b..092f904b 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java @@ -346,20 +346,6 @@ public interface JobsUserWebSessionController extends Serializable { */ void setStreet (final String street); - /** - * Getter for user instance (e.g. from show_user) - *

- * @return User instance - */ - User getUser (); - - /** - * Setter for user instance (e.g. from show_user) - *

- * @param user User instance - */ - void setUser (final User user); - /** * Getter for user id *

diff --git a/web/admin/user/admin_user_show.xhtml b/web/admin/user/admin_user_show.xhtml index 4e5ed9c0..350b1914 100644 --- a/web/admin/user/admin_user_show.xhtml +++ b/web/admin/user/admin_user_show.xhtml @@ -9,7 +9,7 @@ > - + @@ -20,32 +20,32 @@ - + - + - - + + - + - + - + @@ -53,7 +53,7 @@ - + @@ -61,19 +61,19 @@ - + - + - + @@ -81,13 +81,13 @@ - + - + @@ -95,7 +95,7 @@ - + @@ -103,81 +103,81 @@ - + - + - + - + - + - + - + - + - + - - + + - + - + - - + +