]> git.mxchange.org Git - jjobs-war.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Thu, 25 Aug 2016 13:47:34 +0000 (15:47 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 25 Aug 2016 18:36:31 +0000 (20:36 +0200)
- renamed event observer methods to have suffix "Event" in it
- added observer method afterUserResendConfirmationLinkEvent() for logging user activity

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionBean.java
src/java/org/mxchange/jjobs/beans/contact/JobsContactWebSessionController.java
src/java/org/mxchange/jjobs/beans/localization/JobsLocalizationSessionBean.java
src/java/org/mxchange/jjobs/beans/localization/JobsLocalizationSessionController.java
src/java/org/mxchange/jjobs/beans/resendlink/JobsResendLinkWebSessionBean.java
src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java
src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionController.java
src/java/org/mxchange/jjobs/beans/user/activity/JobsUserActivityWebApplicationBean.java
src/java/org/mxchange/jjobs/beans/user/activity/JobsUserActivityWebApplicationController.java

index 1f4ee396cbd9bf4b003f005e64adac801e3eb1c0..6108f6d2f22df28e1bde8752922b7f840ff87fc5 100644 (file)
@@ -485,7 +485,7 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
        }
 
        @Override
-       public void afterUserConfirmedAccountEvent (@Observes final UserConfirmedAccountEvent event) {
+       public void afterUserConfirmedAccountEventEvent (@Observes final UserConfirmedAccountEvent event) {
                // event should not be null
                if (null == event) {
                        // Throw NPE
@@ -506,7 +506,7 @@ public class JobsContactWebSessionBean extends BaseJobsController implements Job
        }
 
        @Override
-       public void afterUserLogin (@Observes final UserLoggedInEvent event) {
+       public void afterUserLoginEvent (@Observes final UserLoggedInEvent event) {
                // event should not be null
                if (null == event) {
                        // Throw NPE
index 70e20315dbb92b3a2fbd2e0cff633e3171122cd5..7a98cc3199137dd9c8e2eb32a6acfc2769483cad 100644 (file)
@@ -93,7 +93,7 @@ public interface JobsContactWebSessionController extends Serializable {
         * <p>
         * @param event Event being fired
         */
-       void afterUserConfirmedAccountEvent (final UserConfirmedAccountEvent event);
+       void afterUserConfirmedAccountEventEvent (final UserConfirmedAccountEvent event);
 
        /**
         * Event observer when a list with unused mobile numbers is being created
@@ -156,7 +156,7 @@ public interface JobsContactWebSessionController extends Serializable {
         * <p>
         * @param event Event instance
         */
-       void afterUserLogin (final UserLoggedInEvent event);
+       void afterUserLoginEvent (final UserLoggedInEvent event);
 
        /**
         * Creates an instance from all properties
index 388881649455744b3abb315373e24ca2a2171db6..c6eb7c4e76b15233c915fcd8bcaae72385b77560 100644 (file)
@@ -49,10 +49,7 @@ public class JobsLocalizationSessionBean extends BaseJobsController implements J
        private Locale locale;
 
        @Override
-       public void afterUserLogin (@Observes final UserLoggedInEvent event) {
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("LandingLocalizationSessionBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
-
+       public void afterUserLoginEvent (@Observes final UserLoggedInEvent event) {
                // event should not be null
                if (null == event) {
                        // Throw NPE
index d29f4db912663e4fc4cd1387e392f5b3883b78b3..37612465e23dc8f2eca0c1b844f0e4094c984eac 100644 (file)
@@ -32,7 +32,7 @@ public interface JobsLocalizationSessionController extends Serializable {
         * <p>
         * @param event Event instance
         */
-       void afterUserLogin (final UserLoggedInEvent event);
+       void afterUserLoginEvent (final UserLoggedInEvent event);
 
        /**
         * Getter for locale
index d5d17002ab0f7f92c8f39eb413e1103dcee430d3..2b1d0ceb35fdd1d0e35f13311cfc44394a79fa7f 100644 (file)
@@ -17,6 +17,8 @@
 package org.mxchange.jjobs.beans.resendlink;
 
 import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
 import javax.inject.Named;
@@ -27,7 +29,12 @@ import org.mxchange.jcoreee.utils.FacesUtils;
 import org.mxchange.jjobs.beans.BaseJobsController;
 import org.mxchange.jjobs.beans.localization.JobsLocalizationSessionController;
 import org.mxchange.jjobs.beans.user.JobsUserWebSessionController;
+import org.mxchange.jusercore.events.resendlink.ResendLinkUserAccountEvent;
+import org.mxchange.jusercore.events.resendlink.UserResendLinkAccountEvent;
 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.User;
 import org.mxchange.jusercore.model.user.status.UserAccountStatus;
 
@@ -67,6 +74,13 @@ public class JobsResendLinkWebSessionBean extends BaseJobsController implements
        @Inject
        private JobsUserWebSessionController userController;
 
+       /**
+        * Event being fired after confirmation link is being sent
+        */
+       @Inject
+       @Any
+       private Event<UserResendLinkAccountEvent> userResendLinkEvent;
+
        /**
         * Default constructor
         */
@@ -127,11 +141,24 @@ public class JobsResendLinkWebSessionBean extends BaseJobsController implements
                        throw new NullPointerException("user.userConfirmKey is null"); //NOI18N
                }
 
-               // Get base URL
-               String baseUrl = FacesUtils.generateBaseUrl();
+               try {
+                       // Get base URL
+                       String baseUrl = FacesUtils.generateBaseUrl();
+
+                       // Call EJB and return redirect target
+                       this.emailBean.resendConfirmationLink(user, this.localizationController.getLocale(), baseUrl);
+               } catch (final UserNotFoundException ex) {
+                       // User not found
+                       this.showFacesMessage("form_resend_link:resendEmailAddress", "ERROR_USER_NOT_FOUND"); //NOI18N
+                       return ""; //NOI18N
+               } catch (final UserStatusLockedException | UserStatusConfirmedException ex) {
+                       // Output message, this should not happen as the confirmation key is being removed
+                       this.showFacesMessage("form_resend_link:resendEmailAddress", ex); //NOI18N
+                       return ""; //NOI18N
+               }
 
-               // Call EJB and return redirect target
-               this.emailBean.resendConfirmationLink(user, this.localizationController.getLocale(), baseUrl);
+               // Fire event
+               this.userResendLinkEvent.fire(new ResendLinkUserAccountEvent(user));
 
                // Clear this bean
                this.clear();
index b7897b2d09856e8e90dc46868a7c8e967fa6ca8a..84dcdc21aef52f76ba82962b7c1a8585d242a2ba 100644 (file)
@@ -331,7 +331,7 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
        }
 
        @Override
-       public void afterUserConfirmedAccount (@Observes final UserConfirmedAccountEvent event) {
+       public void afterUserConfirmedAccountEvent (@Observes final UserConfirmedAccountEvent event) {
                // event should not be null
                if (null == event) {
                        // Throw NPE
@@ -352,7 +352,7 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
        }
 
        @Override
-       public void afterUserLogin (@Observes final UserLoggedInEvent event) {
+       public void afterUserLoginEvent (@Observes final UserLoggedInEvent event) {
                // event should not be null
                if (null == event) {
                        // Throw NPE
@@ -403,7 +403,7 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
        }
 
        @Override
-       public void afterUserUpdatedPersonalData (@Observes final UpdatedUserPersonalDataEvent event) {
+       public void afterUserUpdatedPersonalDataEvent (@Observes final UpdatedUserPersonalDataEvent event) {
                // Check parameter
                if (null == event) {
                        // Throw NPE
index 13c57204b5cc8cabaf368bd7ad74f1c74a79e2de..0ecb8096aafba8ee2a7c8c3128e9109a791e29ce 100644 (file)
@@ -86,7 +86,7 @@ public interface JobsUserWebSessionController extends Serializable {
         * <p>
         * @param event Event being fired
         */
-       void afterUserConfirmedAccount (final UserConfirmedAccountEvent event);
+       void afterUserConfirmedAccountEvent (final UserConfirmedAccountEvent event);
 
        /**
         * Method being call after user's password has been updated (and history
@@ -101,7 +101,7 @@ public interface JobsUserWebSessionController extends Serializable {
         * <p>
         * @param event Event being fired
         */
-       void afterUserUpdatedPersonalData (final UpdatedUserPersonalDataEvent event);
+       void afterUserUpdatedPersonalDataEvent (final UpdatedUserPersonalDataEvent event);
 
        /**
         * Event observer for new user registrations
@@ -115,7 +115,7 @@ public interface JobsUserWebSessionController extends Serializable {
         * <p>
         * @param event Event instance
         */
-       void afterUserLogin (final UserLoggedInEvent event);
+       void afterUserLoginEvent (final UserLoggedInEvent event);
 
        /**
         * All users
index 66958f2cbfdaa7472a1e31aa393ee9bb82a6d76e..6062b05676b6628f31d9f02a1cc5e48f42b14be9 100644 (file)
@@ -34,6 +34,7 @@ import org.mxchange.jjobs.beans.BaseJobsController;
 import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent;
 import org.mxchange.jusercore.events.login.UserLoggedInEvent;
 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
+import org.mxchange.jusercore.events.resendlink.UserResendLinkAccountEvent;
 import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
 import org.mxchange.jusercore.events.user.linked.AdminLinkedUserEvent;
 import org.mxchange.jusercore.events.user.locked.AdminLockedUserEvent;
@@ -278,7 +279,7 @@ public class JobsUserActivityWebApplicationBean extends BaseJobsController imple
        }
 
        @Override
-       public void afterUserConfirmedAccount (@Observes final UserConfirmedAccountEvent event) {
+       public void afterUserConfirmedAccountEvent (@Observes final UserConfirmedAccountEvent event) {
                // event should not be null
                if (null == event) {
                        // Throw NPE
@@ -299,7 +300,7 @@ public class JobsUserActivityWebApplicationBean extends BaseJobsController imple
        }
 
        @Override
-       public void afterUserLogin (@Observes final UserLoggedInEvent event) {
+       public void afterUserLoginEvent (@Observes final UserLoggedInEvent event) {
                // event should not be null
                if (null == event) {
                        // Throw NPE
@@ -319,6 +320,27 @@ public class JobsUserActivityWebApplicationBean extends BaseJobsController imple
                this.addUserActivity(event.getLoggedInUser(), "USER_LOGGED_IN"); //NOI18N
        }
 
+       @Override
+       public void afterUserResendConfirmationLinkEvent (@Observes final UserResendLinkAccountEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getResendLinkUser()== null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.resendLinkUser is null"); //NOI18N
+               } else if (event.getResendLinkUser().getUserId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.resendLinkUser.userId is null"); //NOI18N
+               } else if (event.getResendLinkUser().getUserId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getResendLinkUser(), event.getResendLinkUser().getUserId())); //NOI18N
+               }
+
+               // Copy all data to this bean
+               this.addUserActivity(event.getResendLinkUser(), "USER_RESEND_CONFIRMATION_LINK"); //NOI18N
+       }
+
        @Override
        public void afterUserUpdatedPasswordEvent (@Observes final UpdatedUserPasswordEvent event) {
                // Check parameter
@@ -341,7 +363,7 @@ public class JobsUserActivityWebApplicationBean extends BaseJobsController imple
        }
 
        @Override
-       public void afterUserUpdatedPersonalData (@Observes final UpdatedUserPersonalDataEvent event) {
+       public void afterUserUpdatedPersonalDataEvent (@Observes final UpdatedUserPersonalDataEvent event) {
                // Check parameter
                if (null == event) {
                        // Throw NPE
index a738ba9bf51d1b1b661e2efb786f57e671fdaec5..c576b632e245bf950a77203b28a0e8535299c9c1 100644 (file)
@@ -22,6 +22,7 @@ import javax.ejb.Local;
 import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent;
 import org.mxchange.jusercore.events.login.UserLoggedInEvent;
 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
+import org.mxchange.jusercore.events.resendlink.UserResendLinkAccountEvent;
 import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
 import org.mxchange.jusercore.events.user.linked.AdminLinkedUserEvent;
 import org.mxchange.jusercore.events.user.locked.AdminLockedUserEvent;