+ // Initialize user list
+ this.userList = this.userBean.allUsers();
+
+ // Get full user name list for reducing EJB calls
+ this.userNameList = this.userBean.getUserNameList();
+
+ // Is the user logged-in?
+ if (this.userLoginController.isUserLoggedIn()) {
+ // Is logged-in, so load also users visible to memebers
+ this.visibleUserList = this.userBean.allMemberPublicVisibleUsers();
+ } else {
+ // Initialize user list
+ this.visibleUserList = this.userBean.allPublicUsers();
+ }
+
+ // Get all users
+ List<User> allUsers = this.allUsers();
+
+ // Get all contacts
+ List<Contact> allContacts = this.contactBean.getAllContacts();
+
+ // Get iterator
+ Iterator<Contact> iterator = allContacts.iterator();
+
+ // Loop through it
+ while (iterator.hasNext()) {
+ // Get next element
+ Contact next = iterator.next();
+
+ // Get iterator
+ Iterator<User> userIterator = allUsers.iterator();
+
+ // Loop through all users
+ while (userIterator.hasNext()) {
+ // Get user instance
+ User nextUser = userIterator.next();
+
+ // Is contact same?
+ if (Objects.equals(next, nextUser.getUserContact())) {
+ // Found same
+ iterator.remove();
+ break;
+ }
+ }
+ }
+
+ // Set contact list
+ this.selectableContacts = allContacts;
+ }
+
+ @Override
+ public boolean isContactFound (final Contact contact) {
+ // The contact must be valid
+ if (null == contact) {
+ // Throw NPE
+ throw new NullPointerException("contact is null"); //NOI18N
+ } else if (contact.getContactId() == null) {
+ // Throw again ...
+ throw new NullPointerException("contact.contactId is null"); //NOI18N
+ } else if (contact.getContactId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("contact.contactId={0} is not valid", contact.getContactId())); //NOI18N
+ }
+
+ // Default is not found
+ boolean isFound = false;
+
+ // Get iterator
+ Iterator<User> iterator = this.allUsers().iterator();
+
+ // Loop through all entries
+ while (iterator.hasNext()) {
+ // Get user
+ User next = iterator.next();
+
+ // Compare both objects
+ if (Objects.equals(contact, next.getUserContact())) {
+ // Found it
+ isFound = true;
+ break;
+ }
+ }
+
+ // Return status
+ return isFound;
+ }
+
+ @Override
+ public boolean isPublicUserProfileEnabled () {
+ // Get context parameter
+ String contextParameter = FacesContext.getCurrentInstance().getExternalContext().getInitParameter("is_public_profile_enabled"); //NOI18N
+
+ // Is it set?
+ boolean isEnabled = ((contextParameter instanceof String) && (contextParameter.toLowerCase().equals("true"))); //NOI18N
+
+ // This requires user names being enabled, too.
+ if ((isEnabled) && (!this.isUserNameRequired())) {
+ // Not valid state, users must be able to modify their profile, especially when it is public
+ throw new IllegalStateException("Public user profiles are enabled but user name requirement is disabled, this is not possible."); //NOI18N
+ }
+
+ // Return value
+ return isEnabled;