]> git.mxchange.org Git - addressbook-mailer-ejb.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>
nbproject/build-impl.xml
nbproject/genfiles.properties
nbproject/project.properties
nbproject/project.xml
src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java
src/java/org/mxchange/addressbook/model/addressbook/share/SharedAddressbooksSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/addressbook/model/shared/SharedAddressbooksSessionBean.java [deleted file]

index 376c8cc2665c3713a830639dc7f4778294045f8d..631e677e2e41cfba4bbc8e856c06977ea63d7870 100644 (file)
@@ -857,6 +857,8 @@ exists or setup the property manually. For example like this:
         <copyfiles files="${file.reference.juser-lib.jar}" todir="${build.classes.dir}"/>
         <copyfiles files="${file.reference.jaddressbook-core.jar}" todir="${build.classes.dir}"/>
         <copyfiles files="${file.reference.jaddressbook-lib.jar}" todir="${build.classes.dir}"/>
+        <copyfiles files="${file.reference.jaddressbook-share-core.jar}" todir="${build.classes.dir}"/>
+        <copyfiles files="${file.reference.jaddressbook-share-lib.jar}" todir="${build.classes.dir}"/>
         <copyfiles files="${file.reference.jmailer-ee.jar}" todir="${build.classes.dir}"/>
         <copyfiles files="${reference.addressbook-core.jar}" todir="${build.classes.dir}"/>
         <copyfiles files="${reference.addressbook-lib.jar}" todir="${build.classes.dir}"/>
@@ -877,13 +879,15 @@ exists or setup the property manually. For example like this:
         <basename file="${file.reference.juser-lib.jar}" property="manifest.file.reference.juser-lib.jar"/>
         <basename file="${file.reference.jaddressbook-core.jar}" property="manifest.file.reference.jaddressbook-core.jar"/>
         <basename file="${file.reference.jaddressbook-lib.jar}" property="manifest.file.reference.jaddressbook-lib.jar"/>
+        <basename file="${file.reference.jaddressbook-share-core.jar}" property="manifest.file.reference.jaddressbook-share-core.jar"/>
+        <basename file="${file.reference.jaddressbook-share-lib.jar}" property="manifest.file.reference.jaddressbook-share-lib.jar"/>
         <basename file="${file.reference.jmailer-ee.jar}" property="manifest.file.reference.jmailer-ee.jar"/>
         <basename file="${reference.addressbook-core.jar}" property="manifest.reference.addressbook-core.jar"/>
         <basename file="${reference.addressbook-lib.jar}" property="manifest.reference.addressbook-lib.jar"/>
         <basename file="${reference.addressbook-mailer.jar}" property="manifest.reference.addressbook-mailer.jar"/>
         <basename file="${file.reference.cdi-api.jar}" property="manifest.file.reference.cdi-api.jar"/>
         <manifest file="${build.ear.classes.dir}/META-INF/MANIFEST.MF" mode="update">
-            <attribute name="Extension-List" value="jar-1 jar-2 jar-3 jar-4 jar-5 jar-6 jar-7 jar-8 jar-9 jar-10 jar-11 jar-12 jar-13 jar-14 jar-15 jar-16 jar-17 jar-18 "/>
+            <attribute name="Extension-List" value="jar-1 jar-2 jar-3 jar-4 jar-5 jar-6 jar-7 jar-8 jar-9 jar-10 jar-11 jar-12 jar-13 jar-14 jar-15 jar-16 jar-17 jar-18 jar-19 jar-20 "/>
             <attribute name="jar-1-Extension-Name" value="${manifest.file.reference.jcoreee.jar}"/>
             <attribute name="jar-2-Extension-Name" value="${manifest.file.reference.jcore-logger-lib.jar}"/>
             <attribute name="jar-3-Extension-Name" value="${manifest.file.reference.jcountry-core.jar}"/>
@@ -897,11 +901,13 @@ exists or setup the property manually. For example like this:
             <attribute name="jar-11-Extension-Name" value="${manifest.file.reference.juser-lib.jar}"/>
             <attribute name="jar-12-Extension-Name" value="${manifest.file.reference.jaddressbook-core.jar}"/>
             <attribute name="jar-13-Extension-Name" value="${manifest.file.reference.jaddressbook-lib.jar}"/>
