From: Roland Häder Date: Fri, 9 Jun 2017 19:43:54 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=38e8fdc1bad01739da4f845fa510416efea7d22a;p=addressbook-core.git Please cherry-pick: - added more checks on parameters (AKA sanity-check) Signed-off-by: Roland Häder --- diff --git a/src/org/mxchange/addressbook/database/BaseAddressbookDatabaseBean.java b/src/org/mxchange/addressbook/database/BaseAddressbookDatabaseBean.java index 40c905f..4f05c77 100644 --- a/src/org/mxchange/addressbook/database/BaseAddressbookDatabaseBean.java +++ b/src/org/mxchange/addressbook/database/BaseAddressbookDatabaseBean.java @@ -57,7 +57,7 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean { } /** - * Updates all contacts's phone entry's created timestamps + * Updates all contact's phone entry's created timestamps *

* @param contact Contact instance to update */ @@ -458,6 +458,36 @@ public abstract class BaseAddressbookDatabaseBean extends BaseDatabaseBean { } else if (null == emailAddress) { // Throw NPE throw new NullPointerException("emailAddress is null"); //NOI18N + }else if (null == user) { + // Throw NPE + throw new NullPointerException("user is null"); //NOI18N + } else if (user.getUserId() == null) { + // Throw NPE again + throw new NullPointerException("user.userId is null"); //NOI18N + } else if (user.getUserId() < 1) { + // Not valid number + throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N + } else if (user.getUserName() == null) { + // Throw NPE again + throw new NullPointerException("user.userName is null"); //NOI18N + } else if (user.getUserName().isEmpty()) { + // Empty string + throw new IllegalArgumentException("user.userName is empty"); //NOI18N + } else if (user.getUserAccountStatus() == null) { + // Throw NPE + throw new NullPointerException("user.userAccountStatus is null"); //NOI18N + } else if (user.getUserContact() == null) { + // Throw it again + throw new NullPointerException("user.userContact is null"); //NOI18N + } else if (user.getUserContact().getContactId() == null) { + // .. and again + throw new NullPointerException("user.userContact.contactId is null"); //NOI18N + } else if (user.getUserContact().getContactId() < 1) { + // Invalid id + throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is invalid", user.getUserContact().getContactId())); //NOI18N + } else if (user.getUserContact().getContactGender() == null) { + // Throw NPE again + throw new NullPointerException("user.userContact.contactGender is null"); //NOI18N } // Prepare mail wrapper