]> git.mxchange.org Git - addressbook-war.git/commitdiff
Implemented isOwnAddressbook() and isOtherAddressbook()
authorRoland Haeder <roland@mxchange.org>
Thu, 15 Oct 2015 17:42:11 +0000 (19:42 +0200)
committerRoland Haeder <roland@mxchange.org>
Thu, 15 Oct 2015 17:42:11 +0000 (19:42 +0200)
src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebBean.java
src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebController.java

index b97648e66a900621643f4e90a04eb01ea4e1edc4..1c66acdff2feecc17a247aef388b5b1828586864 100644 (file)
@@ -22,6 +22,7 @@ import java.util.Calendar;
 import java.util.Collections;
 import java.util.GregorianCalendar;
 import java.util.List;
+import java.util.Objects;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import javax.annotation.PostConstruct;
@@ -372,6 +373,24 @@ public class AddressbookWebBean implements AddressbookWebController {
                return isFound;
        }
 
+       @Override
+       public boolean isOtherAddressbook () {
+               // Just call the other method and invert it
+               return (!this.isOwnAddressbook());
+       }
+
+       @Override
+       public boolean isOwnAddressbook () {
+               // Is the user logged in?
+               if (!this.loginController.isUserLoggedIn()) {
+                       // No, then no own address book
+                       return false;
+               }
+
+               // Is same user?
+               return Objects.equals(this.getAddressbookUser(), this.loginController.getLoggedInUser());
+       }
+
        /**
         * Initializes the user user's address book list
         */
index 96546cb7401a8312c59535b09a6a2de43c1e3b61..285ce793377f527bbdb4789e7fcf8acbb969a401 100644 (file)
@@ -171,4 +171,21 @@ public interface AddressbookWebController extends Serializable {
         * @param event
         */
        void afterLoginEvent (final UserLoggedInEvent event);
+
+       /**
+        * Checks if the user is logged in and if so if it matches the current
+        * address book owner.
+        * <p>
+        * @return Whether the owner matches currently logged-in user
+        */
+       boolean isOwnAddressbook ();
+
+       /**
+        * Checks if the owner of the current address book is NOT matching the
+        * logged-in user.
+        * <p>
+        * @return Whether the user does NOT match
+        */
+       boolean isOtherAddressbook ();
+
 }