From: Roland Häder Date: Tue, 31 Jan 2023 14:23:56 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=ac03051d8950affddec11dda40bb84789d3a1601;p=jaddressbook-share-core.git Continued: - added checks on addressbookUserOwner field --- diff --git a/src/org/mxchange/jaddressbookshare/model/shared/AddressbookShare.java b/src/org/mxchange/jaddressbookshare/model/shared/AddressbookShare.java index e0c903d..351cf82 100644 --- a/src/org/mxchange/jaddressbookshare/model/shared/AddressbookShare.java +++ b/src/org/mxchange/jaddressbookshare/model/shared/AddressbookShare.java @@ -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