]> git.mxchange.org Git - pizzaservice-war.git/blobdiff - src/java/org/mxchange/pizzaapplication/beans/user/PizzaUserWebSessionBean.java
updated JNDI names
[pizzaservice-war.git] / src / java / org / mxchange / pizzaapplication / beans / user / PizzaUserWebSessionBean.java
index 18925b2000ec601db1311ad2208f723c2be5e376..06f8d61e7ad389fa0f72459fe43108ea5e8a660f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Roland Haeder
+ * Copyright (C) 2016, 2017 Roland Häder
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as
@@ -33,15 +33,18 @@ import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.jcontacts.contact.Contact;
-import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
-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.user.add.AdminAddedUserEvent;
-import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
-import org.mxchange.jusercore.events.user.update.AdminUpdatedUserDataEvent;
+import org.mxchange.jusercore.events.confirmation.ObservableUserConfirmedAccountEvent;
+import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent;
+import org.mxchange.jusercore.events.registration.ObservableUserRegisteredEvent;
+import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
+import org.mxchange.jusercore.events.user.delete.ObservableAdminDeletedUserEvent;
+import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
+import org.mxchange.jusercore.events.user.locked.ObservableAdminLockedUserEvent;
+import org.mxchange.jusercore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
+import org.mxchange.jusercore.events.user.unlocked.ObservableAdminUnlockedUserEvent;
+import org.mxchange.jusercore.events.user.update.ObservableAdminUpdatedUserDataEvent;
+import org.mxchange.jusercore.events.user.update.ObservableUpdatedUserPersonalDataEvent;
 import org.mxchange.jusercore.events.user.update.UpdatedUserPersonalDataEvent;
-import org.mxchange.jusercore.events.user.update.UserUpdatedPersonalDataEvent;
 import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
 import org.mxchange.jusercore.exceptions.UserNotFoundException;
 import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
@@ -53,13 +56,12 @@ import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
 import org.mxchange.pizzaapplication.beans.BasePizzaController;
 import org.mxchange.pizzaapplication.beans.contact.PizzaContactWebSessionController;
 import org.mxchange.pizzaapplication.beans.features.PizzaFeaturesWebApplicationController;
-import org.mxchange.pizzaapplication.beans.localization.PizzaLocalizationSessionController;
-import org.mxchange.pizzaapplication.beans.login.PizzaUserLoginWebSessionController;
+import org.mxchange.pizzaapplication.beans.login.user.PizzaUserLoginWebSessionController;
 
 /**
  * A user bean (controller)
  * <p>
- * @author Roland Haeder<roland@mxchange.org>
+ * @author Roland Häder<roland@mxchange.org>
  */
 @Named ("userController")
 @SessionScoped
@@ -70,11 +72,6 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
         */
        private static final long serialVersionUID = 542_145_347_916L;
 
-       /**
-        * Contact EJB
-        */
-       private ContactSessionBeanRemote contactBean;
-
        /**
         * General contact controller
         */
@@ -87,23 +84,17 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
        @Inject
        private PizzaFeaturesWebApplicationController featureController;
 
-       /**
-        * Localization controller
-        */
-       @Inject
-       private PizzaLocalizationSessionController localizationController;
-
        /**
         * Event being fired when user updated personal data
         */
        @Inject
        @Any
-       private Event<UpdatedUserPersonalDataEvent> updatedPersonalDataEvent;
+       private Event<ObservableUpdatedUserPersonalDataEvent> updatedPersonalDataEvent;
 
        /**
         * Remote user bean
         */
-       private final UserSessionBeanRemote userBean;
+       private UserSessionBeanRemote userBean;
 
        /**
         * User id
@@ -116,7 +107,7 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
        private List<User> userList;
 
        /**
-        * Login bean (controller)
+        * Login controller (bean)
         */
        @Inject
        private PizzaUserLoginWebSessionController userLoginController;
