]> git.mxchange.org Git - addressbook-war.git/commitdiff
addded method afterUserLogin() which is an CDI observer on logged-in user events
authorRoland Haeder <roland@mxchange.org>
Sat, 17 Oct 2015 19:07:30 +0000 (21:07 +0200)
committerRoland Haeder <roland@mxchange.org>
Sat, 17 Oct 2015 19:07:30 +0000 (21:07 +0200)
src/java/org/mxchange/addressbook/beans/user/UserWebBean.java
src/java/org/mxchange/addressbook/beans/user/UserWebController.java

index 3759a66e6a42b3723526942cd1a77f07b39c3e58..8bb0bf65269a42aa50470b45b731eb9c3f37d542 100644 (file)
@@ -44,6 +44,7 @@ import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
 import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
 import org.mxchange.jphone.phonenumbers.landline.LandLineNumber;
 import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider;
+import org.mxchange.jusercore.events.login.UserLoggedInEvent;
 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
 import org.mxchange.jusercore.exceptions.UserNotFoundException;
 import org.mxchange.jusercore.model.user.LoginUser;
@@ -237,6 +238,33 @@ public class UserWebBean implements UserWebController {
                }
        }
 
+       @Override
+       public void afterUserLogin (final @Observes UserLoggedInEvent event) {
+               // Trace message
+               System.out.println(MessageFormat.format("UserWebBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
+
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getUser() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.user is null"); //NOI18N
+               } else if (event.getUser().getUserId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.user.userId is null"); //NOI18N
+               } else if (event.getUser().getUserId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUser(), event.getUser().getUserId())); //NOI18N
+               }
+
+               // Re-initialize list
+               this.visibleUserList = this.userBean.allMemberPublicVisibleUsers();
+
+               // Trace message
+               System.out.println(MessageFormat.format("UserWebBean:afterUserLogin: this.visibleUserList.size()={0} - EXIT!", this.visibleUserList.size())); //NOI18N
+       }
+
        @Override
        public void afterRegistrationEvent (final @Observes UserRegisteredEvent event) {
                // Trace message
index f9644e2fc92a7d959773f410c9b9933108cf327e..e153f8d54356b2f47ae0c5fb6ec567ebf449ed84 100644 (file)
@@ -22,6 +22,7 @@ import java.util.List;
 import org.mxchange.jcontacts.contact.gender.Gender;
 import org.mxchange.jcountry.data.Country;
 import org.mxchange.jphone.phonenumbers.smsprovider.SmsProvider;
+import org.mxchange.jusercore.events.login.UserLoggedInEvent;
 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
 import org.mxchange.jusercore.exceptions.UserNotFoundException;
 import org.mxchange.jusercore.model.user.User;
@@ -53,6 +54,13 @@ public interface UserWebController extends Serializable {
         */
        void afterRegistrationEvent (final UserRegisteredEvent event);
 
+       /**
+        * Event observer for logged-in user
+        * <p>
+        * @param event Event instance
+        */
+       void afterUserLogin (final UserLoggedInEvent event);
+
        /**
         * All public user profiles
         * <p>