2 * Copyright (C) 2016 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation, either version 3 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.pizzaapplication.beans.user;
19 import java.text.MessageFormat;
20 import java.util.Collections;
21 import java.util.Iterator;
22 import java.util.List;
23 import java.util.Objects;
24 import javax.annotation.PostConstruct;
25 import javax.enterprise.context.SessionScoped;
26 import javax.enterprise.event.Event;
27 import javax.enterprise.event.Observes;
28 import javax.enterprise.inject.Any;
29 import javax.faces.context.FacesContext;
30 import javax.faces.view.facelets.FaceletException;
31 import javax.inject.Inject;
32 import javax.inject.Named;
33 import javax.naming.Context;
34 import javax.naming.InitialContext;
35 import javax.naming.NamingException;
36 import org.mxchange.jcontacts.contact.Contact;
37 import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
38 import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent;
39 import org.mxchange.jusercore.events.login.UserLoggedInEvent;
40 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
41 import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
42 import org.mxchange.jusercore.events.user.update.AdminUpdatedUserDataEvent;
43 import org.mxchange.jusercore.events.user.update.UpdatedUserPersonalDataEvent;
44 import org.mxchange.jusercore.events.user.update.UserUpdatedPersonalDataEvent;
45 import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
46 import org.mxchange.jusercore.exceptions.UserNotFoundException;
47 import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
48 import org.mxchange.jusercore.model.user.LoginUser;
49 import org.mxchange.jusercore.model.user.User;
50 import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
51 import org.mxchange.jusercore.model.user.UserUtils;
52 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
53 import org.mxchange.pizzaapplication.beans.BasePizzaController;
54 import org.mxchange.pizzaapplication.beans.contact.PizzaContactWebSessionController;
55 import org.mxchange.pizzaapplication.beans.features.PizzaFeaturesWebApplicationController;
56 import org.mxchange.pizzaapplication.beans.localization.PizzaLocalizationSessionController;
57 import org.mxchange.pizzaapplication.beans.login.PizzaUserLoginWebSessionController;
60 * A user bean (controller)
62 * @author Roland Haeder<roland@mxchange.org>
64 @Named ("userController")
66 public class PizzaUserWebSessionBean extends BasePizzaController implements PizzaUserWebSessionController {
71 private static final long serialVersionUID = 542_145_347_916L;
76 private ContactSessionBeanRemote contactBean;
79 * General contact controller
82 private PizzaContactWebSessionController contactController;
88 private PizzaFeaturesWebApplicationController featureController;
91 * Localization controller
94 private PizzaLocalizationSessionController localizationController;
97 * Event being fired when user updated personal data
101 private Event<UpdatedUserPersonalDataEvent> updatedPersonalDataEvent;
106 private final UserSessionBeanRemote userBean;
114 * A list of all user profiles
116 private List<User> userList;
119 * Login bean (controller)
122 private PizzaUserLoginWebSessionController userLoginController;
127 private String userName;
132 private List<String> userNameList;
135 * User password (unencrypted from web form)
137 private String userPassword;
140 * User password repeated (unencrypted from web form)
142 private String userPasswordRepeat;
145 * Whether the user wants a public profile
147 private ProfileMode userProfileMode;
150 * A list of all public user profiles
152 private List<User> visibleUserList;
155 * Default constructor
157 public PizzaUserWebSessionBean () {
160 // Get initial context
161 Context context = new InitialContext();
164 this.userBean = (UserSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote"); //NOI18N
167 this.contactBean = (ContactSessionBeanRemote) context.lookup("java:global/pizzaservice-ejb/contact!org.mxchange.jcontacts.contact.ContactSessionBeanRemote"); //NOI18N
168 } catch (final NamingException e) {
170 throw new FaceletException(e);
175 public void afterAdminAddedUserEvent (@Observes final AdminAddedUserEvent event) {
177 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterAdminAddedUserEvent: event={0} - CALLED!", event)); //NOI18N
179 // event should not be null
182 throw new NullPointerException("event is null"); //NOI18N
183 } else if (event.getAddedUser() == null) {
185 throw new NullPointerException("event.addedUser is null"); //NOI18N
186 } else if (event.getAddedUser().getUserId() == null) {
188 throw new NullPointerException("event.addedUser.userId is null"); //NOI18N
189 } else if (event.getAddedUser().getUserId() < 1) {
191 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getAddedUser(), event.getAddedUser().getUserId())); //NOI18N
194 // Add user to local list
195 this.userList.add(event.getAddedUser());
201 this.setUserId(event.getAddedUser().getUserId());
204 //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterAdminAddedUserEvent: EXIT!"); //NOI18N
208 public void afterAdminUpdatedUserDataEvent (@Observes final AdminUpdatedUserDataEvent event) {
210 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterAdminUpdatedUserEvent: event={0} - CALLED!", event)); //NOI18N
212 // event should not be null
215 throw new NullPointerException("event is null"); //NOI18N
216 } else if (event.getUpdatedUser() == null) {
218 throw new NullPointerException("event.updatedUser is null"); //NOI18N
219 } else if (event.getUpdatedUser().getUserId() == null) {
221 throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N
222 } else if (event.getUpdatedUser().getUserId() < 1) {
224 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getUpdatedUser(), event.getUpdatedUser().getUserId())); //NOI18N
228 this.updateList(event.getUpdatedUser());
234 //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterAdminUpdatedUserEvent: EXIT!"); //NOI18N
238 public void afterRegistrationEvent (@Observes final UserRegisteredEvent event) {
240 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterRegistration: event={0} - CALLED!", event)); //NOI18N
242 // event should not be null
245 throw new NullPointerException("event is null"); //NOI18N
246 } else if (event.getRegisteredUser() == null) {
248 throw new NullPointerException("event.registeredUser is null"); //NOI18N
249 } else if (event.getRegisteredUser().getUserId() == null) {
251 throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N
252 } else if (event.getRegisteredUser().getUserId() < 1) {
254 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getRegisteredUser(), event.getRegisteredUser().getUserId())); //NOI18N
258 User registeredUser = event.getRegisteredUser();
261 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterRegistration: registeredUser={0}", registeredUser)); //NOI18N
263 // Copy all data from registered->user
264 this.copyUser(registeredUser);
269 // Add user to local list
270 this.userList.add(registeredUser);
273 this.addUserName(registeredUser);
275 // Is the account public?
276 if (Objects.equals(registeredUser.getUserProfileMode(), ProfileMode.PUBLIC)) {
277 // Also add it to this list
278 this.visibleUserList.add(registeredUser);
282 this.setUserId(registeredUser.getUserId());
285 //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterRegistration: EXIT!"); //NOI18N
289 public void afterUserConfirmedAccount (@Observes final UserConfirmedAccountEvent event) {
291 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("ContactWebBean:afterAdminUpdatedContactDataEvent: event={0} - CALLED!", event)); //NOI18N
293 // event should not be null
296 throw new NullPointerException("event is null"); //NOI18N
297 } else if (event.getConfirmedUser() == null) {
299 throw new NullPointerException("event.confirmedUser is null"); //NOI18N
300 } else if (event.getConfirmedUser().getUserId() == null) {
302 throw new NullPointerException("event.confirmedUser.userId is null"); //NOI18N
303 } else if (event.getConfirmedUser().getUserId() < 1) {
305 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getConfirmedUser(), event.getConfirmedUser().getUserId())); //NOI18N
308 // Get iterator from list
309 Iterator<User> iterator = this.userList.iterator();
311 // "Walk" through all entries
312 while (iterator.hasNext()) {
314 User next = iterator.next();
316 // Is id number the same?
317 if (Objects.equals(event.getConfirmedUser().getUserId(), next.getUserId())) {
318 // Found entry, so remove it and abort
319 this.userList.remove(next);
324 // Add contact to list
325 this.userList.add(event.getConfirmedUser());
329 public void afterUserLogin (@Observes final UserLoggedInEvent event) {
331 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterUserLogin: event={0} - CALLED!", event)); //NOI18N
333 // event should not be null
336 throw new NullPointerException("event is null"); //NOI18N
337 } else if (event.getLoggedInUser() == null) {
339 throw new NullPointerException("event.registeredUser is null"); //NOI18N
340 } else if (event.getLoggedInUser().getUserId() == null) {
342 throw new NullPointerException("event.registeredUser.userId is null"); //NOI18N
343 } else if (event.getLoggedInUser().getUserId() < 1) {
345 throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
348 // Copy all data to this bean
349 this.copyUser(event.getLoggedInUser());
351 // Re-initialize list
352 this.visibleUserList = this.userBean.allMemberPublicVisibleUsers();
355 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("UserWebBean:afterUserLogin: this.visibleUserList.size()={0} - EXIT!", this.visibleUserList.size())); //NOI18N
359 public void afterUserUpdatedPersonalData (@Observes final UpdatedUserPersonalDataEvent event) {
363 throw new NullPointerException("event is null"); //NOI18N
364 } else if (event.getUpdatedUser() == null) {
366 throw new NullPointerException("event.updatedUser is null"); //NOI18N
367 } else if (event.getUpdatedUser().getUserId() == null) {
369 throw new NullPointerException("event.updatedUser.userId is null"); //NOI18N
370 } else if (event.getUpdatedUser().getUserId() < 1) {
372 throw new IllegalArgumentException(MessageFormat.format("event.updatedUser.userId={0} is in valid", event.getUpdatedUser().getUserId())); //NOI18N
375 // All fine, so update list
376 this.updateList(event.getUpdatedUser());
380 public List<User> allUsers () {
382 return Collections.unmodifiableList(this.userList);
386 public List<User> allVisibleUsers () {
388 return Collections.unmodifiableList(this.visibleUserList);
392 public User createUserInstance () {
394 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createUserInstance: CALLED!", this.getClass().getSimpleName()));
396 // Required personal data must be set
397 assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
399 // Create new user instance
400 User user = new LoginUser();
402 // Is user name required?
403 if (!this.isUserNameRequired()) {
404 // Generate pseudo-random user name
405 String randomName = this.userBean.generateRandomUserName();
407 // Set it and inivisible profile
408 this.setUserName(randomName);
409 this.setUserProfileMode(ProfileMode.INVISIBLE);
411 // Generate random password
412 String randomPassword = UserUtils.createRandomPassword(PizzaUserWebSessionController.MINIMUM_PASSWORD_LENGTH);
414 // Set random password
415 this.setUserPassword(randomPassword);
416 this.setUserPasswordRepeat(randomPassword);
419 // Set local, user name and mode
420 user.setUserLocale(this.localizationController.getLocale());
421 user.setUserName(this.getUserName());
422 user.setUserProfileMode(this.getUserProfileMode());
424 // Is multiple registration page
425 if ((createContactData) || (!this.featureController.isFeatureEnabled("user_register_multiple_page"))) { //NOI18N
426 // Create contact instance
427 Contact contact = this.contactController.createContactInstance();
430 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createUserInstance: contact={1}", this.getClass().getSimpleName(), contact));
432 // Set contact in user
433 user.setUserContact(contact);
437 //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("{0}.createUserInstance: user={1} - EXIT!", this.getClass().getSimpleName(), user));
444 public User createUserLogin () {
446 //* NOISY-DEBUG */ System.out.println(MessageFormat.format("{0}.createUserLogin: CALLED!", this.getClass().getSimpleName()));
449 if (this.getUserName() == null) {
451 throw new NullPointerException("recruiterName is null"); //NOI18N
452 } else if (this.getUserName().isEmpty()) {
454 throw new IllegalStateException("recruiterName is empty."); //NOI18N
457 // Create new recruiter instance
458 User recruiter = new LoginUser();
460 // Update all data ...
461 recruiter.setUserName(this.getUserName());
464 //* NOISY-DEBUG */ System.out.println(MessageFormat.format("{0}.createUserLogin: recruiter={1} - EXIT!", this.getClass().getSimpleName(), recruiter));
466 // Return the new instance
471 public String doChangePersonalData () {
472 // This method shall only be called if the user is logged-in
473 if (!this.userLoginController.isUserLoggedIn()) {
475 throw new IllegalStateException("User is not logged-in"); //NOI18N
476 } else if (!this.isRequiredChangePersonalDataSet()) {
477 // Not all required fields are set
478 throw new FaceletException("Not all required fields are set."); //NOI18N
479 } else if (!this.userLoginController.ifCurrentPasswordMatches()) {
480 // Password not matching
481 throw new FaceletException(new UserPasswordMismatchException(this.userLoginController.getLoggedInUser()));
482 } else if (!this.featureController.isFeatureEnabled("edit_user_data")) {
483 // Editing is not allowed
484 throw new IllegalStateException("User tried to edit personal data"); //NOI18N
488 User user = this.userLoginController.getLoggedInUser();
490 // Copy contact data to contact instance
491 this.contactController.updateContactDataFromController(user.getUserContact());
493 // It should be there, so run some tests on it
494 assert (user instanceof User) : "Instance loginController.loggedInUser is null"; //NOI18N
495 assert (user.getUserId() instanceof Long) : "Instance loginController.loggedInUser.userId is null"; //NOI18N
496 assert (user.getUserId() > 0) : MessageFormat.format("loginController.loggedInUser.userId={0} is invalid", user.getUserId()); //NOI18N
497 assert (user.getUserContact() instanceof Contact) : "Instance loginController.loggedInUser.userContact is null"; //NOI18N
498 assert (user.getUserContact().getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null"; //NOI18N
499 assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); //NOI18N
502 user.setUserProfileMode(this.getUserProfileMode());
504 // Send it to the EJB
505 User updatedUser = this.userBean.updateUserPersonalData(user);
508 this.updatedPersonalDataEvent.fire(new UserUpdatedPersonalDataEvent(updatedUser));
511 return "user_data_saved"; //NOI18N
515 public Long getUserId () {
520 public void setUserId (final Long userId) {
521 this.userId = userId;
525 public String getUserName () {
526 return this.userName;
530 public void setUserName (final String userName) {
531 this.userName = userName;
535 public String getUserPassword () {
536 return this.userPassword;
540 public void setUserPassword (final String userPassword) {
541 this.userPassword = userPassword;
545 public String getUserPasswordRepeat () {
546 return this.userPasswordRepeat;
550 public void setUserPasswordRepeat (final String userPasswordRepeat) {
551 this.userPasswordRepeat = userPasswordRepeat;
555 public ProfileMode getUserProfileMode () {
556 return this.userProfileMode;
560 public void setUserProfileMode (final ProfileMode userProfileMode) {
561 this.userProfileMode = userProfileMode;
565 public boolean hasUsers () {
566 return (!this.allUsers().isEmpty());
570 * Post-initialization of this class
573 public void init () {
574 // Initialize user list
575 this.userList = this.userBean.allUsers();
577 // Get full user name list for reducing EJB calls
578 this.userNameList = this.userBean.getUserNameList();
580 // Is the user logged-in?
581 if (this.userLoginController.isUserLoggedIn()) {
582 // Is logged-in, so load also users visible to memebers
583 this.visibleUserList = this.userBean.allMemberPublicVisibleUsers();
585 // Initialize user list
586 this.visibleUserList = this.userBean.allPublicUsers();
591 public boolean isContactFound (final Contact contact) {
592 // The contact must be valid
593 if (null == contact) {
595 throw new NullPointerException("contact is null"); //NOI18N
596 } else if (contact.getContactId() == null) {
598 throw new NullPointerException("contact.contactId is null"); //NOI18N
599 } else if (contact.getContactId() < 1) {
601 throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
604 // Default is not found
605 boolean isFound = false;
608 Iterator<User> iterator = this.allUsers().iterator();
610 // Loop through all entries
611 while (iterator.hasNext()) {
613 User next = iterator.next();
615 // Compare both objects
616 if (Objects.equals(contact, next.getUserContact())) {
628 public boolean isPublicUserProfileEnabled () {
629 // Get context parameter
630 String contextParameter = FacesContext.getCurrentInstance().getExternalContext().getInitParameter("is_public_profile_enabled"); //NOI18N
633 boolean isEnabled = ((contextParameter instanceof String) && (contextParameter.toLowerCase().equals("true"))); //NOI18N
635 // This requires user names being enabled, too.
636 if ((isEnabled) && (!this.isUserNameRequired())) {
637 // Not valid state, users must be able to modify their profile, especially when it is public
638 throw new IllegalStateException("Public user profiles are enabled but user name requirement is disabled, this is not possible."); //NOI18N
646 public boolean isRequiredChangePersonalDataSet () {
647 return ((this.getUserProfileMode() != null) &&
648 (this.getUserName() != null) && (!this.getUserName().isEmpty()) &&
649 (this.contactController.isRequiredChangePersonalDataSet()));
653 public boolean isRequiredPersonalDataSet () {
654 if (this.featureController.isFeatureEnabled("user_register_multiple_page")) { //NOI18N
655 // Multiple registration page
656 return this.contactController.isRequiredPersonalDataSet();
658 // Single registration page
659 return (((this.getUserName() != null) || (!this.isUserNameRequired())) &&
660 (this.getUserProfileMode() != null) &&
661 (this.contactController.isRequiredPersonalDataSet()) &&
662 (this.getUserPassword() != null) &&
663 (this.getUserPasswordRepeat() != null));
668 public boolean isSamePasswordEntered () {
669 return ((!this.getUserPassword().isEmpty()) && (Objects.equals(this.getUserPassword(), this.getUserPasswordRepeat())));
673 public boolean isUserIdEmpty () {
674 return ((this.getUserId() == null) || (this.getUserId() == 0));
678 public boolean isUserNameRegistered (final User user) {
679 return ((this.userNameList instanceof List) && (this.userNameList.contains(user.getUserName())));
683 public boolean isUserNameRequired () {
684 // Get context parameter
685 String contextParameter = FacesContext.getCurrentInstance().getExternalContext().getInitParameter("is_user_name_required"); //NOI18N
688 boolean isRequired = ((contextParameter instanceof String) && (contextParameter.toLowerCase().equals("true"))); //NOI18N
695 public boolean isVisibleUserFound () {
696 return ((this.visibleUserList instanceof List) && (!this.visibleUserList.isEmpty()));
700 public User lookupUserById (final Long userId) throws UserNotFoundException {
701 // Parameter must be valid
702 if (null == userId) {
704 throw new NullPointerException("userId is null"); //NOI18N
705 } else if (userId < 1) {
707 throw new IllegalArgumentException(MessageFormat.format("userId={0} is not valid.", userId)); //NOI18N
713 // Try to lookup it in visible user list
714 for (final Iterator<User> iterator = this.userList.iterator(); iterator.hasNext();) {
716 User next = iterator.next();
718 // Is the user id found?
719 if (Objects.equals(next.getUserId(), userId)) {
720 // Copy to other variable
728 // Not visible for the current user
729 throw new UserNotFoundException(userId);
737 public User lookupUserByEmailAddress (final String emailAddress) throws UserEmailAddressNotFoundException {
738 // Parameter must be valid
739 if (null == emailAddress) {
741 throw new NullPointerException("emailAddress is null"); //NOI18N
742 } else if (emailAddress.isEmpty()) {
744 throw new IllegalArgumentException("emailAddress is empty"); //NOI18N
750 // Try to lookup it in visible user list
751 for (final Iterator<User> iterator = this.userList.iterator(); iterator.hasNext();) {
753 User next = iterator.next();
755 // Contact should be set
756 if (next.getUserContact() == null) {
758 throw new NullPointerException(MessageFormat.format("next.userContact is null for user id {0}", next.getUserId())); //NOI18N
759 } else if (next.getUserContact().getContactEmailAddress() == null) {
760 // Email address should be set
761 throw new NullPointerException(MessageFormat.format("next.userContact.contactEmailAddress is null for user id {0}", next.getUserId())); //NOI18N //NOI18N
764 // Is the email address found?
765 if (Objects.equals(next.getUserContact().getContactEmailAddress(), emailAddress)) {
766 // Copy to other variable
774 // Not visible for the current user
775 throw new UserEmailAddressNotFoundException(emailAddress);
783 * Adds user's name to bean's internal list. It also updates the public user
784 * list if the user has decided to have a public account,
786 * @param user User instance
788 private void addUserName (final User user) {
789 // Make sure the entry is not added yet
790 if (this.userNameList.contains(user.getUserName())) {
792 throw new IllegalArgumentException(MessageFormat.format("User name {0} already added.", user.getUserName())); //NOI18N
793 } else if (this.contactController.isEmailAddressRegistered(user.getUserContact())) {
795 throw new IllegalArgumentException(MessageFormat.format("Email address {0} already added.", user.getUserContact().getContactEmailAddress())); //NOI18N
799 this.userNameList.add(user.getUserName());
805 private void clear () {
808 this.setUserId(null);
809 this.setUserProfileMode(null);
812 this.setUserName(null);
813 this.setUserPassword(null);
814 this.setUserPasswordRepeat(null);
818 * Copies given user into the controller
820 * @param user User instance
822 private void copyUser (final User user) {
823 // Make sure the instance is valid
826 throw new NullPointerException("user is null"); //NOI18N
827 } else if (user.getUserContact() == null) {
829 throw new NullPointerException("user.userContact is null"); //NOI18N
834 this.setUserId(user.getUserId());
835 this.setUserProfileMode(user.getUserProfileMode());
839 * Updates list with given user instance
841 * @param user User instance
843 private void updateList (final User user) {
844 // The user should be valid
847 throw new NullPointerException("user is null"); //NOI18N
848 } else if (user.getUserId() == null) {
850 throw new NullPointerException("user.userId is null"); //NOI18N
851 } else if (user.getUserId() < 1) {
853 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
857 Iterator<User> iterator = this.userList.iterator();
860 while (iterator.hasNext()) {
862 User next = iterator.next();
864 // Is the same user id?
865 if (Objects.equals(user.getUserId(), next.getUserId())) {
866 // Found it, so remove it
867 this.userList.remove(next);
873 this.userList.add(user);