]> git.mxchange.org Git - jfinancials-war.git/commitdiff
moved user instance to admin controller as this is the right one for this purpose
authorRoland Haeder <roland@mxchange.org>
Mon, 18 Apr 2016 19:36:41 +0000 (21:36 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 18 Apr 2016 19:37:32 +0000 (21:37 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebSessionBean.java
src/java/org/mxchange/addressbook/beans/user/AddressbookAdminUserWebSessionController.java
src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java
src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionController.java
web/admin/user/admin_user_show.xhtml

index ff99674cf76b6dcbec3d37c702a4a1b03f5b9355..2159032181abf599a68fc4cd7c7e933ad441d391 100644 (file)
@@ -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);
        }
 
        /**
index 26f734ca20d1037f7584773ddd8a609574684fe7..62824e663d4b76e1af9ac3ba2df4cff195538e1d 100644 (file)
@@ -317,6 +317,20 @@ public interface AddressbookAdminUserWebSessionController extends Serializable {
         */
        void setStreet (final String street);
 
+       /**
+        * Getter for user instance (e.g. from show_user)
+        * <p>
+        * @return User instance
+        */
+       User getUser ();
+
+       /**
+        * Setter for user instance (e.g. from show_user)
+        * <p>
+        * @param user User instance
+        */
+       void setUser (final User user);
+
        /**
         * Getter for user name
         * <p>
index 6c8e6c887cdcd2b4dfa35b4ad75dc2dabb6f00a7..12d19b022d438bb6e8d22ca83192b77cbe590e79 100644 (file)
@@ -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);
        }
 
        /**
index c2f385cf846889f3fd265c56b82c18ecafaea4ef..769c879551eb3fcbcd47b06840b9931cd47a8cd7 100644 (file)
@@ -374,20 +374,6 @@ public interface AddressbookUserWebSessionController extends Serializable {
         */
        void setStreet (final String street);
 