@@ -132,12 +123,12 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
        private List<String> userNameList;
 
        /**
-        * User password (unencrypted from web form)
+        * User password (clear-text from web form)
         */
        private String userPassword;
 
        /**
-        * User password repeated (unencrypted from web form)
+        * User password repeated (clear-text from web form)
         */
        private String userPasswordRepeat;
 
@@ -158,27 +149,16 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
         * Default constructor
         */
        public PizzaUserWebSessionBean () {
-               // Try it
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Try to lookup
-                       this.userBean = (UserSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
-
-                       // Try to lookup
-                       this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
-               } catch (final NamingException e) {
-                       // Throw again
-                       throw new FaceletException(e);
-               }
+               // Call super constructor
+               super();
        }
 
-       @Override
-       public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterAdminAddedUserEvent: event={0} - CALLED!", event)); //NOI18N
-
+       /**
+        * Event observer for newly added users by administrator
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
                // event should not be null
                if (null == event) {
                        // Throw NPE
@@ -194,105 +174,159 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
                        throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
                }
 
-               // Add user uniquely
-               this.uniqueAddUser(event.getAddedUser());
+               // Update user list
+               this.updateList(event.getAddedUser());
 
                // Clear all data
                this.clear();
 
                // Set user id again
                this.setUserId(event.getAddedUser().getUserId());
-
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterAdminAddedUserEvent: EXIT!"); //NOI18N
        }
 
-       @Override
-       public void afterAdminUpdatedUserDataEvent (@Observes final AdminUpdatedUserDataEvent event) {
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterAdminUpdatedUserEvent: event={0} - CALLED!", event)); //NOI18N
-
+       /**
+        * Event observer for deleted user accounts (by administrator)
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterAdminDeletedUserEvent (final ObservableAdminDeletedUserEvent event) {
                // event should not be null
                if (null == event) {
                        // Throw NPE
                        throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getUpdatedUser() == null) {
+               } else if (event.getDeletedUser() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("event.updatedUser is null"); //NOI18N
-               } else if (event.getUpdatedUser().getUserId() == null) {
+                       throw new NullPointerException("event.deletedUser is null"); //NOI18N
+               } else if (event.getDeletedUser().getUserId() == null) {
                        // userId is null
-                       throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N
-               } else if (event.getUpdatedUser().getUserId() < 1) {
+                       throw new NullPointerException("event.deletedUser.userId is null"); //NOI18N
+               } else if (event.getDeletedUser().getUserId() < 1) {
                        // Not avalid id
-                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUpdatedUser(), event.getUpdatedUser().getUserId())); //NOI18N
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getDeletedUser(), event.getDeletedUser().getUserId())); //NOI18N
                }
 
-               // Update list
-               this.updateList(event.getUpdatedUser());
+               // Update user list
+               this.removeFromList(event.getDeletedUser());
 
                // Clear all data
                this.clear();
-
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterAdminUpdatedUserEvent: EXIT!"); //NOI18N
        }
 
-       @Override
-       public void afterRegistrationEvent (@Observes final UserRegisteredEvent event) {
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N
-
+       /**
+        * Event observer for linked users with existing contact data
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterAdminLinkedUserEvent (@Observes final ObservableAdminLinkedUserEvent event) {
                // event should not be null
                if (null == event) {
                        // Throw NPE
                        throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getRegisteredUser() == null) {
+               } else if (event.getLinkedUser() == null) {
                        // Throw NPE again
-                       throw new NullPointerException("event.registeredUser is null"); //NOI18N
-               } else if (event.getRegisteredUser().getUserId() == null) {
+                       throw new NullPointerException("event.linkedUser is null"); //NOI18N
+               } else if (event.getLinkedUser().getUserId() == null) {
                        // userId is null
-                       throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N
-               } else if (event.getRegisteredUser().getUserId() < 1) {
+                       throw new NullPointerException("event.linkedUser.userId is null"); //NOI18N
+               } else if (event.getLinkedUser().getUserId() < 1) {
                        // Not avalid id
-                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLinkedUser(), event.getLinkedUser().getUserId())); //NOI18N
                }
 
-               // Get user instance
-               User registeredUser = event.getRegisteredUser();
-
-               // Debug message
-               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterRegistration: registeredUser={0}", registeredUser)); //NOI18N
-
-               // Copy all data from registered->user
-               this.copyUser(registeredUser);
+               // Update user list
+               this.updateList(event.getLinkedUser());
 
                // Clear all data
                this.clear();
 
-               // Add user uniquely
-               this.uniqueAddUser(registeredUser);
-
-               // Add user name
-               this.addUserName(registeredUser);
+               // Set user id again
+               this.setUserId(event.getLinkedUser().getUserId());
+       }
 
-               // Is the account public?
-               if (Objects.equals(registeredUser.getUserProfileMode(), ProfileMode.PUBLIC)) {
-                       // Also add it to this list
-                       this.visibleUserList.add(registeredUser);
+       /**
+        * Event observer for locked users
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterAdminLockedUserEvent (@Observes final ObservableAdminLockedUserEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getLockedUser() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.lockedUser is null"); //NOI18N
+               } else if (event.getLockedUser().getUserId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.lockedUser.userId is null"); //NOI18N
+               } else if (event.getLockedUser().getUserId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLockedUser(), event.getLockedUser().getUserId())); //NOI18N
                }
 
-               // Set user id again
-               this.setUserId(registeredUser.getUserId());
+               // Update user list
+               this.updateList(event.getLockedUser());
+       }
 
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterRegistration: EXIT!"); //NOI18N
+       /**
+        * Event observer for unlocked users
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterAdminUnlockedUserEvent (@Observes final ObservableAdminUnlockedUserEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getUnlockedUser() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.unlockedUser is null"); //NOI18N
+               } else if (event.getUnlockedUser().getUserId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.unlockedUser.userId is null"); //NOI18N
+               } else if (event.getUnlockedUser().getUserId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUnlockedUser(), event.getUnlockedUser().getUserId())); //NOI18N
+               }
+
+               // Update user list
+               this.updateList(event.getUnlockedUser());
        }
 
-       @Override
-       public void afterUserConfirmedAccount (@Observes final UserConfirmedAccountEvent event) {
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterAdminUpdatedContactDataEvent: event={0} - CALLED!", event)); //NOI18N
+       /**
+        * Event observer for updated user data by administrator
+        * <p>
+        * @param event Event being updated
+        */
+       public void afterAdminUpdatedUserDataEvent (@Observes final ObservableAdminUpdatedUserDataEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getUpdatedUser() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.updatedUser is null"); //NOI18N
+               } else if (event.getUpdatedUser().getUserId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N
+               } else if (event.getUpdatedUser().getUserId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUpdatedUser(), event.getUpdatedUser().getUserId())); //NOI18N
+               }
+
+               // Update user list
+               this.updateList(event.getUpdatedUser());
+
+               // Clear all data
+               this.clear();
+       }
 
