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=d93ee1be2e857f49a1a1dcc948f5b8024dd97406;p=jfinancials-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/addressbook/beans/user/AddressbookAdminUserWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebSessionBean.java index ff99674c..21590321 100644 --- a/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebSessionBean.java @@ -166,6 +166,11 @@ public class AddressbookAdminUserWebSessionBean implements AddressbookAdminUserW */ private String street; + /** + * User instance + */ + private User user; + /** * Remote user bean */ @@ -225,10 +230,12 @@ public class AddressbookAdminUserWebSessionBean implements AddressbookAdminUserW @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 AddressbookAdminUserWebSessionBean implements AddressbookAdminUserW 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(AddressbookUserWebSessionController.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 AddressbookAdminUserWebSessionBean implements AddressbookAdminUserW assert (password.length() >= AddressbookUserWebSessionController.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 AddressbookAdminUserWebSessionBean implements AddressbookAdminUserW 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 AddressbookAdminUserWebSessionBean implements AddressbookAdminUserW this.setUserPassword(null); this.setUserPasswordRepeat(null); this.setZipCode(null); + + // - user instance + this.setUser(null); } /** diff --git a/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebSessionController.java b/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebSessionController.java index 26f734ca..62824e66 100644 --- a/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebSessionController.java +++ b/src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebSessionController.java @@ -317,6 +317,20 @@ public interface AddressbookAdminUserWebSessionController 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/addressbook/beans/user/AddressbookUserWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java index 6c8e6c88..12d19b02 100644 --- a/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java @@ -182,11 +182,6 @@ public class AddressbookUserWebSessionBean implements AddressbookUserWebSessionC */ private String street; - /** - * User instance - */ - private User user; - /** * Remote user bean */ @@ -648,16 +643,6 @@ public class AddressbookUserWebSessionBean implements AddressbookUserWebSessionC 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; @@ -885,9 +870,6 @@ public class AddressbookUserWebSessionBean implements AddressbookUserWebSessionC this.setUserName(null); this.setUserPassword(null); this.setUserPasswordRepeat(null); - - // - user instance - this.setUser(null); } /** diff --git a/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionController.java b/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionController.java index c2f385cf..769c8795 100644 --- a/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionController.java +++ b/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionController.java @@ -374,20 +374,6 @@ public interface AddressbookUserWebSessionController 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 @@ - + - + - + - + - + - + - + - + - + - - + + - + - + - - + +