]> git.mxchange.org Git - jaddressbook-share-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 31 Jan 2023 14:23:56 +0000 (15:23 +0100)
committerRoland Häder <roland@mxchange.org>
Tue, 31 Jan 2023 14:23:56 +0000 (15:23 +0100)
- added checks on addressbookUserOwner field

src/org/mxchange/jaddressbookshare/model/shared/AddressbookShare.java

index e0c903d58ac0b8a3f917a910db8340d4c54c5646..351cf824f7a09b35e228b56461973eb6c0f3f48f 100644 (file)
@@ -149,6 +149,15 @@ public class AddressbookShare implements ShareableAddressbook {
                } else if (addressbook.getAddressbookId() < 1) {
                        // Invalid id number
                        throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookId={0} is invalid.", addressbook.getAddressbookId())); //NOI18N
+               } else if (addressbook.getAddressbookUser() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("addressbook.addressbookUser is null"); //NOI18N
+               } else if (addressbook.getAddressbookUser().getUserId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("addressbook.addressbookUser.userId is null"); //NOI18N
+               } else if (addressbook.getAddressbookUser().getUserId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookUser.userId={0} is invalid.", addressbook.getAddressbookUser().getUserId())); //NOI18N
                } else if (Objects.equals(addressbook.getAddressbookUser(), sharee)) {
                        // Sharing with yourself!
                        throw new IllegalStateException("User tries to share with himself."); //NOI18N