From: Roland Häder Date: Thu, 11 Aug 2016 12:09:36 +0000 (+0200) Subject: added more checks on user's contact instance (please cherry-pick) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=de7df11156998b33508d31ceaff989464ca7c2c4;p=jjobs-war.git added more checks on user's contact instance (please cherry-pick) --- diff --git a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java index 331f5c53..0e40c412 100644 --- a/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java +++ b/src/java/org/mxchange/jjobs/beans/user/JobsUserWebSessionBean.java @@ -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. - *

- * @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 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 *

@@ -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