-            <attribute name="jar-14-Extension-Name" value="${manifest.file.reference.jmailer-ee.jar}"/>
-            <attribute name="jar-15-Extension-Name" value="${manifest.reference.addressbook-core.jar}"/>
-            <attribute name="jar-16-Extension-Name" value="${manifest.reference.addressbook-lib.jar}"/>
-            <attribute name="jar-17-Extension-Name" value="${manifest.reference.addressbook-mailer.jar}"/>
-            <attribute name="jar-18-Extension-Name" value="${manifest.file.reference.cdi-api.jar}"/>
+            <attribute name="jar-14-Extension-Name" value="${manifest.file.reference.jaddressbook-share-core.jar}"/>
+            <attribute name="jar-15-Extension-Name" value="${manifest.file.reference.jaddressbook-share-lib.jar}"/>
+            <attribute name="jar-16-Extension-Name" value="${manifest.file.reference.jmailer-ee.jar}"/>
+            <attribute name="jar-17-Extension-Name" value="${manifest.reference.addressbook-core.jar}"/>
+            <attribute name="jar-18-Extension-Name" value="${manifest.reference.addressbook-lib.jar}"/>
+            <attribute name="jar-19-Extension-Name" value="${manifest.reference.addressbook-mailer.jar}"/>
+            <attribute name="jar-20-Extension-Name" value="${manifest.file.reference.cdi-api.jar}"/>
         </manifest>
     </target>
     <target depends="compile" name="library-inclusion-in-manifest">
@@ -918,6 +924,8 @@ exists or setup the property manually. For example like this:
         <copyfiles files="${file.reference.juser-lib.jar}" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jaddressbook-core.jar}" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jaddressbook-lib.jar}" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${file.reference.jaddressbook-share-core.jar}" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${file.reference.jaddressbook-share-lib.jar}" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.jmailer-ee.jar}" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${reference.addressbook-core.jar}" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${reference.addressbook-lib.jar}" todir="${dist.ear.dir}/lib"/>
index db5f447b7d6d95957be9db0cf0ea7ff61dd023c4..9cafdc373ae98576dabb58213062f3c8ed9b24d0 100644 (file)
@@ -3,6 +3,6 @@ build.xml.script.CRC32=7d41e0fd
 build.xml.stylesheet.CRC32=5910fda3@1.51.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=85adc17b
-nbproject/build-impl.xml.script.CRC32=2401f53a
+nbproject/build-impl.xml.data.CRC32=8d819964
+nbproject/build-impl.xml.script.CRC32=a108c83f
 nbproject/build-impl.xml.stylesheet.CRC32=6096d939@1.55.1
index f8742343b4b5cb347960ac2f7a0646f11c0e86fc..45072a3011c6df164832c7e27c1df630037c961f 100644 (file)
@@ -25,6 +25,8 @@ file.reference.addressbook-mailer.jar=lib/addressbook-mailer.jar
 file.reference.cdi-api.jar=lib/cdi-api.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
@@ -65,6 +67,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}:\
     ${file.reference.jmailer-ee.jar}:\
     ${reference.addressbook-core.jar}:\
     ${reference.addressbook-lib.jar}:\
@@ -116,6 +120,8 @@ source.encoding=UTF-8
 source.reference.addressbook-mailer.jar=../addressbook-mailer/src/
 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 8818717f357a3830ac88e7c00968586eac517b4d..33d7dcf1df49fa157112217e8b57552cdd341267 100644 (file)
@@ -18,6 +18,8 @@
             <included-library dirs="200">file.reference.juser-lib.jar</included-library>
             <included-library dirs="200">file.reference.jaddressbook-core.jar</included-library>
             <included-library dirs="200">file.reference.jaddressbook-lib.jar</included-library>
+            <included-library dirs="200">file.reference.jaddressbook-share-core.jar</included-library>
+            <included-library dirs="200">file.reference.jaddressbook-share-lib.jar</included-library>
             <included-library dirs="200">file.reference.jmailer-ee.jar</included-library>
             <included-library dirs="200">reference.addressbook-core.jar</included-library>
             <included-library dirs="200">reference.addressbook-lib.jar</included-library>
index f1c6b984c5d0f98d1c923269b52cee0229161258..c4c6ebce6743a98ff49d307b6cd897b675c6a381 100644 (file)
 package org.mxchange.addressbook.model.addressbook;
 
 import java.text.MessageFormat;
-import java.util.ArrayList;
 import java.util.GregorianCalendar;