+       /**
+        * Event observer when user confirmed account.
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterUserConfirmedAccountEvent (@Observes final ObservableUserConfirmedAccountEvent event) {
                // event should not be null
                if (null == event) {
                        // Throw NPE
@@ -308,15 +342,16 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
                        throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getConfirmedUser(), event.getConfirmedUser().getUserId())); //NOI18N
                }
 
-               // Add user uniquely
-               this.uniqueAddUser(event.getConfirmedUser());
+               // Update user list
+               this.updateList(event.getConfirmedUser());
        }
 
-       @Override
-       public void afterUserLogin (@Observes final UserLoggedInEvent event) {
-               // Trace message
-               //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
-
+       /**
+        * Event observer for logged-in user
+        * <p>
+        * @param event Event instance
+        */
+       public void afterUserLoginEvent (@Observes final ObservableUserLoggedInEvent event) {
                // event should not be null
                if (null == event) {
                        // Throw NPE
@@ -345,8 +380,59 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
                }
        }
 
-       @Override
-       public void afterUserUpdatedPasswordEvent (@Observes final UpdatedUserPasswordEvent event) {
+       /**
+        * Event observer for new user registrations
+        * <p>
+        * @param event User registration event
+        */
+       public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getRegisteredUser() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.registeredUser is null"); //NOI18N
+               } else if (event.getRegisteredUser().getUserId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N
+               } else if (event.getRegisteredUser().getUserId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
+               }
+
+               // Get user instance
+               User registeredUser = event.getRegisteredUser();
+
+               // Copy all data from registered->user
+               this.copyUser(registeredUser);
+
+               // Clear all data
+               this.clear();
+
+               // Update user list
+               this.updateList(registeredUser);
+
+               // Add user name
+               this.addUserName(registeredUser);
+
+               // Is the account public?
+               if (Objects.equals(registeredUser.getUserProfileMode(), ProfileMode.PUBLIC)) {
+                       // Also add it to this list
+                       this.visibleUserList.add(registeredUser);
+               }
+
+               // Set user id again
+               this.setUserId(registeredUser.getUserId());
+       }
+
+       /**
+        * Method being call after user's password has been updated (and history
+        * entry has been created).
+        * <p>
+        * @param event Event being observed
+        */
+       public void afterUserUpdatedPasswordEvent (@Observes final ObservableUpdatedUserPasswordEvent event) {
                // Check parameter
                if (null == event) {
                        // Throw NPE
@@ -362,12 +448,16 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
                        throw new IllegalArgumentException(MessageFormat.format("event.passwordHistory.userPasswordHistoryId={0} is in valid", event.getPasswordHistory().getUserPasswordHistoryId())); //NOI18N
                }
 
-               // All fine, so update list
+               // Update user list
                this.updateList(event.getPasswordHistory().getUserPasswordHistoryUser());
        }
 