-       /**
-        * Getter for user instance (e.g. from show_user)
-        * <p>
-        * @return User instance
-        */
-       User getUser ();
-
-       /**
-        * Setter for user instance (e.g. from show_user)
-        * <p>
-        * @param user User instance
-        */
-       void setUser (final User user);
-
        /**
         * Getter for user id
         * <p>
index 4e5ed9c00541ae636deee3c31c8bf9674f89f192..350b191406d35deff74d72ac9d9163a42e44a2ea 100644 (file)
@@ -9,7 +9,7 @@
        >
 
        <f:metadata>
-               <f:viewParam name="userId" value="#{userController.user}" converter="UserConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_USER_ID_NOT_SET}" />
+               <f:viewParam name="userId" value="#{adminUserController.user}" converter="UserConverter" required="true" requiredMessage="#{msg.ERROR_PARAMETER_USER_ID_NOT_SET}" />
        </f:metadata>
 
        <ui:composition template="/WEB-INF/templates/admin/admin_base.tpl">
                </ui:define>
 
                <ui:define name="content">
-                       <h:outputText styleClass="errors" value="#{msg.ERROR_USER_ID_NOT_FOUND}" rendered="#{empty userController.user}" />
+                       <h:outputText styleClass="errors" value="#{msg.ERROR_USER_ID_NOT_FOUND}" rendered="#{empty adminUserController.user}" />
 
-                       <h:panelGrid id="user_profile" summary="#{msg.ADMIN_TABLE_SUMMARY_SHOW_USER}" headerClass="table_header_column" styleClass="table_big" columns="3" rendered="#{not empty userController.user}">
+                       <h:panelGrid id="user_profile" summary="#{msg.ADMIN_TABLE_SUMMARY_SHOW_USER}" headerClass="table_header_column" styleClass="table_big" columns="3" rendered="#{not empty adminUserController.user}">
                                <f:facet name="header">
                                        <h:outputFormat value="#{msg.ADMIN_HEADER_SHOW_USER}">
-                                               <f:param value="#{userController.user.userName}" />
-                                               <f:param value="#{userController.user.userId}" />
+                                               <f:param value="#{adminUserController.user.userName}" />
+                                               <f:param value="#{adminUserController.user.userId}" />
                                        </h:outputFormat>
                                </f:facet>
 
                                <h:column>
                                        <h:outputLabel for="userId" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_ID}" />
 
-                                       <h:outputText id="userId" styleClass="data_field" value="#{userController.user.userId}" />
+                                       <h:outputText id="userId" styleClass="data_field" value="#{adminUserController.user.userId}" />
                                </h:column>
 
                                <h:column>
                                        <h:outputLabel for="userName" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_NAME}" />
 
-                                       <h:outputText id="userName" styleClass="data_field" value="#{userController.user.userName}" />
+                                       <h:outputText id="userName" styleClass="data_field" value="#{adminUserController.user.userName}" />
                                </h:column>
 
                                <h:column>
                                        <h:outputLabel for="userCreated" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_CREATED}" />
 
-                                       <h:outputText id="userCreated" styleClass="data_field" value="#{userController.user.userCreated.time}">
+                                       <h:outputText id="userCreated" styleClass="data_field" value="#{adminUserController.user.userCreated.time}">
                                                <f:convertDateTime for="userCreated" type="both" />
                                        </h:outputText>
                                </h:column>
@@ -53,7 +53,7 @@
                                <h:column>
                                        <h:outputLabel for="userUpdated" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_UPDATED}" />
 
-                                       <h:outputText id="userUpdated" styleClass="data_field" value="#{userController.user.userUpdated.time}">
+                                       <h:outputText id="userUpdated" styleClass="data_field" value="#{adminUserController.user.userUpdated.time}">
                                                <f:convertDateTime for="userUpdated" type="both" />
                                        </h:outputText>
                                </h:column>
                                <h:column>
                                        <h:outputLabel for="userAccountStatus" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_ACCOUNT_STATUS}" />
 
-                                       <h:outputText id="userAccountStatus" styleClass="data_field #{userController.user.userAccountStatus.styleClass}" value="#{msg[userController.user.userAccountStatus.messageKey]}" />
+                                       <h:outputText id="userAccountStatus" styleClass="data_field #{adminUserController.user.userAccountStatus.styleClass}" value="#{msg[adminUserController.user.userAccountStatus.messageKey]}" />
                                </h:column>
 
                                <h:column>
                                        <h:outputLabel for="userProfileMode" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_PROFILE_MODE}" />
 
-                                       <h:outputText id="userProfileMode" styleClass="data_field" value="#{msg[userController.user.userProfileMode.messageKey]}" />
+                                       <h:outputText id="userProfileMode" styleClass="data_field" value="#{msg[adminUserController.user.userProfileMode.messageKey]}" />
                                </h:column>
 
                                <h:column>
                                        <h:outputLabel for="userLastLocked" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_LAST_LOCKED}" />
 
-                                       <h:outputText id="userLastLocked" styleClass="data_field" value="#{userController.user.userLastLocked.time}">
+                                       <h:outputText id="userLastLocked" styleClass="data_field" value="#{adminUserController.user.userLastLocked.time}">
                                                <f:convertDateTime for="userLastLocked" type="both" />
                                        </h:outputText>
                                </h:column>
                                <h:column>
                                        <h:outputLabel for="lastLockedReason" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_LAST_LOCKED_REASON}" />
 
-                                       <h:outputText id="lastLockedReason" styleClass="data_field" value="#{userController.user.lastLockedReason}" />
+                                       <h:outputText id="lastLockedReason" styleClass="data_field" value="#{adminUserController.user.lastLockedReason}" />
                                </h:column>
 
                                <h:column>
                                        <h:outputLabel for="contactCreated" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_CONTACT_CREATED}" />
 
-                                       <h:outputText id="contactCreated" styleClass="data_field" value="#{userController.user.userContact.contactCreated.time}">
+                                       <h:outputText id="contactCreated" styleClass="data_field" value="#{adminUserController.user.userContact.contactCreated.time}">
                                                <f:convertDateTime for="contactCreated" type="both" />
                                        </h:outputText>
                                </h:column>
@@ -95,7 +95,7 @@
                                <h:column>
                                        <h:outputLabel for="contactUpdated" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_CONTACT_UPDATED}" />
 
-                                       <h:outputText id="contactUpdated" styleClass="data_field" value="#{userController.user.userContact.contactUpdated.time}">
+                                       <h:outputText id="contactUpdated" styleClass="data_field" value="#{adminUserController.user.userContact.contactUpdated.time}">
                                                <f:convertDateTime for="contactUpdated" type="both" />
                                        </h:outputText>
                                </h:column>
                                <h:column>
                                        <h:outputLabel for="isOwnContact" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_IS_OWN_CONTACT}" />
 
-                                       <h:outputText id="isOwnContact" styleClass="data_field" value="#{userController.user.userContact.isOwnContact()}" />
+                                       <h:outputText id="isOwnContact" styleClass="data_field" value="#{adminUserController.user.userContact.isOwnContact()}" />
                                </h:column>
 
                                <h:column>
                                        <h:outputLabel for="contactGender" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_GENDER}" />
 
-                                       <h:outputText id="contactGender" styleClass="data_field" value="#{msg[userController.user.userContact.contactGender.messageKey]}" />
+                                       <h:outputText id="contactGender" styleClass="data_field" value="#{msg[adminUserController.user.userContact.contactGender.messageKey]}" />
                                </h:column>
 
                                <h:column>
                                        <h:outputLabel for="contactTitle" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_TITLE}" />
 
-                                       <h:outputText id="contactTitle" styleClass="data_field" value="#{userController.user.userContact.contactTitle}" />
+                                       <h:outputText id="contactTitle" styleClass="data_field" value="#{adminUserController.user.userContact.contactTitle}" />
                                </h:column>
 
                                <h:column>
                                        <h:outputLabel for="contactFirstName" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_FIRST_NAME}" />
 
-                                       <h:outputText id="contactFirstName" styleClass="data_field" value="#{userController.user.userContact.contactFirstName}" />
+                                       <h:outputText id="contactFirstName" styleClass="data_field" value="#{adminUserController.user.userContact.contactFirstName}" />
                                </h:column>
 
                                <h:column>
                                        <h:outputLabel for="contactFamilyName" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_FAMILY_NAME}" />
 
-                                       <h:outputText id="contactFamilyName" styleClass="data_field" value="#{userController.user.userContact.contactFamilyName}" />
+                                       <h:outputText id="contactFamilyName" styleClass="data_field" value="#{adminUserController.user.userContact.contactFamilyName}" />
                                </h:column>
 
                                <h:column>
                                        <h:outputLabel for="contactStreet" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_STREET}" />
 
-                                       <h:outputText id="contactStreet" styleClass="data_field" value="#{userController.user.userContact.contactStreet}" />
+                                       <h:outputText id="contactStreet" styleClass="data_field" value="#{adminUserController.user.userContact.contactStreet}" />
                                </h:column>
 
                                <h:column>
                                        <h:outputLabel for="contactHouseNumber" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_HOUSE_NUMBER}" />
 
-                                       <h:outputText id="contactHouseNumber" styleClass="data_field" value="#{userController.user.userContact.contactHouseNumber}" />
+                                       <h:outputText id="contactHouseNumber" styleClass="data_field" value="#{adminUserController.user.userContact.contactHouseNumber}" />
                                </h:column>
 
                                <h:column>
                                        <h:outputLabel for="contactZipCode" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_ZIP_CODE}" />
 
-                                       <h:outputText id="contactZipCode" styleClass="data_field" value="#{userController.user.userContact.contactZipCode}" />
+                                       <h:outputText id="contactZipCode" styleClass="data_field" value="#{adminUserController.user.userContact.contactZipCode}" />
                                </h:column>
 
                                <h:column>
                                        <h:outputLabel for="contactCity" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_CITY}" />
 
-                                       <h:outputText id="contactCity" styleClass="data_field" value="#{userController.user.userContact.contactCity}" />
+                                       <h:outputText id="contactCity" styleClass="data_field" value="#{adminUserController.user.userContact.contactCity}" />
                                </h:column>
 
                                <h:column>
                                        <h:outputLabel for="contactEmailAddress" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_EMAIL_ADDRESS}" />
 
-                                       <h:outputLink id="contactEmailAddress" styleClass="data_field" value="mailto:#{userController.user.userContact.contactEmailAddress}">
-                                               <h:outputText value="#{userController.user.userContact.contactEmailAddress}" />
+                                       <h:outputLink id="contactEmailAddress" styleClass="data_field" value="mailto:#{adminUserController.user.userContact.contactEmailAddress}">
+                                               <h:outputText value="#{adminUserController.user.userContact.contactEmailAddress}" />
                                        </h:outputLink>
                                </h:column>
 
                                <h:column>
                                        <h:outputLabel for="contactBirthday" styleClass="data_label" value="#{msg.ADMIN_SHOW_USER_BIRTHDAY}" />
 
-                                       <h:outputText id="contactBirthday" styleClass="data_field" value="#{userController.user.userContact.contactBirthday.time}">
+                                       <h:outputText id="contactBirthday" styleClass="data_field" value="#{adminUserController.user.userContact.contactBirthday.time}">
                                                <f:convertDateTime for="contactBirthday" type="date" />
                                        </h:outputText>
                                </h:column>
                        </h:panelGrid>
 
                        <ui:include src="/WEB-INF/templates/admin/user/admin_user_links.tpl">
-                               <ui:param name="user" value="#{userController.user}" />
+                               <ui:param name="user" value="#{adminUserController.user}" />
                        </ui:include>
 
                        <ui:include src="/WEB-INF/templates/admin/cellphone/admin_cellphone_data.tpl">
-                               <ui:param name="cellphoneNumber" value="#{userController.user.userContact.contactCellphoneNumber}" />
-                               <ui:param name="user" value="#{userController.user}" />
+                               <ui:param name="cellphoneNumber" value="#{adminUserController.user.userContact.contactCellphoneNumber}" />
+                               <ui:param name="user" value="#{adminUserController.user}" />
                        </ui:include>
                </ui:define>
        </ui:composition>