]> git.mxchange.org Git - juser-activity-core.git/commitdiff
Continued a bit:
authorRoland Haeder <roland@mxchange.org>
Thu, 5 May 2016 12:18:52 +0000 (14:18 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 5 May 2016 12:18:52 +0000 (14:18 +0200)
- added more (deeper) checks on parameter user
- ignored strings for internationalization (i18n)

src/org/mxchange/jusercore/container/login/UserLoginContainer.java

index 267f70a2f8c71038f8c3fb35d8f221e297e7173e..84df915b5b729bf0308152af77c7261bba1b0e01 100644 (file)
@@ -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