-       @Override
-       public void afterUserUpdatedPersonalData (@Observes final UpdatedUserPersonalDataEvent event) {
+       /**
+        * Listens to fired event when user updated personal data
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterUserUpdatedPersonalDataEvent (@Observes final ObservableUpdatedUserPersonalDataEvent event) {
                // Check parameter
                if (null == event) {
                        // Throw NPE
@@ -383,7 +473,7 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
                        throw new IllegalArgumentException(MessageFormat.format("event.updatedUser.userId={0} is in valid", event.getUpdatedUser().getUserId())); //NOI18N
                }
 
-               // All fine, so update list
+               // Update user list
                this.updateList(event.getUpdatedUser());
        }
 
@@ -429,8 +519,7 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
                        this.setUserPasswordRepeat(randomPassword);
                }
 
-               // Set local, user name and mode
-               user.setUserLocale(this.localizationController.getLocale());
+               // Set user name and mode
                user.setUserName(this.getUserName());
                user.setUserProfileMode(this.getUserProfileMode());
 
@@ -441,14 +530,12 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
 
                        // Debug message
                        //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createUserInstance: contact={1}", this.getClass().getSimpleName(), contact));
-
                        // Set contact in user
                        user.setUserContact(contact);
                }
 
                // Trace message
                //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createUserInstance: user={1} - EXIT!", this.getClass().getSimpleName(), user));
-
                // Return it
                return user;
        }
@@ -461,23 +548,22 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
                // Is all data set?
                if (this.getUserName() == null) {
                        // Throw NPE
-                       throw new NullPointerException("recruiterName is null"); //NOI18N
+                       throw new NullPointerException("userName is null"); //NOI18N
                } else if (this.getUserName().isEmpty()) {
                        // Is empty
-                       throw new IllegalStateException("recruiterName is empty."); //NOI18N
+                       throw new IllegalStateException("userName is empty."); //NOI18N
                }
 
-               // Create new recruiter instance
-               User recruiter = new LoginUser();
+               // Create new user instance
+               User user = new LoginUser();
 
                // Update all data ...
-               recruiter.setUserName(this.getUserName());
+               user.setUserName(this.getUserName());
 
                // Trace message
-               //* NOISY-DEBUG */ System.out.println(MessageFormat.format("{0}.createUserLogin: recruiter={1} - EXIT!", this.getClass().getSimpleName(), recruiter));
-
+               //* NOISY-DEBUG */ System.out.println(MessageFormat.format("{0}.createUserLogin: user={1} - EXIT!", this.getClass().getSimpleName(), user));
                // Return the new instance
-               return recruiter;
+               return user;
        }
 
        @Override
