]> git.mxchange.org Git - addressbook-war.git/commitdiff
ported project to new libraries jaddressbook-share-core/lib
authorRoland Häder <roland@mxchange.org>
Thu, 27 Apr 2017 12:30:22 +0000 (14:30 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 27 Apr 2017 12:30:22 +0000 (14:30 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
13 files changed:
nbproject/build-impl.xml
nbproject/genfiles.properties
nbproject/project.properties
nbproject/project.xml
src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebSessionBean.java
src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebSessionController.java
src/java/org/mxchange/addressbook/beans/addressbook/share/AddressbookSharesWebSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/addressbook/beans/addressbook/share/AddressbookSharesWebSessionController.java [new file with mode: 0644]
src/java/org/mxchange/addressbook/beans/shares/AddressbookSharesWebSessionBean.java [deleted file]
src/java/org/mxchange/addressbook/beans/shares/AddressbookSharesWebSessionController.java [deleted file]
src/java/org/mxchange/addressbook/validator/addressbook/AddressbookIdValidator.java
web/guest/user/user_show_addressbook.xhtml
web/user/login_start_sharing_addressbook.xhtml

index 961c79916db9b453984232885788f8a15174c323..453bca0e9eaf739e0a2ae6306c1b628c71d5c824 100644 (file)
@@ -1042,13 +1042,10 @@ exists or setup the property manually. For example like this:
     </target>
     <target depends="init,compile,compile-jsps,-pre-dist,-do-dist-with-manifest,-do-dist-without-manifest" name="do-dist"/>
     <target depends="init" if="dist.ear.dir" name="library-inclusion-in-manifest">
-        <copyfiles files="${reference.addressbook-core.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <mkdir dir="${build.web.dir}/META-INF"/>
         <manifest file="${build.web.dir}/META-INF/MANIFEST.MF" mode="update"/>
     </target>
-    <target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir">
-        <copyfiles files="${reference.addressbook-core.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
-    </target>
+    <target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir"/>
     <target depends="init" if="dist.ear.dir" name="-clean-webinf-lib">
         <delete dir="${build.web.dir}/WEB-INF/lib"/>
     </target>
index ce3203167b48656a0e8a4a2852d848775074d5e0..f1e9f3a6f50d038054426e86b98f004b12f5fabc 100644 (file)
@@ -3,6 +3,6 @@ build.xml.script.CRC32=be5f34f7
 build.xml.stylesheet.CRC32=651128d4@1.68.1.1
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=f07494a8
-nbproject/build-impl.xml.script.CRC32=8dc59c00
+nbproject/build-impl.xml.data.CRC32=25847443
+nbproject/build-impl.xml.script.CRC32=b9d55450
 nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.75.1.1
index 203ad966cfbb5ca44fd61ace6be57c1c317b8535..f0a373be50b50124fce0771a368caa6c1bc9df0f 100644 (file)
@@ -39,6 +39,8 @@ file.reference.cdi-api.jar=lib/cdi-api.jar
 file.reference.gf-client.jar=lib/gf-client.jar
 file.reference.jaddressbook-core.jar=lib/jaddressbook-core.jar
 file.reference.jaddressbook-lib.jar=lib/jaddressbook-lib.jar
+file.reference.jaddressbook-share-core.jar=lib/jaddressbook-share-core.jar
+file.reference.jaddressbook-share-lib.jar=lib/jaddressbook-share-lib.jar
 file.reference.jcontacts-business-core.jar=lib/jcontacts-business-core.jar
 file.reference.jcontacts-core.jar=lib/jcontacts-core.jar
 file.reference.jcontacts-lib.jar=lib/jcontacts-lib.jar
@@ -79,6 +81,8 @@ javac.classpath=\
     ${file.reference.juser-lib.jar}:\
     ${file.reference.jaddressbook-core.jar}:\
     ${file.reference.jaddressbook-lib.jar}:\
+    ${file.reference.jaddressbook-share-core.jar}:\
+    ${file.reference.jaddressbook-share-lib.jar}:\
     ${reference.addressbook-core.jar}:\
     ${reference.addressbook-lib.jar}:\
     ${reference.addressbook-mailer.jar}:\
@@ -134,6 +138,8 @@ runmain.jvmargs=
 source.encoding=UTF-8
 source.reference.jaddressbook-core.jar=../jaddressbook-core/src/
 source.reference.jaddressbook-lib.jar=../jaddressbook-lib/src/
+source.reference.jaddressbook-share-core.jar=../jaddressbook-share-core/src
+source.reference.jaddressbook-share-lib.jar=../jaddressbook-share-lib/src
 source.reference.jcontacts-business-core.jar=../jcontacts-business-core/src/
 source.reference.jcontacts-core.jar=../jcontacts-core/src/
 source.reference.jcontacts-lib.jar=../jcontacts-lib/src/
index a7ea36a57d25b99391b696d830043bac438aa644..4d9d8bb4ac7530d72b0e4038ed936b3507b6e6cb 100644 (file)
                 <library dirs="200">
                     <file>${file.reference.jaddressbook-lib.jar}</file>
                 </library>
+                <library dirs="200">
+                    <file>${file.reference.jaddressbook-share-core.jar}</file>
+                </library>
+                <library dirs="200">
+                    <file>${file.reference.jaddressbook-share-lib.jar}</file>
+                </library>
                 <library dirs="200">
                     <file>${reference.addressbook-core.jar}</file>
-                    <path-in-war>WEB-INF/lib</path-in-war>
                 </library>
                 <library dirs="200">
                     <file>${reference.addressbook-lib.jar}</file>
index 6a6b9fc2e0dd797a0c0bf9aff38b52efeec257db..e0363432d398ff028c6e734b723c9440b0b2b1ae 100644 (file)
@@ -22,8 +22,6 @@ import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
 import javax.annotation.PostConstruct;
 import javax.enterprise.context.SessionScoped;
 import javax.enterprise.event.Event;
@@ -38,13 +36,13 @@ import javax.naming.NamingException;
 import org.mxchange.addressbook.beans.BaseAddressbookController;
 import org.mxchange.addressbook.beans.login.user.AddressbookUserLoginWebSessionController;
 import org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote;
-import org.mxchange.jaddressbookcore.events.addressbook.AddressbookLoadedEvent;
-import org.mxchange.jaddressbookcore.events.addressbook.ObservableAddressbookLoadedEvent;
-import org.mxchange.jaddressbookcore.exceptions.AddressbookNameAlreadyUsedException;
-import org.mxchange.jaddressbookcore.exceptions.AddressbookNotFoundException;
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
-import org.mxchange.jaddressbookcore.model.addressbook.UserAddressbook;
-import org.mxchange.jaddressbookcore.model.addressbook.entry.AddressbookEntry;
+import org.mxchange.jaddressbook.events.addressbook.AddressbookLoadedEvent;
+import org.mxchange.jaddressbook.events.addressbook.ObservableAddressbookLoadedEvent;
+import org.mxchange.jaddressbook.exceptions.AddressbookNameAlreadyUsedException;
+import org.mxchange.jaddressbook.exceptions.AddressbookNotFoundException;
+import org.mxchange.jaddressbook.model.addressbook.Addressbook;
+import org.mxchange.jaddressbook.model.addressbook.UserAddressbook;
+import org.mxchange.jaddressbook.model.addressbook.entry.AddressbookEntry;
 import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent;
 import org.mxchange.jusercore.model.user.User;
 
@@ -57,11 +55,6 @@ import org.mxchange.jusercore.model.user.User;
 @SessionScoped
 public class AddressbookWebSessionBean extends BaseAddressbookController implements AddressbookWebSessionController {
 
-       /**
-        * Map for count of user's shared addresses
-        */
-       private static ConcurrentMap<User, Integer> countSharesList;
-
        /**
         * Serial number
         */
@@ -121,9 +114,6 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme
        public AddressbookWebSessionBean () {
                // Call super constructor
                super();
-
-               // Init list
-               AddressbookWebSessionBean.countSharesList = new ConcurrentHashMap<>(0);
        }
 
        @Override
@@ -164,7 +154,11 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme
                }
        }
 
-       @Override
+       /**
+        * Event being fired after an address book has been loaded
+        * <p>
+        * @param event Event being fired
+        */
        public void afterAddressbookLoadedEvent (@Observes final ObservableAddressbookLoadedEvent event) {
                // event should not be null
                if (null == event) {
@@ -197,7 +191,11 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme
                this.setAddressbook(book);
        }
 
-       @Override
+       /**
+        * Event being fired after user has logged-in
+        * <p>
+        * @param event Event being fired
+        */
        public void afterLoginEvent (@Observes final ObservableUserLoggedInEvent event) {
                // Is the user logged in?
                if (null == event) {
@@ -247,36 +245,6 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme
                return this.allEntries(addressbook).size();
        }
 
-       @Override
-       public List<User> allUsersNotSharing () {
-               // Is the user logged in?
-               if (!this.userLoginController.isUserLoggedIn()) {
-                       // Not logged in
-                       throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
-               }
-
-               // Call EJB
-               return this.addressbookBean.allUsersNotSharing(this.userLoginController.getLoggedInUser(), this.getAddressbook());
-       }
-
-       @Override
-       public Integer countAllUserSharedAddressbooks (final User user) {
-               // Is there cache?
-               if (AddressbookWebSessionBean.countSharesList.containsKey(user)) {
-                       // Return it instead
-                       return AddressbookWebSessionBean.countSharesList.get(user);
-               }
-
-               // Call EJB ("expensive")
-               Integer count = this.addressbookBean.countAllUserSharedAddressbooks(user);
-
-               // Add to list
-               AddressbookWebSessionBean.countSharesList.put(user, count);
-
-               // Return it
-               return count;
-       }
-
        @Override
        public Addressbook getAddressbook () {
                return this.addressbook;
index 43d84c30ce1f0bec70c888b955b925eb5b583071..2bf8014c6033628ca59e453e32f7228fffbed023 100644 (file)
@@ -19,11 +19,9 @@ package org.mxchange.addressbook.beans.addressbook;
 import java.io.Serializable;
 import java.util.Calendar;
 import java.util.List;
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
-import org.mxchange.jaddressbookcore.model.addressbook.entry.AddressbookEntry;
+import org.mxchange.jaddressbook.model.addressbook.Addressbook;
+import org.mxchange.jaddressbook.model.addressbook.entry.AddressbookEntry;
 import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jaddressbookcore.events.addressbook.ObservableAddressbookLoadedEvent;
-import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent;
 
 /**
  * An interface for address book beans
@@ -139,31 +137,6 @@ public interface AddressbookWebSessionController extends Serializable {
         */
        void setAddressbookCreated (final Calendar addressbookCreated);
 
-       /**
-        * This method is called when an address book has been successfully loaded
-        * from JPA.
-        * <p>
-        * @param event Event with address book instance
-        */
-       void afterAddressbookLoadedEvent (final ObservableAddressbookLoadedEvent event);
-
-       /**
-        * Count all shared address books by given user id
-        * <p>
-        * @param user User instance to look for
-        * <p>
-        * @return Count of user's shared address books
-        */
-       Integer countAllUserSharedAddressbooks (final User user);
-
-       /**
-        * This method is called when a user has successfully logged in his/her
-        * account.
-        * <p>
-        * @param event
-        */
-       void afterLoginEvent (final ObservableUserLoggedInEvent event);
-
        /**
         * Checks if the user is logged in and if so if it matches the current
         * address book owner.
@@ -194,14 +167,6 @@ public interface AddressbookWebSessionController extends Serializable {
         */
        void setAddressbook (final Addressbook addressbook);
 
-       /**
-        * Retrieves a list of all users this user is not sharing this address book
-        * with.
-        * <p>
-        * @return List of not sharing users
-        */
-       List<User> allUsersNotSharing ();
-
        /**
         * Checks wether an address book has been loaded by checking the id number.
         * <p>
diff --git a/src/java/org/mxchange/addressbook/beans/addressbook/share/AddressbookSharesWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/addressbook/share/AddressbookSharesWebSessionBean.java
new file mode 100644 (file)
index 0000000..5f90d78
--- /dev/null
@@ -0,0 +1,406 @@
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.beans.addressbook.share;
+
+import java.text.MessageFormat;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+import javax.faces.view.facelets.FaceletException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import org.mxchange.addressbook.beans.BaseAddressbookController;
+import org.mxchange.addressbook.beans.addressbook.AddressbookWebSessionController;
+import org.mxchange.addressbook.beans.login.user.AddressbookUserLoginWebSessionController;
+import org.mxchange.addressbook.model.shared.AddressbookShareSessionBeanRemote;
+import org.mxchange.jaddressbook.model.addressbook.Addressbook;
+import org.mxchange.jaddressbookshare.events.sharing.ObservableAddressbookSharingEvent;
+import org.mxchange.jaddressbookshare.events.sharing.StartedAddressbookSharingEvent;
+import org.mxchange.jaddressbookshare.events.sharing.type.SharingType;
+import org.mxchange.jaddressbookshare.exceptions.UserAlreadySharingAddressbookException;
+import org.mxchange.jaddressbookshare.model.addressbook.shared.ShareableAddressbook;
+import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
+
+/**
+ * A bean for sharing address books with other users
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Named (value = "shareController")
+@SessionScoped
+public class AddressbookSharesWebSessionBean extends BaseAddressbookController implements AddressbookSharesWebSessionController {
+
+       /**
+        * Map for count of user's shared addresses
+        */
+       private static ConcurrentMap<User, Integer> countSharesList;
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 19_868_976_871_976_780L;
+
+       /**
+        * Address book controller
+        */
+       @Inject
+       private AddressbookWebSessionController addressbookBean;
+
+       /**
+        * Remote bean for sharing address books
+        */
+       private AddressbookShareSessionBeanRemote addressbookShareBean;
+
+       /**
+        * Cached flag whether the user is sharing address books
+        */
+       private Boolean isUserSharing = null;
+
+       /**
+        * Share instance
+        */
+       private ShareableAddressbook share;
+
+       /**
+        * A list of all user's shared (with others) address books
+        */
+       private List<ShareableAddressbook> sharedAddressbooks;
+
+       /**
+        * User id of sharee
+        */
+       private Long shareeUserId;
+
+       /**
+        * An event triggered when address book sharing starts or ends
+        */
+       @Inject
+       @Any
+       private Event<ObservableAddressbookSharingEvent> sharingEvent;
+
+       /**
+        * Login controller injection
+        */
+       @Inject
+       private AddressbookUserLoginWebSessionController userLoginController;
+
+       /**
+        * Default constructor
+        */
+       public AddressbookSharesWebSessionBean () {
+               // Init list
+               countSharesList = new ConcurrentHashMap<>(0);
+       }
+
+       /**
+        * Observer method for ended sharing events
+        * <p>
+        * @param event Event instance
+        */
+       public void afterAdressbookShareEndedEvent (@Observes final ObservableAddressbookSharingEvent event) {
+               // Validate parameter
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getSharingType() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("event.sharingType is null"); //NOI18N
+               } else if (event.getSharingType() != SharingType.ENDED) {
+                       // Wrong event
+                       return;
+               }
+
+               // Validate event
+               this.validateEvent(event);
+
+               // Add it to list
+               this.sharedAddressbooks.remove(event.getShareableAddressbook());
+       }
+
+       /**
+        * Observer method for started sharing events
+        * <p>
+        * @param event Event instance
+        */
+       public void afterAdressbookShareStartedEvent (@Observes final ObservableAddressbookSharingEvent event) {
+               // Validate parameter
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getSharingType() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("event.sharingType is null"); //NOI18N
+               } else if (event.getSharingType() != SharingType.STARTED) {
+                       // Wrong event
+                       return;
+               }
+
+               // Validate event
+               this.validateEvent(event);
+
+               // Add it to list
+               this.sharedAddressbooks.add(event.getShareableAddressbook());
+       }
+
+       /**
+        * This method is called when a user has successfully logged in his/her
+        * account.
+        * <p>
+        * @param event Event instance
+        */
+       public void afterLoginEvent (@Observes final ObservableUserLoggedInEvent event) {
+               // Is the user logged in?
+               if (null == event) {
+                       // Is null
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getLoggedInUser() == null) {
+                       // user is null
+                       throw new NullPointerException("event.user is null"); //NOI18N
+               }
+
+               // Init share list
+               this.sharedAddressbooks = this.addressbookShareBean.allSharedAddressbooks(event.getLoggedInUser());
+       }
+
+       @Override
+       public List<ShareableAddressbook> allShares () {
+               // Is the user logged in?
+               if (!this.userLoginController.isUserLoggedIn()) {
+                       // Not logged in
+                       throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
+               }
+
+               return Collections.unmodifiableList(this.sharedAddressbooks);
+       }
+
+       @Override
+       public List<User> allUsersNotSharing () {
+               // Is the user logged in?
+               if (!this.userLoginController.isUserLoggedIn()) {
+                       // Not logged in
+                       throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
+               }
+
+               // Call EJB
+               return this.addressbookShareBean.allUsersNotSharing(this.userLoginController.getLoggedInUser(), this.addressbookBean.getAddressbook());
+       }
+
+       @Override
+       public Integer countAllUserSharedAddressbooks (final User user) {
+               // Is there cache?
+               if (countSharesList.containsKey(user)) {
+                       // Return it instead
+                       return countSharesList.get(user);
+               }
+
+               // Call EJB ("expensive")
+               Integer count = this.addressbookShareBean.countAllUserSharedAddressbooks(user);
+
+               // Add to list
+               countSharesList.put(user, count);
+
+               // Return it
+               return count;
+       }
+
+       @Override
+       public ShareableAddressbook getShare () {
+               return this.share;
+       }
+
+       @Override
+       public void setShare (final ShareableAddressbook share) {
+               this.share = share;
+       }
+
+       @Override
+       public Long getShareeUserId () {
+               return this.shareeUserId;
+       }
+
+       @Override
+       public void setShareeUserId (final Long shareeUserId) {
+               this.shareeUserId = shareeUserId;
+       }
+
+       /**
+        * Post-initialization of this class
+        */
+       @PostConstruct
+       public void init () {
+               // Try it
+               try {
+                       // Get initial context
+                       Context context = new InitialContext();
+
+                       // Look up bean
+                       this.addressbookShareBean = (AddressbookShareSessionBeanRemote) context.lookup("ejb/stateless-addressbook-share"); //NOI18N
+               } catch (final NamingException ex) {
+                       // Continue to throw
+                       throw new FaceletException(ex);
+               }
+
+       }
+
+       @Override
+       public boolean isShareeUserIdEmpty () {
+               return (!this.isShareeUserIdSet());
+       }
+
+       @Override
+       public boolean isShareeUserIdSet () {
+               return ((this.getShareeUserId() instanceof Long) && (this.getShareeUserId() > 0));
+       }
+
+       @Override
+       public boolean isSharingAddressbooks () {
+               // Only to be called for logged-in users
+               if (!this.userLoginController.isUserLoggedIn()) {
+                       // Not logged in
+                       throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
+               } else if (this.isUserSharing instanceof Boolean) {
+                       // Return cached value
+                       return this.isUserSharing;
+               }
+
+               // Call the proper bean
+               this.isUserSharing = this.addressbookShareBean.isUserSharingAddressbooks(this.userLoginController.getLoggedInUser());
+
+               // Return it
+               return this.isUserSharing;
+       }
+
+       @Override
+       public String startSharing (final User user, final Addressbook addressbook) {
+               // Check conditions
+               if (!this.userLoginController.isUserLoggedIn()) {
+                       // No, then throw exception
+                       throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
+               } else if (null == user) {
+                       // Throw NPE
+                       throw new NullPointerException("user is null"); //NOI18N
+               } else if (user.getUserId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("user.userId is null"); //NOI18N
+               } else if (user.getUserId() < 1) {
+                       // Invalid id number
+                       throw new IllegalStateException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
+               } else if (Objects.equals(user, this.userLoginController.getLoggedInUser())) {
+                       // Sharing with yourself!
+                       throw new IllegalStateException("User tries to share with himself."); //NOI18N
+               } else if (null == addressbook) {
+                       // Throw NPE again
+                       throw new NullPointerException("addressbook is null"); //NOI18N
+               } else if (addressbook.getAddressbookId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("addressbook.addressbookId is null"); //NOI18N
+               } else if (addressbook.getAddressbookId() < 1) {
+                       // Invalid id number
+                       throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookId={0} is invalid.", addressbook.getAddressbookId())); //NOI18N
+               } else if (!Objects.equals(addressbook.getAddressbookUser(), this.userLoginController.getLoggedInUser())) {
+                       // Not the same user!
+                       throw new IllegalStateException(MessageFormat.format("Address book id {0} owner id {1} mismatching logged-in user id {2}", addressbook.getAddressbookId(), addressbook.getAddressbookUser().getUserId(), this.userLoginController.getLoggedInUser().getUserId())); //NOI18N
+               } else if (this.userLoginController.getLoggedInUser().getUserProfileMode() == ProfileMode.INVISIBLE) {
+                       // User is invisible
+                       throw new FaceletException(MessageFormat.format("user {0} is invisible and cannot start sharing address books.", this.userLoginController.getLoggedInUser().getUserId())); //NOI18N
+               } else if (user.getUserProfileMode() == ProfileMode.INVISIBLE) {
+                       // User is invisible
+                       throw new FaceletException(MessageFormat.format("user {0} is invisible and cannot be selected for sharing.", user.getUserId())); //NOI18N
+               }
+
+               try {
+                       // Init sharing
+                       ShareableAddressbook shared = this.addressbookShareBean.startSharing(user, addressbook);
+
+                       // TODO Set it here
+                       this.setShare(shared);
+
+                       /// Trigger event
+                       this.sharingEvent.fire(new StartedAddressbookSharingEvent(shared));
+               } catch (final UserAlreadySharingAddressbookException ex) {
+                       // Throw again
+                       throw new FaceletException(ex);
+               }
+
+               // TODO Unfinished
+               return null;
+       }
+
+       /**
+        * Validates given event for all values and throws exceptions
+        * <p>
+        * @param event Event to validate
+        */
+       private void validateEvent (final ObservableAddressbookSharingEvent event) {
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getSharingType() == null) {
+                       // Throw NPE
+                       throw new NullPointerException("event.sharingType is null"); //NOI18N
+               } else if (event.getShareableAddressbook() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.shareableAddressbook is null"); //NOI18N
+               } else if (event.getShareableAddressbook().getShareId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.shareableAddressbook.shareId is null"); //NOI18N
+               } else if (event.getShareableAddressbook().getShareId() < 1) {
+                       // Throw NPE again
+                       throw new IllegalArgumentException(MessageFormat.format("event.shareableAddressbook.shareId={0} is invalid", event.getShareableAddressbook().getShareId())); //NOI18N
+               } else if (event.getShareableAddressbook().getShareAddressbook() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.shareableAddressbook.shareAddressbook is null"); //NOI18N
+               } else if (event.getShareableAddressbook().getShareAddressbook().getAddressbookId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.shareableAddressbook.shareAddressbook.addressbookId is null"); //NOI18N
+               } else if (event.getShareableAddressbook().getShareAddressbook().getAddressbookId() < 1) {
+                       // Throw NPE again
+                       throw new IllegalArgumentException(MessageFormat.format("event.shareableAddressbook.shareAddressbook.addressbookId={0} is invalid", event.getShareableAddressbook().getShareAddressbook().getAddressbookId())); //NOI18N
+               } else if (event.getShareableAddressbook().getShareUserOwner() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.shareableAddressbook.shareUserOwner is null"); //NOI18N
+               } else if (event.getShareableAddressbook().getShareUserOwner().getUserId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.shareableAddressbook.shareUserOwner.userId is null"); //NOI18N
+               } else if (event.getShareableAddressbook().getShareUserOwner().getUserId() < 1) {
+                       // Throw NPE again
+                       throw new IllegalArgumentException(MessageFormat.format("event.shareableAddressbook.shareUserOwner.userId={0} is invalid", event.getShareableAddressbook().getShareUserOwner().getUserId())); //NOI18N
+               } else if (event.getShareableAddressbook().getShareUserSharee() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.shareableAddressbook.shareUserSharee is null"); //NOI18N
+               } else if (event.getShareableAddressbook().getShareUserSharee().getUserId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.shareableAddressbook.shareUserSharee.userId is null"); //NOI18N
+               } else if (event.getShareableAddressbook().getShareUserSharee().getUserId() < 1) {
+                       // Throw NPE again
+                       throw new IllegalArgumentException(MessageFormat.format("event.shareableAddressbook.shareUserSharee.userId={0} is invalid", event.getShareableAddressbook().getShareUserOwner().getUserId())); //NOI18N
+               }
+       }
+
+}
diff --git a/src/java/org/mxchange/addressbook/beans/addressbook/share/AddressbookSharesWebSessionController.java b/src/java/org/mxchange/addressbook/beans/addressbook/share/AddressbookSharesWebSessionController.java
new file mode 100644 (file)
index 0000000..18b44ed
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2016 Roland Häder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.beans.addressbook.share;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jaddressbook.model.addressbook.Addressbook;
+import org.mxchange.jaddressbookshare.model.addressbook.shared.ShareableAddressbook;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * Controller interface sharing address books
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface AddressbookSharesWebSessionController extends Serializable {
+
+       /**
+        * Returns a list of all address books the user is sharing with others.
+        * <p>
+        * @return List of all shared address books
+        */
+       List<ShareableAddressbook> allShares ();
+
+       /**
+        * Getter for share instance
+        * <p>
+        * @return Share instance
+        */
+       ShareableAddressbook getShare ();
+
+       /**
+        * Setter for share instance
+        * <p>
+        * @param share Share instance
+        */
+       void setShare (final ShareableAddressbook share);
+
+       /**
+        * Getter for sharee's user id
+        * <p>
+        * @return Sharee's user id
+        */
+       Long getShareeUserId ();
+
+       /**
+        * Setter for sharee's user id
+        * <p>
+        * @param shareeUserId Sharee's user id
+        */
+       void setShareeUserId (final Long shareeUserId);
+
+       /**
+        * Checks if the sharee's user id is empty.
+        * <p>
+        * @return Whether the sharee's user id is empty.
+        */
+       boolean isShareeUserIdEmpty ();
+
+       /**
+        * Checks whether the sharee's user id is set
+        * <p>
+        * @return Whether the sharee's user id is set
+        */
+       boolean isShareeUserIdSet ();
+
+       /**
+        * Checks wether the current user is sharing address books with others
+        * <p>
+        * @return Whether the current user is sharing address books
+        */
+       boolean isSharingAddressbooks ();
+
+       /**
+        * Starts an address book share between currently logged-in user and
+        * assigned user for current address book.
+        * <p>
+        * @param user User instance
+        * @param addressbook Address book instance
+        * <p>
+        * @return Redirect target
+        */
+       String startSharing (final User user, final Addressbook addressbook);
+
+       /**
+        * Count all shared address books by given user id
+        * <p>
+        * @param user User instance to look for
+        * <p>
+        * @return Count of user's shared address books
+        */
+       Integer countAllUserSharedAddressbooks (final User user);
+
+       /**
+        * Retrieves a list of all users this user is not sharing this address book
+        * with.
+        * <p>
+        * @return List of not sharing users
+        */
+       List<User> allUsersNotSharing ();
+
+}
diff --git a/src/java/org/mxchange/addressbook/beans/shares/AddressbookSharesWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/shares/AddressbookSharesWebSessionBean.java
deleted file mode 100644 (file)
index eb1210a..0000000
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.beans.shares;
-
-import java.text.MessageFormat;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.SessionScoped;
-import javax.enterprise.event.Event;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Any;
-import javax.faces.view.facelets.FaceletException;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import org.mxchange.addressbook.beans.BaseAddressbookController;
-import org.mxchange.addressbook.beans.login.user.AddressbookUserLoginWebSessionController;
-import org.mxchange.addressbook.model.shared.SharedAddressbooksSessionBeanRemote;
-import org.mxchange.jaddressbookcore.events.sharing.StartedAddressbookSharingEvent;
-import org.mxchange.jaddressbookcore.events.sharing.type.SharingType;
-import org.mxchange.jaddressbookcore.exceptions.UserAlreadySharingAddressbookException;
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
-import org.mxchange.jaddressbookcore.model.addressbook.shared.ShareableAddressbook;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
-import org.mxchange.jaddressbookcore.events.sharing.ObservableAddressbookSharingEvent;
-import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent;
-
-/**
- * A bean for sharing address books with other users
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Named (value = "shareController")
-@SessionScoped
-public class AddressbookSharesWebSessionBean extends BaseAddressbookController implements AddressbookSharesWebSessionController {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 19_868_976_871_976_780L;
-
-       /**
-        * Cached flag whether the user is sharing address books
-        */
-       private Boolean isUserSharing = null;
-
-       /**
-        * Login controller injection
-        */
-       @Inject
-       private AddressbookUserLoginWebSessionController userLoginController;
-
-       /**
-        * Share instance
-        */
-       private ShareableAddressbook share;
-
-       /**
-        * Remote bean for sharing address books
-        */
-       private SharedAddressbooksSessionBeanRemote shareBean;
-
-       /**
-        * A list of all user's shared (with others) address books
-        */
-       private List<ShareableAddressbook> sharedAddressbooks;
-
-       /**
-        * User id of sharee
-        */
-       private Long shareeUserId;
-
-       /**
-        * An event triggered when address book sharing starts or ends
-        */
-       @Inject
-       @Any
-       private Event<ObservableAddressbookSharingEvent> sharingEvent;
-
-       /**
-        * Default constructor
-        */
-       public AddressbookSharesWebSessionBean () {
-               // Try it
-               try {
-                       // Get initial context
-                       Context context = new InitialContext();
-
-                       // Look up bean
-                       this.shareBean = (SharedAddressbooksSessionBeanRemote) context.lookup("ejb/stateless-addressbook-share"); //NOI18N
-               } catch (final NamingException ex) {
-                       // Continue to throw
-                       throw new FaceletException(ex);
-               }
-       }
-
-       @Override
-       public void afterAdressbookShareEnded (@Observes final ObservableAddressbookSharingEvent event) {
-               // Validate parameter
-               if (null == event) {
-                       // Throw NPE
-                       throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getSharingType() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("event.sharingType is null"); //NOI18N
-               } else if (event.getSharingType() != SharingType.ENDED) {
-                       // Wrong event
-                       return;
-               }
-
-               // Validate event
-               this.validateEvent(event);
-
-               // Add it to list
-               this.sharedAddressbooks.remove(event.getShareableAddressbook());
-       }
-
-       @Override
-       public void afterAdressbookShareStarted (@Observes final ObservableAddressbookSharingEvent event) {
-               // Validate parameter
-               if (null == event) {
-                       // Throw NPE
-                       throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getSharingType() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("event.sharingType is null"); //NOI18N
-               } else if (event.getSharingType() != SharingType.STARTED) {
-                       // Wrong event
-                       return;
-               }
-
-               // Validate event
-               this.validateEvent(event);
-
-               // Add it to list
-               this.sharedAddressbooks.add(event.getShareableAddressbook());
-       }
-
-       @Override
-       public void afterLoginEvent (@Observes final ObservableUserLoggedInEvent event) {
-               // Is the user logged in?
-               if (null == event) {
-                       // Is null
-                       throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getLoggedInUser() == null) {
-                       // user is null
-                       throw new NullPointerException("event.user is null"); //NOI18N
-               }
-
-               // Init share list
-               this.sharedAddressbooks = this.shareBean.allSharedAddressbooks(event.getLoggedInUser());
-       }
-
-       @Override
-       public List<ShareableAddressbook> allShares () {
-               // Is the user logged in?
-               if (!this.userLoginController.isUserLoggedIn()) {
-                       // Not logged in
-                       throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
-               }
-
-               return Collections.unmodifiableList(this.sharedAddressbooks);
-       }
-
-       @Override
-       public ShareableAddressbook getShare () {
-               return this.share;
-       }
-
-       @Override
-       public void setShare (final ShareableAddressbook share) {
-               this.share = share;
-       }
-
-       @Override
-       public Long getShareeUserId () {
-               return this.shareeUserId;
-       }
-
-       @Override
-       public void setShareeUserId (final Long shareeUserId) {
-               this.shareeUserId = shareeUserId;
-       }
-
-       /**
-        * Post-initialization of this class
-        */
-       @PostConstruct
-       public void init () {
-       }
-
-       @Override
-       public boolean isShareeUserIdEmpty () {
-               return (!this.isShareeUserIdSet());
-       }
-
-       @Override
-       public boolean isShareeUserIdSet () {
-               return ((this.getShareeUserId() instanceof Long) && (this.getShareeUserId() > 0));
-       }
-
-       @Override
-       public boolean isSharingAddressbooks () {
-               // Only to be called for logged-in users
-               if (!this.userLoginController.isUserLoggedIn()) {
-                       // Not logged in
-                       throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
-               } else if (this.isUserSharing instanceof Boolean) {
-                       // Return cached value
-                       return this.isUserSharing;
-               }
-
-               // Call the proper bean
-               this.isUserSharing = this.shareBean.isUserSharingAddressbooks(this.userLoginController.getLoggedInUser());
-
-               // Return it
-               return this.isUserSharing;
-       }
-
-       @Override
-       public String startSharing (final User user, final Addressbook addressbook) {
-               // Check conditions
-               if (!this.userLoginController.isUserLoggedIn()) {
-                       // No, then throw exception
-                       throw new FaceletException("This method can only be called as logged-in user."); //NOI18N
-               } else if (null == user) {
-                       // Throw NPE
-                       throw new NullPointerException("user is null"); //NOI18N
-               } else if (user.getUserId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("user.userId is null"); //NOI18N
-               } else if (user.getUserId() < 1) {
-                       // Invalid id number
-                       throw new IllegalStateException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
-               } else if (Objects.equals(user, this.userLoginController.getLoggedInUser())) {
-                       // Sharing with yourself!
-                       throw new IllegalStateException("User tries to share with himself."); //NOI18N
-               } else if (null == addressbook) {
-                       // Throw NPE again
-                       throw new NullPointerException("addressbook is null"); //NOI18N
-               } else if (addressbook.getAddressbookId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("addressbook.addressbookId is null"); //NOI18N
-               } else if (addressbook.getAddressbookId() < 1) {
-                       // Invalid id number
-                       throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookId={0} is invalid.", addressbook.getAddressbookId())); //NOI18N
-               } else if (!Objects.equals(addressbook.getAddressbookUser(), this.userLoginController.getLoggedInUser())) {
-                       // Not the same user!
-                       throw new IllegalStateException(MessageFormat.format("Address book id {0} owner id {1} mismatching logged-in user id {2}", addressbook.getAddressbookId(), addressbook.getAddressbookUser().getUserId(), this.userLoginController.getLoggedInUser().getUserId())); //NOI18N
-               } else if (this.userLoginController.getLoggedInUser().getUserProfileMode() == ProfileMode.INVISIBLE) {
-                       // User is invisible
-                       throw new FaceletException(MessageFormat.format("user {0} is invisible and cannot start sharing address books.", this.userLoginController.getLoggedInUser().getUserId())); //NOI18N
-               } else if (user.getUserProfileMode() == ProfileMode.INVISIBLE) {
-                       // User is invisible
-                       throw new FaceletException(MessageFormat.format("user {0} is invisible and cannot be selected for sharing.", user.getUserId())); //NOI18N
-               }
-
-               try {
-                       // Init sharing
-                       ShareableAddressbook shared = this.shareBean.startSharing(user, addressbook);
-
-                       // TODO Set it here
-                       this.setShare(shared);
-
-                       /// Trigger event
-                       this.sharingEvent.fire(new StartedAddressbookSharingEvent(shared));
-               } catch (final UserAlreadySharingAddressbookException ex) {
-                       // Throw again
-                       throw new FaceletException(ex);
-               }
-
-               // TODO Unfinished
-               return null;
-       }
-
-       /**
-        * Validates given event for all values and throws exceptions
-        * <p>
-        * @param event Event to validate
-        */
-       private void validateEvent (final ObservableAddressbookSharingEvent event) {
-               if (null == event) {
-                       // Throw NPE
-                       throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getSharingType() == null) {
-                       // Throw NPE
-                       throw new NullPointerException("event.sharingType is null"); //NOI18N
-               } else if (event.getShareableAddressbook() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("event.shareableAddressbook is null"); //NOI18N
-               } else if (event.getShareableAddressbook().getShareId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("event.shareableAddressbook.shareId is null"); //NOI18N
-               } else if (event.getShareableAddressbook().getShareId() < 1) {
-                       // Throw NPE again
-                       throw new IllegalArgumentException(MessageFormat.format("event.shareableAddressbook.shareId={0} is invalid", event.getShareableAddressbook().getShareId())); //NOI18N
-               } else if (event.getShareableAddressbook().getShareAddressbook() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("event.shareableAddressbook.shareAddressbook is null"); //NOI18N
-               } else if (event.getShareableAddressbook().getShareAddressbook().getAddressbookId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("event.shareableAddressbook.shareAddressbook.addressbookId is null"); //NOI18N
-               } else if (event.getShareableAddressbook().getShareAddressbook().getAddressbookId() < 1) {
-                       // Throw NPE again
-                       throw new IllegalArgumentException(MessageFormat.format("event.shareableAddressbook.shareAddressbook.addressbookId={0} is invalid", event.getShareableAddressbook().getShareAddressbook().getAddressbookId())); //NOI18N
-               } else if (event.getShareableAddressbook().getShareUserOwner() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("event.shareableAddressbook.shareUserOwner is null"); //NOI18N
-               } else if (event.getShareableAddressbook().getShareUserOwner().getUserId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("event.shareableAddressbook.shareUserOwner.userId is null"); //NOI18N
-               } else if (event.getShareableAddressbook().getShareUserOwner().getUserId() < 1) {
-                       // Throw NPE again
-                       throw new IllegalArgumentException(MessageFormat.format("event.shareableAddressbook.shareUserOwner.userId={0} is invalid", event.getShareableAddressbook().getShareUserOwner().getUserId())); //NOI18N
-               } else if (event.getShareableAddressbook().getShareUserSharee() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("event.shareableAddressbook.shareUserSharee is null"); //NOI18N
-               } else if (event.getShareableAddressbook().getShareUserSharee().getUserId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("event.shareableAddressbook.shareUserSharee.userId is null"); //NOI18N
-               } else if (event.getShareableAddressbook().getShareUserSharee().getUserId() < 1) {
-                       // Throw NPE again
-                       throw new IllegalArgumentException(MessageFormat.format("event.shareableAddressbook.shareUserSharee.userId={0} is invalid", event.getShareableAddressbook().getShareUserOwner().getUserId())); //NOI18N
-               }
-       }
-}
diff --git a/src/java/org/mxchange/addressbook/beans/shares/AddressbookSharesWebSessionController.java b/src/java/org/mxchange/addressbook/beans/shares/AddressbookSharesWebSessionController.java
deleted file mode 100644 (file)
index f3dd504..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Häder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.beans.shares;
-
-import java.io.Serializable;
-import java.util.List;
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
-import org.mxchange.jaddressbookcore.model.addressbook.shared.ShareableAddressbook;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jaddressbookcore.events.sharing.ObservableAddressbookSharingEvent;
-import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent;
-
-/**
- * Controller interface sharing address books
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface AddressbookSharesWebSessionController extends Serializable {
-
-       /**
-        * Observer method for ended sharing events
-        * <p>
-        * @param event Event instance
-        */
-       void afterAdressbookShareEnded (final ObservableAddressbookSharingEvent event);
-
-       /**
-        * Observer method for started sharing events
-        * <p>
-        * @param event Event instance
-        */
-       void afterAdressbookShareStarted (final ObservableAddressbookSharingEvent event);
-
-       /**
-        * This method is called when a user has successfully logged in his/her
-        * account.
-        * <p>
-        * @param event
-        */
-       void afterLoginEvent (final ObservableUserLoggedInEvent event);
-
-       /**
-        * Returns a list of all address books the user is sharing with others.
-        * <p>
-        * @return List of all shared address books
-        */
-       List<ShareableAddressbook> allShares ();
-
-       /**
-        * Getter for share instance
-        * <p>
-        * @return Share instance
-        */
-       ShareableAddressbook getShare ();
-
-       /**
-        * Setter for share instance
-        * <p>
-        * @param share Share instance
-        */
-       void setShare (final ShareableAddressbook share);
-
-       /**
-        * Getter for sharee's user id
-        * <p>
-        * @return Sharee's user id
-        */
-       Long getShareeUserId ();
-
-       /**
-        * Setter for sharee's user id
-        * <p>
-        * @param shareeUserId Sharee's user id
-        */
-       void setShareeUserId (final Long shareeUserId);
-
-       /**
-        * Checks if the sharee's user id is empty.
-        * <p>
-        * @return Whether the sharee's user id is empty.
-        */
-       boolean isShareeUserIdEmpty ();
-
-       /**
-        * Checks whether the sharee's user id is set
-        * <p>
-        * @return Whether the sharee's user id is set
-        */
-       boolean isShareeUserIdSet ();
-
-       /**
-        * Checks wether the current user is sharing address books with others
-        * <p>
-        * @return Whether the current user is sharing address books
-        */
-       boolean isSharingAddressbooks ();
-
-       /**
-        * Starts an address book share between currently logged-in user and
-        * assigned user for current address book.
-        * <p>
-        * @param user User instance
-        * @param addressbook Address book instance
-        * <p>
-        * @return Redirect target
-        */
-       String startSharing (final User user, final Addressbook addressbook);
-}
index 78db21b3133f2366121ffcc6af449c4723424abf..ab8caeef27629f30a907fdf6b025e85f5632f923 100644 (file)
@@ -26,8 +26,8 @@ import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote;
-import org.mxchange.jaddressbookcore.exceptions.AddressbookNotFoundException;
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
+import org.mxchange.jaddressbook.exceptions.AddressbookNotFoundException;
+import org.mxchange.jaddressbook.model.addressbook.Addressbook;
 import org.mxchange.jcoreee.validator.number.BaseLongValidator;
 import org.mxchange.jcoreeelogger.beans.local.logger.Log;
 import org.mxchange.jcoreeelogger.beans.local.logger.LoggerBeanLocal;
