return Objects.equals(this.getAddressbookUser(), this.loginController.getLoggedInUser());
}
+ @Override
+ public String startSharing () {
+ // Check conditions
+ if (!this.loginController.isUserLoggedIn()) {
+ // No, then throw exception
+ throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
+ } else if (this.getAddressbookUser() == null) {
+ // Throw NPE
+ throw new NullPointerException("this.addressbookUser is null"); //NOI18N
+ } else if (this.getAddressbookUser().getUserId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("this.addressbookUser.userId is null"); //NOI18N
+ } else if (this.getAddressbookUser().getUserId() < 1) {
+ // Invalid id number
+ throw new IllegalStateException(MessageFormat.format("this.addressbookUser.userId={0} is invalid", this.getAddressbookUser().getUserId())); //NOI18N
+ } else if (Objects.equals(this.getAddressbookUser(), this.loginController.getLoggedInUser())) {
+ // Sharing with yourself!
+ throw new IllegalStateException("User tries to share with himself."); //NOI18N
+ } else if (this.getAddressbook() == null) {
+ // Throw NPE again
+ throw new NullPointerException("this.addressbook is null"); //NOI18N
+ } else if (this.getAddressbook().getAddressbookId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("this.addressbook.addressbookId is null"); //NOI18N
+ } else if (this.getAddressbook().getAddressbookId() < 1) {
+ // Invalid id number
+ throw new IllegalArgumentException(MessageFormat.format("this.addressbook.addressbookId={0} is invalid.", this.getAddressbook().getAddressbookId())); //NOI18N
+ }
+
+ // TODO Unfinished
+ return null;
+ }
+
/**
* Initializes the user user's address book list
*/