From: Roland Haeder Date: Thu, 5 May 2016 12:18:52 +0000 (+0200) Subject: Continued a bit: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=08ffb270ee12dfba63a93f43f2bcbb12c46a48b7;p=juser-core.git Continued a bit: - added more (deeper) checks on parameter user - ignored strings for internationalization (i18n) --- diff --git a/src/org/mxchange/jusercore/container/login/UserLoginContainer.java b/src/org/mxchange/jusercore/container/login/UserLoginContainer.java index 267f70a..84df915 100644 --- a/src/org/mxchange/jusercore/container/login/UserLoginContainer.java +++ b/src/org/mxchange/jusercore/container/login/UserLoginContainer.java @@ -16,6 +16,7 @@ */ package org.mxchange.jusercore.container.login; +import java.text.MessageFormat; import org.mxchange.jusercore.model.user.User; /** @@ -50,13 +51,28 @@ public class UserLoginContainer implements LoginContainer { // Is both set? if (null == user) { // Throw NPE - throw new NullPointerException("user is null"); + 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) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N + } else if (user.getUserContact() == null) { + // Throw NPE again ... + throw new NullPointerException("user.userContact is null"); //NOI18N + } else if (user.getUserContact().getContactId() == null) { + // Throw NPE again ... + throw new NullPointerException("user.userContact.contactId is null"); //NOI18N + } else if (user.getUserContact().getContactId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is not valid", user.getUserContact().getContactId())); //NOI18N } else if (null == userPassword) { // Throw NPE again - throw new NullPointerException("userPassword is null"); + throw new NullPointerException("userPassword is null"); //NOI18N } else if (userPassword.isEmpty()) { // Empty password - throw new IllegalArgumentException("user password is empty."); + throw new IllegalArgumentException("user password is empty."); //NOI18N } // Set both