]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Sun, 9 Jul 2017 10:53:03 +0000 (12:53 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 10 Jul 2017 17:54:52 +0000 (19:54 +0200)
- renamed bean to userConfirmationLinkController
- always handle returned (mostly updated/managed) entities, then the updated
  data is being handled

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jfinancials/beans/contact/FinancialsAdminContactWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/phone/FinancialsAdminPhoneWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/profile/FinancialsUserProfileWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/user/confirmlink/FinancialsConfirmationLinkWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/user/resendlink/FinancialsResendLinkWebSessionBean.java
web/guest/user/user_confirm_account.xhtml

index 44c3fc97678e90885ba0eee61e7ad561a289d743..0c43937a2fcc1a7d79e72895ed9600432d3c846e 100644 (file)
@@ -33,9 +33,9 @@ import javax.naming.NamingException;
 import org.mxchange.jcontacts.contact.AdminContactSessionBeanRemote;
 import org.mxchange.jcontacts.contact.Contact;
 import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
+import org.mxchange.jcontacts.contact.ContactUtils;
 import org.mxchange.jcontacts.contact.UserContact;
 import org.mxchange.jcontacts.contact.title.PersonalTitle;
-import org.mxchange.jcontacts.contact.ContactUtils;
 import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
 import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
 import org.mxchange.jcontacts.events.contact.update.AdminUpdatedContactEvent;
@@ -66,6 +66,10 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsControll
         * Serial number
         */
        private static final long serialVersionUID = 542_145_347_916L;
+       /**
+        * Academic academicTitle
+        */
+       private String academicTitle;
 
        /**
         * An event fired when the administrator has added a new contact
@@ -226,10 +230,6 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsControll
         */
        private String street;
 
-       /**
-        * Academic academicTitle
-        */
-       private String academicTitle;
 
        /**
         * An event fired when the administrator has updated contact data
@@ -541,6 +541,14 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsControll
                // Return it
                return number;
        }
+       @Override
+       public String getAcademicTitle () {
+               return this.academicTitle;
+       }
+       @Override
+       public void setAcademicTitle (final String academicTitle) {
+               this.academicTitle = academicTitle;
+       }
 
        @Override
        @SuppressWarnings ("ReturnOfDateField")
@@ -785,15 +793,6 @@ public class FinancialsAdminContactWebRequestBean extends BaseFinancialsControll
                this.street = street;
        }
 
-       @Override
-       public String getAcademicTitle () {
-               return this.academicTitle;
-       }
-
-       @Override
-       public void setAcademicTitle (final String academicTitle) {
-               this.academicTitle = academicTitle;
-       }
 
        @Override
        public Integer getZipCode () {
index 95665b481005770f9328b87015dd0d8c3e661e0f..24f797584eeb013b6d45fb238dc012682ea3f0a6 100644 (file)
@@ -91,15 +91,6 @@ public class FinancialsAdminPhoneWebRequestBean extends BaseFinancialsController
         */
        private DialableFaxNumber faxNumber;
 
-       /**
-        * land-line number
-        */
-       private DialableLandLineNumber landLineNumber;
-
-       /**
-        * mobile number
-        */
-       private DialableMobileNumber mobileNumber;
 
        /**
         * Event being fired when an administrator has deleted fax number
@@ -114,6 +105,10 @@ public class FinancialsAdminPhoneWebRequestBean extends BaseFinancialsController
        @Inject
        @Any
        private Event<AdminUpdatedFaxNumberEvent> faxNumberUpdatedEvent;
+       /**
+        * land-line number
+        */
+       private DialableLandLineNumber landLineNumber;
 
        /**
         * Event being fired when an administrator has deleted land-line number
@@ -128,6 +123,10 @@ public class FinancialsAdminPhoneWebRequestBean extends BaseFinancialsController
        @Inject
        @Any
        private Event<AdminUpdatedLandLineNumberEvent> landLineNumberUpdatedEvent;
+       /**
+        * mobile number
+        */
+       private DialableMobileNumber mobileNumber;
 
        /**
         * Event being fired when an administrator has deleted mobile number
index 2b8a917afcbf222acab7547b614496e40c2f79c4..6f2820f535f8e3a96f60db5ae408c8a342b2498c 100644 (file)
@@ -23,8 +23,8 @@ import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
 import javax.inject.Named;
 import org.mxchange.jfinancials.beans.BaseFinancialsController;
-import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
 import org.mxchange.jfinancials.beans.user.FinancialsUserWebSessionController;
+import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
 import org.mxchange.jusercore.exceptions.UserNotFoundException;
 import org.mxchange.jusercore.model.user.User;
 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
index 2aaf032b7b6970da5a3f78ddf6f520e209f817d0..e29b63e250f9cbd8edbb2922c4951c127220516f 100644 (file)
@@ -47,7 +47,7 @@ import org.mxchange.jusercore.model.user.status.UserAccountStatus;
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@Named ("confirmationLinkController")
+@Named ("userConfirmationLinkController")
 @RequestScoped
 public class FinancialsConfirmationLinkWebRequestBean extends BaseFinancialsController implements FinancialsConfirmationLinkWebRequestController {
 
@@ -123,6 +123,9 @@ public class FinancialsConfirmationLinkWebRequestBean extends BaseFinancialsCont
 
        @Override
        public void maybeConfirmUserAccount () {
+               // Trace message
+               System.out.println(MessageFormat.format("{0}.maybeConfirmAccount: CALLED!", this.getClass().getSimpleName())); //NOI18N
+
                // Is the confirmation key set?
                if (this.getConfirmationKey() == null) {
                        // May be null if not set
@@ -135,6 +138,9 @@ public class FinancialsConfirmationLinkWebRequestBean extends BaseFinancialsCont
                // Now try to find the user in user list, first get the whole list
                List<User> users = this.userController.allUsers();
 
+               // Debug message
+               System.out.println(MessageFormat.format("{0}.maybeConfirmAccount: users.size()={1}", this.getClass().getSimpleName(), users.size())); //NOI18N
+
                // Get iterator from it
                Iterator<User> iterator = users.iterator();
 
@@ -146,41 +152,49 @@ public class FinancialsConfirmationLinkWebRequestBean extends BaseFinancialsCont
                        // Get next user
                        User next = iterator.next();
 
+                       // Debug message
+                       System.out.println(MessageFormat.format("{0}.maybeConfirmAccount: this.confirmationKey={1},next.confirmationKey={2}", this.getClass().getSimpleName(), this.getConfirmationKey(), next.getUserConfirmKey())); //NOI18N
+
                        // Same confirmation key?
                        if (Objects.equals(this.getConfirmationKey(), next.getUserConfirmKey())) {
+                               // Debug message
+                               System.out.println(MessageFormat.format("{0}.maybeConfirmAccount: next={1} - Aborting ...", this.getClass().getSimpleName(), next)); //NOI18N
+
                                // Found it, then set it and abort loop
                                user = next;
                                break;
                        }
                }
 
+               // Debug message
+               System.out.println(MessageFormat.format("{0}.maybeConfirmAccount: user={1}", this.getClass().getSimpleName(), user)); //NOI18N
+
                // Is the user instance null?
                if ((null == user) || (user.getUserAccountStatus() != UserAccountStatus.UNCONFIRMED)) {
                        // Then clear this bean and the helper
                        this.beanHelper.setUser(null);
                } else {
-                       // Set user ...
-                       this.beanHelper.setUser(user);
-
-                       // ... and copy it to the controller
-                       this.beanHelper.copyUserToController();
-
                        // Try to confirm it
-                       this.confirmUserAccount();
+                       this.confirmUserAccount(user);
                }
+
+               // Trace message
+               System.out.println(MessageFormat.format("{0}.maybeConfirmAccount: EXIT!", this.getClass().getSimpleName())); //NOI18N
        }
 
        /**
         * Tries to confirm the currently set user instance (in helper).
+        * <p>
+        * @param user User instance
         */
-       private void confirmUserAccount () {
-               // Get user instance
-               User user = this.beanHelper.getUser();
+       private void confirmUserAccount (final User user) {
+               // Trace message
+               System.out.println(MessageFormat.format("{0}.confirmUserAccount: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
 
                // Should be set
                if (null == user) {
                        // Throw NPE
-                       throw new NullPointerException("user is null");
+                       throw new NullPointerException("user is null"); //NOI18N
                } else if (user.getUserId() == null) {
                        // Abort here
                        throw new NullPointerException("user.userId is null"); //NOI18N
@@ -196,6 +210,9 @@ public class FinancialsConfirmationLinkWebRequestBean extends BaseFinancialsCont
                } else if (user.getUserConfirmKey() == null) {
                        // Throw NPE
                        throw new NullPointerException("user.userConfirmKey is null"); //NOI18N
+               } else if (user.getUserConfirmKey().isEmpty()) {
+                       // Is empty string
+                       throw new IllegalArgumentException("user.userConfirmKey is empty"); //NOI18N
                }
 
                // Updated user instance
@@ -205,8 +222,14 @@ public class FinancialsConfirmationLinkWebRequestBean extends BaseFinancialsCont
                        // Get base URL
                        String baseUrl = FacesUtils.generateBaseUrl();
 
+                       // Debug message
+                       System.out.println(MessageFormat.format("{0}.confirmUserAccount: baseUrl={1}", this.getClass().getSimpleName(), baseUrl)); //NOI18N
+
                        // Confirm account
                        updatedUser = this.userBean.confirmAccount(user, baseUrl);
+
+                       // Debug message
+                       System.out.println(MessageFormat.format("{0}.confirmUserAccount: updatedUser={1} - Returned from EJB", this.getClass().getSimpleName(), updatedUser)); //NOI18N
                } catch (final UserStatusConfirmedException | UserStatusLockedException ex) {
                        // Something unexpected happened
                        throw new FaceletException(MessageFormat.format("Cannot confirm user account {0}", user.getUserName()), ex); //NOI18N
@@ -215,8 +238,17 @@ public class FinancialsConfirmationLinkWebRequestBean extends BaseFinancialsCont
                // Fire event that the user has confirmed account
                this.userConfirmedEvent.fire(new UserConfirmedAccountEvent(updatedUser));
 
+               // Debug message
+               System.out.println(MessageFormat.format("{0}.confirmUserAccount: updatedUser={1}", this.getClass().getSimpleName(), updatedUser)); //NOI18N
+
                // Set it again in helper
                this.beanHelper.setUser(updatedUser);
+
+               // ... and copy it to the controller
+               this.beanHelper.copyUserToController();
+
+               // Trace message
+               System.out.println(MessageFormat.format("{0}.confirmUserAccount: EXIT!", this.getClass().getSimpleName())); //NOI18N
        }
 
 }
index b2003932358da1b83c7bb00f68156aa928d50b60..b6399e6306c844562f56f6b84d5642967b6bdcb2 100644 (file)
@@ -36,8 +36,8 @@ import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
 import org.mxchange.jusercore.exceptions.UserNotFoundException;
 import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
 import org.mxchange.jusercore.exceptions.UserStatusLockedException;
-import org.mxchange.jusercore.model.user.resendlink.ResendLinkSessionBeanRemote;
 import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.resendlink.ResendLinkSessionBeanRemote;
 import org.mxchange.jusercore.model.user.status.UserAccountStatus;
 
 /**
@@ -134,12 +134,15 @@ public class FinancialsResendLinkWebSessionBean extends BaseFinancialsController
                        throw new NullPointerException("user.userConfirmKey is null"); //NOI18N
                }
 
+               // Init managed user instance
+               User managedUser;
+
                try {
                        // Get base URL
                        String baseUrl = FacesUtils.generateBaseUrl();
 
                        // Call EJB and return redirect target
-                       this.resendLinkBean.resendConfirmationLink(user, this.localizationController.getLocale(), baseUrl);
+                       managedUser = this.resendLinkBean.resendConfirmationLink(user, this.localizationController.getLocale(), baseUrl);
                } catch (final UserNotFoundException ex) {
                        // User not found
                        this.showFacesMessage("form_resend_link:resendEmailAddress", "ERROR_USER_NOT_FOUND"); //NOI18N
@@ -150,12 +153,12 @@ public class FinancialsResendLinkWebSessionBean extends BaseFinancialsController
                        return ""; //NOI18N
                }
 
-               // Fire event
-               this.userResendLinkEvent.fire(new UserResendLinkAccountEvent(user));
-
                // Clear this bean
                this.clear();
 
+               // Fire event
+               this.userResendLinkEvent.fire(new UserResendLinkAccountEvent(managedUser));
+
                // Return redirect target
                return "user_resend_done"; //NOI18N
        }
index aeb797b41f4688bfd7d613e7c009852cfbbeaba1..a49b6eaadb22c38d940d0f944c3924669f907727 100644 (file)
@@ -10,8 +10,8 @@
        <ui:composition template="/WEB-INF/templates/guest/guest_base.tpl">
                <ui:define name="metadata">
                        <f:metadata>
-                               <f:viewParam name="confirmKey" value="#{confirmationLinkController.confirmationKey}" />
-                               <f:viewAction onPostback="true" action="#{confirmationLinkController.maybeConfirmUserAccount()}" />
+                               <f:viewParam name="confirmKey" value="#{userConfirmationLinkController.confirmationKey}" />
+                               <f:viewAction onPostback="true" action="#{userConfirmationLinkController.maybeConfirmUserAccount()}" />
                        </f:metadata>
                </ui:define>
 
@@ -24,7 +24,7 @@
                </ui:define>
 
                <ui:define name="content">
-                       <ui:fragment rendered="#{not empty confirmationLinkController.confirmationKey}">
+                       <ui:fragment rendered="#{not empty userConfirmationLinkController.confirmationKey}">
                                <h:panelGroup styleClass="table" layout="block" rendered="#{not empty beanHelper.user}">
                                        <div class="table_header">
                                                <h:outputText value="#{msg.GUEST_CONFIRM_USER_ACCOUNT_DONE_TITLE}" />
@@ -47,7 +47,7 @@
                                </ui:fragment>
                        </ui:fragment>
 
-                       <ui:fragment rendered="#{empty confirmationLinkController.confirmationKey}">
+                       <ui:fragment rendered="#{empty userConfirmationLinkController.confirmationKey}">
                                <ui:include src="/WEB-INF/templates/generic/message_box.tpl">
                                        <ui:param name="message" value="#{msg.GUEST_CONFIRMATION_KEY_NOT_SET}" />
                                        <ui:param name="styleClass" value="errors" />