]> git.mxchange.org Git - jjobs-war.git/commitdiff
added more checks on user's contact instance (please cherry-pick)
authorRoland Häder <roland@mxchange.org>
Thu, 11 Aug 2016 12:09:36 +0000 (14:09 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 19 Aug 2016 20:56:19 +0000 (22:56 +0200)
src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java

index 331f5c53d87f83b64ba933b2a1f555422d07db47..0e40c412b03993e76213525a444b09e50f6326bf 100644 (file)
@@ -912,42 +912,6 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
                this.setUserProfileMode(user.getUserProfileMode());
        }
 
-       /**
-        * Uniquely adds given user instance to user list. First an existing
-        * instance will be removed, then the given instance is being added.
-        * <p>
-        * @param user User instance to add
-        */
-       private void uniqueAddUser (final User user) {
-               // Make sure the instance is 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
-               }
-
-               // Get iterator from list
-               Iterator<User> iterator = this.userList.iterator();
-
-               // "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);
-       }
-
        /**
         * Updates list with given user instance
         * <p>
@@ -958,15 +922,21 @@ public class JobsUserWebSessionBean extends BaseJobsController implements JobsUs
                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
+               } 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 from list