]> git.mxchange.org Git - addressbook-war.git/commitdiff
added bean method startSharing() with unfinished part
authorRoland Haeder <roland@mxchange.org>
Thu, 15 Oct 2015 19:08:38 +0000 (21:08 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 15 Oct 2015 19:08:38 +0000 (21:08 +0200)
src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java
src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java

index 5593aa0af5598c2c03533f612c595c7ed1b89891..ff12c1b68940ac6676b91a88321b91986c6c7804 100644 (file)
@@ -421,6 +421,39 @@ public class AddressbookWebBean implements AddressbookWebController {
                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
         */
index 97995957b3d63e3700634261e178e6858b214c26..5cc2ffb7ed839eef296f54db2cadb7fd657df515 100644 (file)
@@ -209,4 +209,12 @@ public interface AddressbookWebController extends Serializable {
         * @return List of not sharing users
         */
        List<User> allUsersNotSharing ();
+
+       /**
+        * Starts an address book share between currently logged-in user and
+        * assigned user for current address book.
+        * <p>
+        * @return Redirect target
+        */
+       String startSharing ();
 }