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=2a85168947fbe27657d7f45e5f09ffdb6c079412;p=pizzaservice-war.git moved user instance to admin controller as this is the right one for this purpose --- diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebSessionBean.java index 37053fb4..772b5b60 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebSessionBean.java @@ -166,6 +166,11 @@ public class PizzaAdminUserWebSessionBean implements PizzaAdminUserWebSessionCon */ private String street; + /** + * User instance + */ + private User user; + /** * Remote user bean */ @@ -225,10 +230,12 @@ public class PizzaAdminUserWebSessionBean implements PizzaAdminUserWebSessionCon @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 PizzaAdminUserWebSessionBean implements PizzaAdminUserWebSessionCon 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)); + 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(PizzaUserWebSessionController.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 PizzaAdminUserWebSessionBean implements PizzaAdminUserWebSessionCon assert (password.length() >= PizzaUserWebSessionController.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 PizzaAdminUserWebSessionBean implements PizzaAdminUserWebSessionCon 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 PizzaAdminUserWebSessionBean implements PizzaAdminUserWebSessionCon this.setUserPassword(null); this.setUserPasswordRepeat(null); this.setZipCode(null); + + // - user instance + this.setUser(null); } /** diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebSessionController.java index dc8e7394..809ce8c3 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebSessionController.java @@ -317,6 +317,20 @@ public interface PizzaAdminUserWebSessionController 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/pizzaapplication/beans/user/PizzaUserWebSessionBean.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java index 1b6bb0c2..4d23d552 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java @@ -182,11 +182,6 @@ public class PizzaUserWebSessionBean implements PizzaUserWebSessionController { */ private String street; - /** - * User instance - */ - private User user; - /** * Remote user bean */ @@ -648,16 +643,6 @@ public class PizzaUserWebSessionBean implements PizzaUserWebSessionController { 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 PizzaUserWebSessionBean implements PizzaUserWebSessionController { this.setUserName(null); this.setUserPassword(null); this.setUserPasswordRepeat(null); - - // - user instance - this.setUser(null); } /** diff --git a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java index 3092362b..2eff8017 100644 --- a/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java +++ b/src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionController.java @@ -374,20 +374,6 @@ public interface PizzaUserWebSessionController 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 @@ - + - + - + - + - + - + - + - + - + - - + + - + - + - - + +