- @Override
- public boolean isUserNameRegistered (final User user) {
- return ((this.userNameList instanceof List) && (this.userNameList.contains(user.getUserName())));
- }
-
- @Override
- public boolean isVisibleUserFound () {
- return ((this.visibleUserList instanceof List) && (this.visibleUserList.size() > 0));
- }
-
- @Override
- public User lookupUserById (final Long userId) throws UserNotFoundException {
- // Init variable
- User localUser = null;
-
- // Clear this bean
- this.clear();
-
- // Try to lookup it in visible user list
- for (final Iterator<User> iterator = this.visibleUserList.iterator(); iterator.hasNext();) {
- // Get next user
- User next = iterator.next();
-
- // Is the user id found?
- if (Objects.equals(next.getUserId(), userId)) {
- // Copy to other variable
- localUser = next;
- break;
- }
- }
-
- // Is it still null?
- if (null == localUser) {
- // Not visible for the current user
- throw new UserNotFoundException(userId);
- }
-
- // Copy all data to this bean
- this.copyUser(localUser);
-
- // Return it
- return localUser;
- }
-
- /**
- * Adds user's name and email address to bean's internal list. It also
- * updates the public user list if the user has decided to ha }
- * <p>
- * @param user User instance
- */
- private void addUserNameEmailAddress (final User user) {
- // Make sure the entry is not added yet
- if (this.userNameList.contains(user.getUserName())) {
- // Abort here
- throw new IllegalArgumentException(MessageFormat.format("User name {0} already added.", user.getUserName())); //NOI18N
- } else if (this.contactController.isEmailAddressRegistered(user.getUserContact())) {
- // Already added
- throw new IllegalArgumentException(MessageFormat.format("Email address {0} already added.", user.getUserContact().getContactEmailAddress())); //NOI18N
- }
-
- // Add user name
- this.userNameList.add(user.getUserName());
-
- // Add email addres
- this.contactController.addEmailAddress(user.getUserContact().getContactEmailAddress());
- }
-