@@ -492,7 +578,7 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
                } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
                        // Password not matching
                        throw new FaceletException(new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()));
-               } else if (!this.featureController.isFeatureEnabled("edit_user_data")) {
+               } else if (!this.featureController.isFeatureEnabled("change_user_personal_data")) {
                        // Editing is not allowed
                        throw new IllegalStateException("User tried to edit personal data."); //NOI18N
                }
@@ -504,12 +590,12 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
                this.contactController.updateContactDataFromController(user.getUserContact());
 
                // It should be there, so run some tests on it
-               assert (user instanceof User) : "Instance loginController.loggedInUser is null"; //NOI18N
-               assert (user.getUserId() instanceof Long) : "Instance loginController.loggedInUser.userId is null"; //NOI18N
-               assert (user.getUserId() > 0) : MessageFormat.format("loginController.loggedInUser.userId={0} is invalid", user.getUserId()); //NOI18N
-               assert (user.getUserContact() instanceof Contact) : "Instance loginController.loggedInUser.userContact is null"; //NOI18N
-               assert (user.getUserContact().getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null"; //NOI18N
-               assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); //NOI18N
+               assert (user instanceof User) : "Instance userLoginController.loggedInUser is null"; //NOI18N
+               assert (user.getUserId() instanceof Long) : "Instance userLoginController.loggedInUser.userId is null"; //NOI18N
+               assert (user.getUserId() > 0) : MessageFormat.format("userLoginController.loggedInUser.userId={0} is invalid", user.getUserId()); //NOI18N
+               assert (user.getUserContact() instanceof Contact) : "Instance userLoginController.loggedInUser.userContact is null"; //NOI18N
+               assert (user.getUserContact().getContactId() instanceof Long) : "Instance userLoginController.userContact.contactId is null"; //NOI18N
+               assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); //NOI18N
 
                // Update all fields
                user.setUserProfileMode(this.getUserProfileMode());
@@ -518,10 +604,10 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
                User updatedUser = this.userBean.updateUserPersonalData(user);
 
                // Fire event
-               this.updatedPersonalDataEvent.fire(new UserUpdatedPersonalDataEvent(updatedUser));
+               this.updatedPersonalDataEvent.fire(new UpdatedUserPersonalDataEvent(updatedUser));
 
                // All fine
-               return "contact_data_saved"; //NOI18N
+               return "user_contact_data_saved"; //NOI18N
        }
 
        @Override
@@ -574,11 +660,31 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
                this.userProfileMode = userProfileMode;
        }
 
