]> git.mxchange.org Git - jjobs-ejb.git/commitdiff
removed address book sharing
authorRoland Haeder <roland@mxchange.org>
Wed, 2 Mar 2016 20:26:53 +0000 (21:26 +0100)
committerRoland Haeder <roland@mxchange.org>
Wed, 2 Mar 2016 20:26:53 +0000 (21:26 +0100)
src/conf/persistence.xml
src/java/org/mxchange/addressbook/model/shared/SharedAddressbooksSessionBean.java [deleted file]

index e638db370448063b4b4775874cc90405452d0058..6f45f220dd068e8f48684065ffccde50165830e2 100644 (file)
     <class>org.mxchange.jcontactsbusiness.jobposition.EmployeePosition</class>
     <class>org.mxchange.jcontactsbusiness.logo.CompanyLogo</class>
     <class>org.mxchange.jcountry.data.CountryData</class>
+    <class>org.mxchange.jjobs.model.addressbook.UserAddressbook</class>
+    <class>org.mxchange.jjobs.model.addressbook.entry.UserAddressbookEntry</class>
+    <class>org.mxchange.jjobs.model.addressbook.shared.AddressbookShare</class>
     <class>org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber</class>
     <class>org.mxchange.jphone.phonenumbers.fax.FaxNumber</class>
     <class>org.mxchange.jphone.phonenumbers.landline.LandLineNumber</class>
     <class>org.mxchange.jphone.phonenumbers.smsprovider.CellphoneProvider</class>
+    <class>org.mxchange.jusercore.model.user.LoginUser</class>
     <exclude-unlisted-classes>false</exclude-unlisted-classes>
     <properties>
       <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
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 31b1010..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (C) 2016 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU 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.jcoreee.database.BaseDatabaseBean;
-import org.mxchange.jjobs.exceptions.UserAlreadySharingAddressbookException;
-import org.mxchange.jjobs.model.addressbook.Addressbook;
-import org.mxchange.jjobs.model.addressbook.shared.AddressbookShare;
-import org.mxchange.jjobs.model.addressbook.shared.ShareableAddressbook;
-import org.mxchange.jjobs.model.shared.SharedAddressbooksSessionBeanRemote;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * A stateless bean for handling address book sharing
- * <p>
- * @author Roland Haeder
- */
-@Stateless (name = "share", mappedName = "ejb/stateless-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;
-       }
-}