]> git.mxchange.org Git - pizzaservice-war.git/blobdiff - src/java/org/mxchange/pizzaapplication/beans/user/PizzaAdminUserWebSessionBean.java
A bit cleanup and introduced private method:
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / user / PizzaAdminUserWebSessionBean.java
index 4f33d8446654935f795ed28fe8ca1be026c34230..c78ed89b27d464999f8c604183efc6630e64a264 100644 (file)
@@ -49,6 +49,7 @@ import org.mxchange.jusercore.model.user.User;
 import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
 import org.mxchange.jusercore.model.user.UserUtils;
 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
+import org.mxchange.jusercore.model.user.status.UserAccountStatus;
 
 /**
  * A user bean (controller)
@@ -160,11 +161,6 @@ public class PizzaAdminUserWebSessionBean implements PizzaAdminUserWebSessionCon
         */
        private final UserSessionBeanRemote userBean;
 
-       /**
-        * User id
-        */
-       private Long userId;
-
        /**
         * A list of all user profiles
         */
@@ -185,11 +181,6 @@ public class PizzaAdminUserWebSessionBean implements PizzaAdminUserWebSessionCon
         */
        private String userPasswordRepeat;
 
-       /**
-        * Whether the user wants a public profile
-        */
-       private ProfileMode userProfileMode;
-
        /**
         * ZIP code
         */
@@ -226,7 +217,8 @@ public class PizzaAdminUserWebSessionBean implements PizzaAdminUserWebSessionCon
                // Create new user instance
                User user = new LoginUser();
                user.setUserName(this.getUserName());
-               user.setUserProfileMode(this.getUserProfileMode());
+               user.setUserAccountStatus(UserAccountStatus.CONFIRMED);
+               user.setUserProfileMode(ProfileMode.INVISIBLE);
 
                // Generate phone number
                DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
@@ -316,7 +308,7 @@ public class PizzaAdminUserWebSessionBean implements PizzaAdminUserWebSessionCon
                } else if (this.userController.isEmailAddressRegistered(user)) {
                        // Email address is already used
                        throw new FaceletException(new EmailAddressAlreadyRegisteredException(user));
-               } else if ((this.getUserPassword().isEmpty()) && (this.getUserPasswordRepeat().isEmpty())) {
+               } 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()) {
@@ -341,6 +333,9 @@ public class PizzaAdminUserWebSessionBean implements PizzaAdminUserWebSessionCon
                        // Throw again
                        throw new FaceletException(ex);
                }
+
+               // Clear all
+               this.clear();
        }
 
        @Override
@@ -529,16 +524,6 @@ public class PizzaAdminUserWebSessionBean implements PizzaAdminUserWebSessionCon
                this.street = street;
        }
 
-       @Override
-       public Long getUserId () {
-               return this.userId;
-       }
-
-       @Override
-       public void setUserId (final Long userId) {
-               this.userId = userId;
-       }
-
        @Override
        public String getUserName () {
                return this.userName;
@@ -569,16 +554,6 @@ public class PizzaAdminUserWebSessionBean implements PizzaAdminUserWebSessionCon
                this.userPasswordRepeat = userPasswordRepeat;
        }
 
-       @Override
-       public ProfileMode getUserProfileMode () {
-               return this.userProfileMode;
-       }
-
-       @Override
-       public void setUserProfileMode (final ProfileMode userProfileMode) {
-               this.userProfileMode = userProfileMode;
-       }
-
        @Override
        public Integer getZipCode () {
                return this.zipCode;
@@ -640,4 +615,33 @@ public class PizzaAdminUserWebSessionBean implements PizzaAdminUserWebSessionCon
                return user;
        }
 
+       /**
+        * Clears this bean
+        */
+       private void clear () {
+               // Clear all
+               this.setBirthday(null);
+               this.setCellphoneCarrier(null);
+               this.setCellphoneNumber(null);
+               this.setCity(null);
+               this.setComment(null);
+               this.setCountry(null);
+               this.setEmailAddress(null);
+               this.setFamilyName(null);
+               this.setFaxAreaCode(null);
+               this.setFaxCountry(null);
+               this.setFaxNumber(null);
+               this.setFirstName(null);
+               this.setGender(null);
+               this.setHouseNumber(null);
+               this.setPhoneAreaCode(null);
+               this.setPhoneCountry(null);
+               this.setPhoneNumber(null);
+               this.setStreet(null);
+               this.setUserName(null);
+               this.setUserPassword(null);
+               this.setUserPasswordRepeat(null);
+               this.setZipCode(null);
+       }
+
 }