+       @Override
+       public boolean ifBothPasswordsEmptyAllowed () {
+               // Check feature first
+               return ((this.featureController.isFeatureEnabled("allow_user_registration_empty_password")) &&
+                               ((this.getUserPassword() == null) || (this.getUserPassword().isEmpty())) &&
+                               ((this.getUserPasswordRepeat() == null) || (this.getUserPasswordRepeat().isEmpty())));
+       }
+
        /**
         * Post-initialization of this class
         */
        @PostConstruct
        public void init () {
+               // Try it
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Try to lookup
+                       this.userBean = (UserSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
+               } catch (final NamingException e) {
+                       // Throw again
+                       throw new FaceletException(e);
+               }
+
                // Initialize user list
                this.userList = this.userBean.allUsers();
 
@@ -701,7 +807,7 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
 
        @Override
        public boolean isVisibleUserFound () {
-               return ((this.visibleUserList instanceof List) && (!this.visibleUserList.isEmpty()));
+               return ((this.visibleUserList instanceof List) && (this.visibleUserList.size() > 0));
        }
 
        @Override
@@ -729,7 +835,7 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
                                throw new NullPointerException(MessageFormat.format("next.userContact is null for user id {0}", next.getUserId())); //NOI18N
                        } else if (next.getUserContact().getContactEmailAddress() == null) {
                                // Email address should be set
-                               throw new NullPointerException(MessageFormat.format("next.userContact.contactEmailAddress is null for user id {0}", next.getUserId())); //NOI18N //NOI18N
+                               throw new NullPointerException(MessageFormat.format("next.userContact.contactEmailAddress is null for user id {0}", next.getUserId())); //NOI18N
                        }
 
                        // Is the email address found?
@@ -844,39 +950,29 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
        }
 
        /**
-        * Uniquely adds given user instance to user list. First an existing
-        * instance will be removed, then the given instance is being added.
+        * Removes user from all lists
         * <p>
-        * @param user User instance to add
+        * @param user User to remove
         */
-       private void uniqueAddUser (final User user) {
-               // Make sure the instance is valid
+       private void removeFromList (final User user) {
+               // The user should be valid
                if (null == user) {
                        // Throw NPE
                        throw new NullPointerException("user is null"); //NOI18N
-               } else if (user.getUserContact() == null) {
-                       // Throw again ...
-                       throw new NullPointerException("user.userContact is null"); //NOI18N
+               } else if (user.getUserId() == null) {
+                       // ... again NPE
+                       throw new NullPointerException("user.userId is null"); //NOI18N
+               } else if (user.getUserId() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
                }
 
-               // Get iterator from list
-               Iterator<User> iterator = this.userList.iterator();
+               // Remove it from lists
+               this.userList.remove(user);
+               this.visibleUserList.remove(user);
 
-               // "Walk" through all entries
-               while (iterator.hasNext()) {
-                       // Get next element
-                       User next = iterator.next();
-
-                       // Is id number the same?
-                       if (Objects.equals(user.getUserId(), next.getUserId())) {
-                               // Found entry, so remove it and abort
-                               this.userList.remove(next);
-                               break;
-                       }
-               }
-
-               // Add contact to list
-               this.userList.add(user);
+               // Remove name from list
+               this.userNameList.remove(user.getUserName());
        }
 
        /**
@@ -895,25 +991,34 @@ public class PizzaUserWebSessionBean extends BasePizzaController implements Pizz
                } else if (user.getUserId() < 1) {
                        // Invalid id
                        throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
+               } else if (user.getUserContact() == null) {
+                       // Throw again ...
+                       throw new NullPointerException("user.userContact is null"); //NOI18N
+               } else if (user.getUserContact().getContactId() == null) {
+                       // Throw again ...
+                       throw new NullPointerException("user.userContact.contactId is null"); //NOI18N
+               } else if (user.getUserContact().getContactId() < 1) {
+                       // Throw again ...
+                       throw new NullPointerException(MessageFormat.format("user.userContact.contactId={0} is invalid.", user.getUserContact().getContactId())); //NOI18N
                }
 
-               // Get iterator
+               // Get iterator from list
                Iterator<User> iterator = this.userList.iterator();
 
-               // Look whole list
+               // "Walk" through all entries
                while (iterator.hasNext()) {
                        // Get next element
                        User next = iterator.next();
 
-                       // Is the same user id?
+                       // Is user id number the same?
                        if (Objects.equals(user.getUserId(), next.getUserId())) {
-                               // Found it, so remove it
+                               // Found entry, so remove it and abort
                                this.userList.remove(next);
                                break;
                        }
                }
 
-               // Re-add item
+               // Re-add user
                this.userList.add(user);
        }