-import java.util.LinkedList;
 import java.util.List;
 import javax.ejb.Stateless;
 import javax.persistence.NoResultException;
 import javax.persistence.Query;
-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.jaddressbookcore.model.addressbook.shared.ShareableAddressbook;
+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.jcoreee.database.BaseDatabaseBean;
 import org.mxchange.jusercore.model.user.User;
 
@@ -84,143 +81,6 @@ public class AddressbookSessionBean extends BaseDatabaseBean implements Addressb
                return query.getResultList();
        }
 
-       @Override
-       @SuppressWarnings ("unchecked")
-       public List<User> allUsersNotSharing (final User user, final Addressbook addressbook) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("allUsersNotSharing: user={0},addressbook={1} - CALLED!", user, addressbook)); //NOI18N
-
-               // Test parameter
-               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
-                       throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
-               } else if (null == addressbook) {
-                       // Again NPE
-                       throw new NullPointerException("addressbook is null"); //NOI18N
-               } else if (addressbook.getAddressbookId() == null) {
-                       // Again NPE
-                       throw new NullPointerException("addressbook.addressbookId is null"); //NOI18N
-               } else if (addressbook.getAddressbookId() < 1) {
-                       // Invalid id
-                       throw new IllegalArgumentException(MessageFormat.format("addressbook.getAddressbookId={0} is invalid", addressbook.getAddressbookId())); //NOI18N
-               }
-
-               // Get named query for a user list without given user
-               Query allUsersExceptQuery = this.getEntityManager().createNamedQuery("SearchAllUsersExcept", List.class); //NOI18N
-
-               // Set parameter
-               allUsersExceptQuery.setParameter("user", user); //NOI18N
-
-               // Get full list
-               List<User> allUsersExcept = allUsersExceptQuery.getResultList();
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: allUsersExcept.size()={0}", allUsersExcept.size())); //NOI18N
-
-               // Now get all shares this user has created
-               Query allSharesQuery = this.getEntityManager().createNamedQuery("SearchUserSharedAddressbooks", List.class); //NOI18N
-
-               // Set parameter
-               allSharesQuery.setParameter("user", user); //NOI18N
-
-               // Get full list again
-               List<ShareableAddressbook> allShares = allSharesQuery.getResultList();
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: allShares.size()={0}", allShares.size())); //NOI18N
-
-               // List for users aharing with given
-               List<User> sharingUsers = new ArrayList<>(allShares.size());
-
-               // Check all entries
-               for (final ShareableAddressbook share : allShares) {
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: share.shareUserSharee={0}", share.getShareUserSharee())); //NOI18N
-
-                       // Add it
-                       sharingUsers.add(share.getShareUserSharee());
-               }
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: sharingUsers.size()={0}", sharingUsers.size())); //NOI18N
-
-               // Init final user list
-               List<User> userList = new LinkedList<>();
-
-               // Walk through all users
-               for (final User foundUser : allUsersExcept) {
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: foundUser={0}", foundUser)); //NOI18N
-
-                       // Does the list contain it ?
-                       if (!sharingUsers.contains(foundUser)) {
-                               // Found one to add
-                               this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: foundUser={0} - ADDING!", foundUser)); //NOI18N
-
-                               // Add it
-                               userList.add(foundUser);
-                       }
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("allUsersNotSharing: userList.size()={0} - EXIT!", userList.size())); //NOI18N
-
-               // Return it
-               return userList;
-       }
-
-       @Override
-       @SuppressWarnings ("unchecked")
-       public Integer countAllUserSharedAddressbooks (final User user) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("countAllUserSharedAddressbooks: user={0} - CALLED!", user)); //NOI18N
-
-               // user should be valid
-               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
-                       throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
-               }
-
-               // Get named query
-               Query query = this.getEntityManager().createNamedQuery("SearchUserSharedAddressbooks", List.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("user", user); //NOI18N
-
-               // Default is zero
-               Integer count = 0;
-
-               // Try it
-               try {
-                       // Get whole list
-                       List<ShareableAddressbook> dummy = query.getResultList();
-
-                       // Set size
-                       count = dummy.size();
-               } catch (final NoResultException ex) {
-                       // Need to catch this, so log it
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("countAllUserSharedAddressbooks: getResultList() failed: {0}", ex)); //NOI18N
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("countAllUserSharedAddressbooks: count={0} - EXIT!", count)); //NOI18N
-
-               // Return count
-               return count;
-       }
-
        @Override
        public Addressbook createAddressbook (final Addressbook addressbook) throws AddressbookNameAlreadyUsedException {
                // Is it not null?
diff --git a/src/java/org/mxchange/addressbook/model/addressbook/share/SharedAddressbooksSessionBean.java b/src/java/org/mxchange/addressbook/model/addressbook/share/SharedAddressbooksSessionBean.java
new file mode 100644 (file)
index 0000000..901ca67
--- /dev/null
@@ -0,0 +1,347 @@
+/*
+ * 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.model.addressbook.share;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+import javax.ejb.Stateless;
+import javax.persistence.NoResultException;
+import javax.persistence.Query;
+import org.mxchange.addressbook.model.shared.AddressbookShareSessionBeanRemote;
+import org.mxchange.jaddressbook.model.addressbook.Addressbook;
+import org.mxchange.jaddressbookshare.exceptions.UserAlreadySharingAddressbookException;
+import org.mxchange.jaddressbookshare.model.addressbook.shared.AddressbookShare;
+import org.mxchange.jaddressbookshare.model.addressbook.shared.ShareableAddressbook;
+import org.mxchange.jcoreee.database.BaseDatabaseBean;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * A stateless bean for handling address book sharing
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+@Stateless (name = "share", description = "A stateless bean for handling shared addressbooks")
+public class SharedAddressbooksSessionBean extends BaseDatabaseBean implements AddressbookShareSessionBeanRemote {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 136_984_697_285_694_710L;
+
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<ShareableAddressbook> allSharedAddressbooks (final User user) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("allSharedAddressbooks: user={0} - CALLED!", user)); //NOI18N
+
+               // Is user null?
+               if (null == user) {
+                       // Throw NPE
+                       throw new NullPointerException("user is null"); //NOI18N
+               } else if (user.getUserId() == null) {
+                       // Null userId is not allowed
+                       throw new NullPointerException("user.userId is null"); //NOI18N
+               } else if (user.getUserId() < 1) {
+                       // Not allowed value
+                       throw new IllegalArgumentException(MessageFormat.format("user.UserId={0} is an invalid value", user.getUserId())); //NOI18N
+               }
+
+               // Get named query
+               Query query = this.getEntityManager().createNamedQuery("SearchUserSharedAddressbooks", List.class); //NOI18N
+
+               // Set parameter
+               query.setParameter("user", user); //NOI18N
+
+               // Return full list
+               List<ShareableAddressbook> list = query.getResultList();
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("allSharedAddressbooks: list.size()={0} - EXIT!", list.size()));
+
+               // Return list
+               return list;
+       }
+
+       @Override
+       @SuppressWarnings ("unchecked")
+       public List<User> allUsersNotSharing (final User user, final Addressbook addressbook) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("allUsersNotSharing: user={0},addressbook={1} - CALLED!", user, addressbook)); //NOI18N
+
+               // Test parameter
+               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
+                       throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
+               } else if (null == addressbook) {
+                       // Again NPE
+                       throw new NullPointerException("addressbook is null"); //NOI18N
+               } else if (addressbook.getAddressbookId() == null) {
+                       // Again NPE
+                       throw new NullPointerException("addressbook.addressbookId is null"); //NOI18N
+               } else if (addressbook.getAddressbookId() < 1) {
+                       // Invalid id
+                       throw new IllegalArgumentException(MessageFormat.format("addressbook.getAddressbookId={0} is invalid", addressbook.getAddressbookId())); //NOI18N
+               }
+
+               // Get named query for a user list without given user
+               Query allUsersExceptQuery = this.getEntityManager().createNamedQuery("SearchAllUsersExcept", List.class); //NOI18N
+
+               // Set parameter
+               allUsersExceptQuery.setParameter("user", user); //NOI18N
+
+               // Get full list
+               List<User> allUsersExcept = allUsersExceptQuery.getResultList();
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: allUsersExcept.size()={0}", allUsersExcept.size())); //NOI18N
+
+               // Now get all shares this user has created
+               Query allSharesQuery = this.getEntityManager().createNamedQuery("SearchUserSharedAddressbooks", List.class); //NOI18N
+
+               // Set parameter
+               allSharesQuery.setParameter("user", user); //NOI18N
+
+               // Get full list again
+               List<ShareableAddressbook> allShares = allSharesQuery.getResultList();
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: allShares.size()={0}", allShares.size())); //NOI18N
+
+               // List for users aharing with given
+               List<User> sharingUsers = new ArrayList<>(allShares.size());
+
+               // Check all entries
+               for (final ShareableAddressbook share : allShares) {
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: share.shareUserSharee={0}", share.getShareUserSharee())); //NOI18N
+
+                       // Add it
+                       sharingUsers.add(share.getShareUserSharee());
+               }
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: sharingUsers.size()={0}", sharingUsers.size())); //NOI18N
+
+               // Init final user list
+               List<User> userList = new LinkedList<>();
+
+               // Walk through all users
+               for (final User foundUser : allUsersExcept) {
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: foundUser={0}", foundUser)); //NOI18N
+
+                       // Does the list contain it ?
+                       if (!sharingUsers.contains(foundUser)) {
+                               // Found one to add
+                               this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: foundUser={0} - ADDING!", foundUser)); //NOI18N
+
+                               // Add it
+                               userList.add(foundUser);
+                       }
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("allUsersNotSharing: userList.size()={0} - EXIT!", userList.size())); //NOI18N
+
+               // Return it
+               return userList;
+       }
+
+       @Override
+       @SuppressWarnings ("unchecked")
+       public Integer countAllUserSharedAddressbooks (final User user) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("countAllUserSharedAddressbooks: user={0} - CALLED!", user)); //NOI18N
+
+               // user should be valid
+               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
+                       throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N
+               }
+
+               // Get named query
+               Query query = this.getEntityManager().createNamedQuery("SearchUserSharedAddressbooks", List.class); //NOI18N
+
+               // Set parameter
+               query.setParameter("user", user); //NOI18N
+
+               // Default is zero
+               Integer count = 0;
+
+               // Try it
+               try {
+                       // Get whole list
+                       List<ShareableAddressbook> dummy = query.getResultList();
+
+                       // Set size
+                       count = dummy.size();
+               } catch (final NoResultException ex) {
+                       // Need to catch this, so log it
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("countAllUserSharedAddressbooks: getResultList() failed: {0}", ex)); //NOI18N
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("countAllUserSharedAddressbooks: count={0} - EXIT!", count)); //NOI18N
+
+               // Return count
+               return count;
+       }
+
+       @Override
+       public Boolean isUserSharingAddressbooks (final User user) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("isUserSharingAddressbooks: user={0} - CALLED!", user)); //NOI18N
+
+               // Is user null?
+               if (null == user) {
+                       // Throw NPE
+                       throw new NullPointerException("user is null"); //NOI18N
+               } else if (user.getUserId() == null) {
+                       // Null userId is not allowed
+                       throw new NullPointerException("user.userId is null"); //NOI18N
+               } else if (user.getUserId() < 1) {
+                       // Not allowed value
+                       throw new IllegalArgumentException(MessageFormat.format("user.UserId={0} is an invalid value", user.getUserId())); //NOI18N
+               }
+
+               // Get results
+               List<ShareableAddressbook> list = this.allSharedAddressbooks(user);
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("isUserSharingAddressbooks: list.size()={0}", list.size())); //NOI18N
+
+               // Is it not empty?
+               Boolean isSharing = (!list.isEmpty());
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("isUserSharingAddressbooks: iSharing={0} - EXIT!", isSharing)); //NOI18N
+
+               // Return it
+               return isSharing;
+       }
+
+       @Override
+       public ShareableAddressbook startSharing (final User sharee, final Addressbook addressbook) throws UserAlreadySharingAddressbookException {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("startSharing: sharee={0},addressbook={1} - CALLED!", sharee, addressbook)); //NOI18N
+
+               // Check all conditions
+               if (null == sharee) {
+                       // Throw NPE
+                       throw new NullPointerException("sharee is null"); //NOI18N
+               } else if (sharee.getUserId() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("sharee.userId is null"); //NOI18N
+               } else if (sharee.getUserId() < 1) {
+                       // Invalid id number
+                       throw new IllegalStateException(MessageFormat.format("sharee.userId={0} is invalid", sharee.getUserId())); //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(), sharee)) {
+                       // Sharing with yourself!
+                       throw new IllegalStateException("User tries to share with himself."); //NOI18N
+               }
+
+               // Is the entry already there?
+               if (this.isUserAlreadySharingAddressbook(addressbook, sharee)) {
+                       // Abort here
+                       throw new UserAlreadySharingAddressbookException(addressbook, sharee);
+               }
+
+               // All fine so far, then create the instance
+               ShareableAddressbook share = new AddressbookShare(addressbook, sharee);
+
+               // Debug message
+               this.getLoggerBeanLocal().logDebug(MessageFormat.format("startSharing: share={0}", share)); //NOI18N
+
+               // Persist it
+               this.getEntityManager().persist(share);
+
+               // Flush to get id number
+               this.getEntityManager().flush();
+
+               // Return updated instance
+               return share;
+       }
+
+       /**
+        * Checks whether the owner of the given address book is already sharing it
+        * with the sharee.
+        * <p>
+        * @param addressbook Address book to be shared with
+        * @param sharee      User sharee instance
+        * <p>
+        * @return Wether the address book is already shared with the sharee
+        */
+       private boolean isUserAlreadySharingAddressbook (final Addressbook addressbook, final User sharee) {
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("isUserAlreadySharingAddressbook: addressbook={0},sharee={1} - CALLED!", addressbook, sharee)); //NOI18N
+
+               // Get named query
+               Query query = this.getEntityManager().createNamedQuery("SearchShareeAddressbookShare", AddressbookShare.class); //NOI18N
+
+               // Set parameter
+               query.setParameter("addressbook", addressbook); //NOI18N
+               query.setParameter("sharee", sharee); //NOI18N
+
+               // Default is not found
+               boolean isFound = false;
+
+               // Try it
+               try {
+                       // Get single instance
+                       ShareableAddressbook share = (ShareableAddressbook) query.getSingleResult();
+
+                       // Debug message
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("isUserAlreadySharingAddressbook: share={0} - FOUND!", share)); //NOI18N
+
+                       // Set found
+                       isFound = true;
+               } catch (final NoResultException ex) {
+                       // Not found, log exception
+                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("isUserAlreadySharingAddressbook: Notfound. Exception: {0}", ex)); //NOI18N
+               }
+
+               // Trace message
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("isUserAlreadySharingAddressbook: isFound={0} - EXIT!", isFound)); //NOI18N
+
+               // Return it
+               return isFound;
+       }
+}
diff --git a/src/java/org/mxchange/addressbook/model/shared/SharedAddressbooksSessionBean.java b/src/java/org/mxchange/addressbook/model/shared/SharedAddressbooksSessionBean.java
deleted file mode 100644 (file)
index 8ff75bc..0000000
+++ /dev/null
@@ -1,207 +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.model.shared;
-
-import java.text.MessageFormat;
-import java.util.List;
-import java.util.Objects;
-import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
-import javax.persistence.Query;
-import org.mxchange.jaddressbookcore.exceptions.UserAlreadySharingAddressbookException;
-import org.mxchange.jaddressbookcore.model.addressbook.Addressbook;
-import org.mxchange.jaddressbookcore.model.addressbook.shared.AddressbookShare;
-import org.mxchange.jaddressbookcore.model.addressbook.shared.ShareableAddressbook;
-import org.mxchange.jcoreee.database.BaseDatabaseBean;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * A stateless bean for handling address book sharing
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "share", description = "A stateless bean for handling shared addressbooks")
-public class SharedAddressbooksSessionBean extends BaseDatabaseBean implements SharedAddressbooksSessionBeanRemote {
-
-       /**
-        * Serial number
-        */
-       private static final long serialVersionUID = 136_984_697_285_694_710L;
-
-       @Override
-       @SuppressWarnings ("unchecked")
-       public List<ShareableAddressbook> allSharedAddressbooks (final User user) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("allSharedAddressbooks: user={0} - CALLED!", user)); //NOI18N
-
-               // Is user null?
-               if (null == user) {
-                       // Throw NPE
-                       throw new NullPointerException("user is null"); //NOI18N
-               } else if (user.getUserId() == null) {
-                       // Null userId is not allowed
-                       throw new NullPointerException("user.userId is null"); //NOI18N
-               } else if (user.getUserId() < 1) {
-                       // Not allowed value
-                       throw new IllegalArgumentException(MessageFormat.format("user.UserId={0} is an invalid value", user.getUserId())); //NOI18N
-               }
-
-               // Get named query
-               Query query = this.getEntityManager().createNamedQuery("SearchUserSharedAddressbooks", List.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("user", user); //NOI18N
-
-               // Return full list
-               List<ShareableAddressbook> list = query.getResultList();
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("allSharedAddressbooks: list.size()={0} - EXIT!", list.size()));
-
-               // Return list
-               return list;
-       }
-
-       @Override
-       public Boolean isUserSharingAddressbooks (final User user) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("isUserSharingAddressbooks: user={0} - CALLED!", user)); //NOI18N
-
-               // Is user null?
-               if (null == user) {
-                       // Throw NPE
-                       throw new NullPointerException("user is null"); //NOI18N
-               } else if (user.getUserId() == null) {
-                       // Null userId is not allowed
-                       throw new NullPointerException("user.userId is null"); //NOI18N
-               } else if (user.getUserId() < 1) {
-                       // Not allowed value
-                       throw new IllegalArgumentException(MessageFormat.format("user.UserId={0} is an invalid value", user.getUserId())); //NOI18N
-               }
-
-               // Get results
-               List<ShareableAddressbook> list = this.allSharedAddressbooks(user);
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("isUserSharingAddressbooks: list.size()={0}", list.size())); //NOI18N
-
-               // Is it not empty?
-               Boolean isSharing = (!list.isEmpty());
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("isUserSharingAddressbooks: iSharing={0} - EXIT!", isSharing)); //NOI18N
-
-               // Return it
-               return isSharing;
-       }
-
-       @Override
-       public ShareableAddressbook startSharing (final User sharee, final Addressbook addressbook) throws UserAlreadySharingAddressbookException {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("startSharing: sharee={0},addressbook={1} - CALLED!", sharee, addressbook)); //NOI18N
-
-               // Check all conditions
-               if (null == sharee) {
-                       // Throw NPE
-                       throw new NullPointerException("sharee is null"); //NOI18N
-               } else if (sharee.getUserId() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("sharee.userId is null"); //NOI18N
-               } else if (sharee.getUserId() < 1) {
-                       // Invalid id number
-                       throw new IllegalStateException(MessageFormat.format("sharee.userId={0} is invalid", sharee.getUserId())); //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(), sharee)) {
-                       // Sharing with yourself!
-                       throw new IllegalStateException("User tries to share with himself."); //NOI18N
-               }
-
-               // Is the entry already there?
-               if (this.isUserAlreadySharingAddressbook(addressbook, sharee)) {
-                       // Abort here
-                       throw new UserAlreadySharingAddressbookException(addressbook, sharee);
-               }
-
-               // All fine so far, then create the instance
-               ShareableAddressbook share = new AddressbookShare(addressbook, sharee);
-
-               // Debug message
-               this.getLoggerBeanLocal().logDebug(MessageFormat.format("startSharing: share={0}", share)); //NOI18N
-
-               // Persist it
-               this.getEntityManager().persist(share);
-
-               // Flush to get id number
-               this.getEntityManager().flush();
-
-               // Return updated instance
-               return share;
-       }
-
-       /**
-        * Checks whether the owner of the given address book is already sharing it
-        * with the sharee.
-        * <p>
-        * @param addressbook Address book to be shared with
-        * @param sharee User sharee instance
-        * <p>
-        * @return Wether the address book is already shared with the sharee
-        */
-       private boolean isUserAlreadySharingAddressbook (final Addressbook addressbook, final User sharee) {
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("isUserAlreadySharingAddressbook: addressbook={0},sharee={1} - CALLED!", addressbook, sharee)); //NOI18N
-
-               // Get named query
-               Query query = this.getEntityManager().createNamedQuery("SearchShareeAddressbookShare", AddressbookShare.class); //NOI18N
-
-               // Set parameter
-               query.setParameter("addressbook", addressbook); //NOI18N
-               query.setParameter("sharee", sharee); //NOI18N
-
-               // Default is not found
-               boolean isFound = false;
-
-               // Try it
-               try {
-                       // Get single instance
-                       ShareableAddressbook share = (ShareableAddressbook) query.getSingleResult();
-
-                       // Debug message
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("isUserAlreadySharingAddressbook: share={0} - FOUND!", share)); //NOI18N
-
-                       // Set found
-                       isFound = true;
-               } catch (final NoResultException ex) {
-                       // Not found, log exception
-                       this.getLoggerBeanLocal().logDebug(MessageFormat.format("isUserAlreadySharingAddressbook: Notfound. Exception: {0}", ex)); //NOI18N
-               }
-
-               // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("isUserAlreadySharingAddressbook: isFound={0} - EXIT!", isFound)); //NOI18N
-
-               // Return it
-               return isFound;
-       }
-}