index 0ebf6524806fe2bf6d2fed5ed731135d9dd3efbb..68315390bd2f50a936623773563a4d95c56a7b5e 100644 (file)
@@ -14,7 +14,7 @@
                </f:viewParam>
        </f:metadata>
 
-       <ui:composition template="/WEB-INF/templates/#{userLoginController.templateType}/#{userLoginController.templateType}_base.tpl">
+       <ui:composition template="/WEB-INF/templates/#{userLoginController.baseTemplatePathName}/#{userLoginController.baseTemplatePathName}_base.tpl">
                <ui:define name="login_title">
                        <h:outputText value="#{msg.PAGE_TITLE_USER_SHOW_ADDRESSBOOK}" />
                </ui:define>
index 6eb82de650afa1920e0d698489d949cd066fbf3f..16d25385da4daf92d1fd7f47688918099f63c6ed 100644 (file)
@@ -5,10 +5,9 @@
        xmlns="http://www.w3.org/1999/xhtml"
          xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
          xmlns:h="http://xmlns.jcp.org/jsf/html"
-         xmlns:f="http://xmlns.jcp.org/jsf/core"
-         xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
+         xmlns:f="http://xmlns.jcp.org/jsf/core">
 
-       <ui:composition template="/WEB-INF/templates/#{userLoginController.templateType}/#{userLoginController.templateType}_base.tpl">
+       <ui:composition template="/WEB-INF/templates/#{userLoginController.baseTemplatePathName}/#{userLoginController.baseTemplatePathName}_base.tpl">
                <ui:define name="login_title">
                        <h:outputText value="#{msg.PAGE_TITLE_LOGIN_START_SHARING_ADDRESSBOOK}" />
                </ui:define>
@@ -28,7 +27,7 @@
                                        <div class="para">
                                                <h:outputText id="userNotLoggedIn" class="notice" value="#{msg.USER_NOT_LOGGED_IN}" rendered="#{not userLoginController.isUserLoggedIn()}" />
 
-                                               <h:dataTable id="userList" headerClass="table_header_column" var="user" value="#{addressbookController.allUsersNotSharing()}" rendered="#{userLoginController.isUserLoggedIn() and not empty addressbookController.addressbook and not userLoginController.isInvisible()}">
+                                               <h:dataTable id="userList" headerClass="table_header_column" var="user" value="#{addressbookShareController.allUsersNotSharing()}" rendered="#{userLoginController.isUserLoggedIn() and not empty addressbookController.addressbook and not userLoginController.isInvisible()}">
 
                                                        <h:column>
                                                                <f:facet name="header">