From 1aa78d4c18669aa7dbfba6871775cfa7c1aa0ce6 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Wed, 2 Mar 2016 20:42:29 +0100 Subject: [PATCH] added files from addressbook-ejb: - added a lot jars and classes which may need to be customized for jjobs - updated project files --- lib/jcore-logger-lib.jar | Bin 0 -> 2533 bytes lib/jcoreee.jar | Bin 0 -> 18591 bytes lib/juser-core.jar | Bin 0 -> 29575 bytes nbproject/build-impl.xml | 24 +- nbproject/genfiles.properties | 6 +- nbproject/project.properties | 9 + nbproject/project.xml | 3 + .../addressbook/AddressbookSessionBean.java | 402 ++++++++++++++++++ .../shared/SharedAddressbooksSessionBean.java | 208 +++++++++ .../data/AddressbookCountrySingletonBean.java | 49 +++ .../AddressbookSmsProviderSingletonBean.java | 49 +++ 11 files changed, 741 insertions(+), 9 deletions(-) create mode 100644 lib/jcore-logger-lib.jar create mode 100644 lib/jcoreee.jar create mode 100644 lib/juser-core.jar create mode 100644 src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java create mode 100644 src/java/org/mxchange/addressbook/model/shared/SharedAddressbooksSessionBean.java create mode 100644 src/java/org/mxchange/jcountry/data/AddressbookCountrySingletonBean.java create mode 100644 src/java/org/mxchange/jphone/phonenumbers/smsprovider/AddressbookSmsProviderSingletonBean.java diff --git a/lib/jcore-logger-lib.jar b/lib/jcore-logger-lib.jar new file mode 100644 index 0000000000000000000000000000000000000000..ea0ec333380d7fb3acda50778f3aca0ddd7e39ab GIT binary patch literal 2533 zcmbtV&2Af26h4zUaXiU13AhqaAzYA3OJz?Af&vwbX=!0_u2rt@)y(J5h+0$VQ$VdBfBJp^IQJs@6xy`*>a}X8TWQvs!gCJg zFeo2LHFSLM)6%WVj-gv#;=~#V`$(2>hL4|AJ~H%OB}E{=Dc?P1{Ku7@uW!F!cDz6; zPq^jY&WEMz`%2iZEbaPg;42Y8^$kNe^zRZ#r-xh9$lFIp&EWFRny+8l{OC#cb`@*^!e!pV7 zVmN&E{O4aF{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n;oPAEYy7S)2Wwi^+kDi*9w%W*2q2sGINg$eeK&lnDl> z&fLl=yXX7QW&ZT@_23pm{8a!W*xNj4C<$P~WdV$@R6BHMh;MXRhA!@zL?)Z#8jv!B zuSh1(>u(%!k$C0I=I}*r%Itev{7Vc}+c(+1PmiTH*a(c_zq;+Pe0ks`$>p)h#3Vjslu%|_vc_^X2+VUQg##=8Am zkCMzz+NksBLCLntj_A#0{o4sBg}-L{ag<;4KaZgQl0u=X)o&?q1^#>ai5@)Xs}}vT zLUH3PK@>Nh*ahf+-1tA@lJQlw8oXlqAJ_N^E=v$uwW|DE2>KsaZNog4R4x26Lg|Rj zO8m;PqyEPt@I5AL5&3U0SL+T_%>`LF$F-Jq)@018PD`gLORVA#YYXFa^Qsd0cMJ4C z9;yqvW;t7h?g@!yDK|xWSHAR|>sOF}Z*BR;33Rn7E$#C+>Xuo|;#HGh+UFnDmJb`Q z{}MxGmFhL8L9ARKQrl|GvmsMA_2s=S|7`|S_{&c`Qb}@NS=j*$F8QT~@)pX!D_dv* zUs$QtcWy$@k1Zof%3CS_Vojlyr}5?J8Z#s`k()Bo^=q_Mo=sP1>l5tvdfF<}`l{Jc z;^!~Qhg+VeQs}}a?Ccs{sFa$a!_)Gn%GvxvQ>OvA>uaibzgUsBmSZfZ)d~%t*jlq; qL+LFriuEYVF@B-32u@mRjIv~hF(_N2Kn+e7*n)p#H&7(X@BR;!Nol(P literal 0 HcmV?d00001 diff --git a/lib/juser-core.jar b/lib/juser-core.jar new file mode 100644 index 0000000000000000000000000000000000000000..40c22b79f6b40e7f73ff091d16431972e436bbce GIT binary patch literal 29575 zcmeHQ37A_~bv{qCJdH-P$z#uWylEUKo_)N;@fJHC&u9|avtv6D0lOGybkp+JEaD9{3>&G%7CKl+uV|GD>VdU{Wi z?IiF)=KCbw``*3hoV%Rmo^$V=iGvlD0U|%q$&)X;hHQT|R7s4Dzp*l_=|PZ3R+ zMH47GaOXX*Uqo^KG~;6y9UT~p4o9Y@`$mUHW2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=^1ikXM`!7s2P7OBgPafAu>zZ%aqt39+VSKA(9`T;+pTnoJKB`PA>Uc5 zcpQ$oN^wV9)!|U}SyCTANB(B2IdzU|&rxus`yADccJ-X2`mtVK|5fl!YWP4MLSa_H zwcY?<@CxY0Fz#;a!wpwk;WOU}cOjH7RI5NKT=j&vbx^|WwBL&Q8cW}p+;TX_<;3OAdh6$Ec=RYQF!v>aK;3%%tWqhMEe z6E>xDpt3_U~2gXDXHgl`o#9p1@c5ntMYW9WMM%OOcw z1P4NuUAT(l396JXP74<2Ng&%2H)Lcsazs3M?VKpj;C>u-pT z^6Y^!b(FZ8A#W?#1!^iULJBn1I-y_&1_#Gy#-?X+cwu^GYSzX(c5SuBt*pr!y2fgA zD9!&v;f{hJ;11pXT7KL+^M{7*Xa zpYB*y-Tv(kSKz<*zJ`6#W>woi;h8vSL2&*%61FhpA0z)PlB__B)qqD{|Kl3Z=rzoL z?oq5N-z+BoxM~~hBM)s|3`n~HLv+`;HxSE(Qw$s%7xIs3y1g85(ji+6C>u!@(5JnD z>NhqQgSEi`CEDBI^X#;|+nx4N&c@i z-tgERWx@NpH$1trwu5r}w>=i9VpL|zf|tK$F4Asx?8rYJ zpm&!AT-UHpnw|gV#{m4^*Zj~Mti?HQu?J}vptX91+T5_V;t-h|E>bwir zLiiZ;P-%qrGaIGuuyl5>^R`S2cPsu6Nom~Nt9p%m<9gsgXMsChwQf5!Ge77+HxV=wmvw=!Wo6Iz&BlA u4)}c4YjeC7i~=kA&pCWb7PkA2mV?b}wQCGY6?|0$S7AE^p{}%f&iy}V05qBa literal 0 HcmV?d00001 diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index 064428e..21fa2d2 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -826,32 +826,44 @@ exists or setup the property manually. For example like this: + + + + + + - - - - - - + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index 687679e..09b7572 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=8561312a +build.xml.data.CRC32=cd9fade4 build.xml.script.CRC32=9c0f08a9 build.xml.stylesheet.CRC32=5910fda3@1.55.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=8561312a -nbproject/build-impl.xml.script.CRC32=80436f3c +nbproject/build-impl.xml.data.CRC32=cd9fade4 +nbproject/build-impl.xml.script.CRC32=fe25a685 nbproject/build-impl.xml.stylesheet.CRC32=6096d939@1.55.1 diff --git a/nbproject/project.properties b/nbproject/project.properties index a52c6d6..921f78c 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -23,8 +23,11 @@ endorsed.classpath= excludes= file.reference.jcontacts-business-core.jar=lib/jcontacts-business-core.jar file.reference.jcontacts-core.jar=lib/jcontacts-core.jar +file.reference.jcore-logger-lib.jar=lib/jcore-logger-lib.jar +file.reference.jcoreee.jar=lib/jcoreee.jar file.reference.jcountry-core.jar=lib/jcountry-core.jar file.reference.jphone-core.jar=lib/jphone-core.jar +file.reference.juser-core.jar=lib/juser-core.jar includes=** j2ee.compile.on.save=true j2ee.deploy.on.save=true @@ -40,10 +43,13 @@ jar.compress=false jar.name=jjobs-ejb.jar jars.in.ejbjar=false javac.classpath=\ + ${file.reference.jcoreee.jar}:\ + ${file.reference.jcore-logger-lib.jar}:\ ${file.reference.jcontacts-core.jar}:\ ${file.reference.jcontacts-business-core.jar}:\ ${file.reference.jcountry-core.jar}:\ ${file.reference.jphone-core.jar}:\ + ${file.reference.juser-core.jar}:\ ${reference.jjobs-lib.jar} javac.compilerargs=-Xlint:unchecked -Xlint:deprecation javac.debug=true @@ -84,8 +90,11 @@ runmain.jvmargs= source.encoding=UTF-8 source.reference.jcontacts-business-core.jar=../jcontacts-business-core/src/ source.reference.jcontacts-core.jar=../jcontacts-core/src/ +source.reference.jcore-logger-lib.jar=../jcore-logger-lib/src/ +source.reference.jcoreee.jar=../jcoreee/src/ source.reference.jcountry-core.jar=../jcountry-core/src/ source.reference.jphone-core.jar=../jphone-core/src/ +source.reference.juser-core.jar=../juser-core/src/ source.root=src src.dir=${source.root}/java test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml index 08c49bc..54d7571 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -5,10 +5,13 @@ jjobs-ejb 1.6.5 + file.reference.jcoreee.jar + file.reference.jcore-logger-lib.jar file.reference.jcontacts-core.jar file.reference.jcontacts-business-core.jar file.reference.jcountry-core.jar file.reference.jphone-core.jar + file.reference.juser-core.jar reference.jjobs-lib.jar diff --git a/src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java b/src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java new file mode 100644 index 0000000..55aaafd --- /dev/null +++ b/src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java @@ -0,0 +1,402 @@ +/* + * 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 . + */ +package org.mxchange.addressbook.model.addressbook; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import javax.ejb.Stateless; +import javax.persistence.NoResultException; +import javax.persistence.Query; +import org.mxchange.jcoreee.database.BaseDatabaseBean; +import org.mxchange.jjobs.exceptions.AddressbookNameAlreadyUsedException; +import org.mxchange.jjobs.exceptions.AddressbookNotFoundException; +import org.mxchange.jjobs.model.addressbook.Addressbook; +import org.mxchange.jjobs.model.addressbook.AddressbookSessionBeanRemote; +import org.mxchange.jjobs.model.addressbook.UserAddressbook; +import org.mxchange.jjobs.model.addressbook.entry.AddressbookEntry; +import org.mxchange.jjobs.model.addressbook.shared.ShareableAddressbook; +import org.mxchange.jusercore.model.user.User; + +/** + * A stateless bean handling addressbooks + *

+ * @author Roland Haeder + */ +@Stateless (name = "addressbook", mappedName = "ejb/stateless-addressbook", description = "A stateless bean for handling addressbooks") +public class AddressbookSessionBean extends BaseDatabaseBean implements AddressbookSessionBeanRemote { + + /** + * Serial number + */ + private static final long serialVersionUID = 129_857_871_287_691L; + + @Override + @SuppressWarnings ("unchecked") + public List allEntries (final Addressbook addressbook) { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("allEntries: addressbook={0} - CALLED!", addressbook)); //NOI18N + + // Validate parameter + if (null == addressbook) { + // Throw NPE + throw new NullPointerException("addressbook is null"); + } else if (addressbook.getAddressbookId() == null) { + // Throw NPE again + throw new NullPointerException("addressbook.addressbookId is null"); + } else if (addressbook.getAddressbookId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookId={0} is invalid.", addressbook.getAddressbookId())); + } else if (addressbook.getAddressbookUser() == null) { + // Throw again NPE + throw new NullPointerException("addressbook.addressbookUser is null"); + } else if (addressbook.getAddressbookUser().getUserId() == null) { + // Throw again NPE + throw new NullPointerException("addressbook.addressbookUser.userId is null"); + } else if (addressbook.getAddressbookUser().getUserId() < 1) { + // Invalid id number again + throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookUser.userId={0} is invalid", addressbook.getAddressbookUser().getUserId())); + } + + // Generate query + Query query = this.getEntityManager().createNamedQuery("SearchUsersAddressbookEntries", List.class); //NOI18N + + // Set parameters + query.setParameter("addressbook", addressbook); //NOI18N + query.setParameter("owner", addressbook.getAddressbookUser()); //NOI18N + + // Return it + return query.getResultList(); + } + + @Override + @SuppressWarnings ("unchecked") + public List 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 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 allShares = allSharesQuery.getResultList(); + + // Debug message + this.getLoggerBeanLocal().logDebug(MessageFormat.format("allUsersNotSharing: allShares.size()={0}", allShares.size())); //NOI18N + + // List for users aharing with given + List 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 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 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? + if (null == addressbook) { + // Abort here + throw new NullPointerException("addressbook is null"); //NOI18N + } else if (addressbook.getAddressbookUser() == null) { + // User instance is null + throw new NullPointerException("addressbook.user should not be null."); //NOI18N + } else if (addressbook.getAddressbookName() == null) { + // Address book name not set + throw new NullPointerException("addressbook.addressbookName should not be null"); //NOI18N + } else if (addressbook.getAddressbookName().isEmpty()) { + // Address book name not set + throw new IllegalArgumentException("addressbook.addressbookName should not be empty"); //NOI18N + } else if (this.isAddressbookNameUsed(addressbook)) { + // The assigned user already used that name + throw new AddressbookNameAlreadyUsedException(addressbook); + } + + // Persist it now + this.getEntityManager().persist(addressbook); + + // Flush it to get all data + this.getEntityManager().flush(); + + // Return it updated + return addressbook; + } + + @Override + public Addressbook getAddressbookById (final Long addressbookId) throws AddressbookNotFoundException { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("getAddressbookById: addressbookId={0} - CALLED!", addressbookId)); //NOI18N + + // addressbookId should not be null or below 1 + if (null == addressbookId) { + // Throw NPE + throw new NullPointerException("addressbookId is null"); //NOI18N + } else if (addressbookId < 1) { + // Not valid + throw new IllegalArgumentException(MessageFormat.format("addressbookId is not valid: {0}", addressbookId)); //NOI18N + } else if (!this.isAddressbookIdUsed(addressbookId)) { + // No address book found + throw new AddressbookNotFoundException(addressbookId); + } + + // Get named query instance + Query query = this.getEntityManager().createNamedQuery("SearchAddressbookById", UserAddressbook.class); //NOI18N + + // Set parameter + query.setParameter("id", addressbookId); //NOI18N + + // Return it + return (Addressbook) query.getSingleResult(); + } + + @Override + @SuppressWarnings ("unchecked") + public List getUsersAddressbookList (final User loggedInUser) { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("getUsersList: loggedInUser={0} - CALLED!", loggedInUser)); //NOI18N + + // Is the user instance null? + if (null == loggedInUser) { + // Abort here + throw new NullPointerException("loggedInUser is null"); //NOI18N + } + + // Get query instance + Query query = this.getEntityManager().createNamedQuery("AllUsersAddressbooks", List.class); //NOI18N + + // Set parameter + query.setParameter("param", loggedInUser); //NOI18N + + // Get full list from JPA + List addressbooks = query.getResultList(); + + // Return it + return addressbooks; + } + + @Override + public boolean isAddressbookIdUsed (final Long addressbookId) { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("isAddressbookIdUsed: addressbookId={0} - CALLED!", addressbookId)); //NOI18N + + // Is it null or zero? + if (null == addressbookId) { + // Throw NPE + throw new NullPointerException("addressbookId is null"); //NOI18N + } else if (addressbookId < 1) { + // Not valid id number + throw new IllegalArgumentException(MessageFormat.format("addressbookId is not valid: {0}", addressbookId)); //NOI18N + } + + // Get query instance + Query query = this.getEntityManager().createNamedQuery("SearchAddressbookById", UserAddressbook.class); //NOI18N + + // Set parameter + query.setParameter("id", addressbookId); //NOI18N + + // Default is not valid + boolean isValid = false; + + // Try it again, yes no other way + try { + // Get single result + Addressbook addressbook = (Addressbook) query.getSingleResult(); + + // Debug message + this.getLoggerBeanLocal().logDebug(MessageFormat.format("isAddressbookIdUsed: addressbook={0} - FOUND!", addressbook)); //NOI18N + + // Found one! + isValid = true; + } catch (final NoResultException ex) { + // Debug log only, maybe out-dated link followed + this.getLoggerBeanLocal().logDebug(MessageFormat.format("isAddressbookIdUsed: addressbookId={0} is not valid: {1}", addressbookId, ex)); //NOI18N + } + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("isAddressbookIdUsed: isValid={0} - EXIT!", isValid)); //NOI18N + + // Return result + return isValid; + } + + @Override + public boolean isAddressbookNameUsed (final Addressbook addressbook) { + // Is it not null? + if (null == addressbook) { + // Abort here + throw new NullPointerException("addressbook is null"); //NOI18N + } else if (addressbook.getAddressbookUser() == null) { + // User instance is null + throw new NullPointerException("addressbook.addressbookUser is null."); //NOI18N + } else if (addressbook.getAddressbookUser().getUserId() == null) { + // User instance is null + throw new NullPointerException("addressbook.addressbookUser.userId is null."); //NOI18N + } else if (addressbook.getAddressbookUser().getUserId() < 1) { + // User instance is null + throw new NullPointerException(MessageFormat.format("addressbook.addressbookUser.userId={0} is invalid.", addressbook.getAddressbookUser().getUserId())); //NOI18N + } else if (addressbook.getAddressbookName() == null) { + // Address book name not set + throw new NullPointerException("addressbook.addressbookName should not be null"); //NOI18N + } else if (addressbook.getAddressbookName().isEmpty()) { + // Address book name not set + throw new IllegalArgumentException("addressbook.addressbookName should not be empty"); //NOI18N + } + + // Get query instance + Query query = this.getEntityManager().createNamedQuery("SearchUserAddressbookName", Addressbook.class); //NOI18N + + // Set parameter + query.setParameter("user", addressbook.getAddressbookUser()); //NOI18N + query.setParameter("name", addressbook.getAddressbookName()); //NOI18N + + // Default is not found + boolean isUsed = false; + + // Try it + try { + // Get a single result + Addressbook dummy = (Addressbook) query.getSingleResult(); + + // Log it + this.getLoggerBeanLocal().logDebug(MessageFormat.format("isAddressbookNameUsed: Found an address book: {0}", dummy)); //NOI18N + + // Found one + isUsed = true; + } catch (final NoResultException ex) { + // No result found, so log it away + this.getLoggerBeanLocal().logDebug(MessageFormat.format("isAddressbookNameUsed: getSingleResult() did not return a result: {0}", ex)); //NOI18N + } + + // Return result + return isUsed; + } +} diff --git a/src/java/org/mxchange/addressbook/model/shared/SharedAddressbooksSessionBean.java b/src/java/org/mxchange/addressbook/model/shared/SharedAddressbooksSessionBean.java new file mode 100644 index 0000000..31b1010 --- /dev/null +++ b/src/java/org/mxchange/addressbook/model/shared/SharedAddressbooksSessionBean.java @@ -0,0 +1,208 @@ +/* + * 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 . + */ +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 + *

+ * @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 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 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 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. + *

+ * @param addressbook Address book to be shared with + * @param sharee User sharee instance + *

+ * @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/jcountry/data/AddressbookCountrySingletonBean.java b/src/java/org/mxchange/jcountry/data/AddressbookCountrySingletonBean.java new file mode 100644 index 0000000..da3e44a --- /dev/null +++ b/src/java/org/mxchange/jcountry/data/AddressbookCountrySingletonBean.java @@ -0,0 +1,49 @@ +/* + * 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 . + */ +package org.mxchange.jcountry.data; + +import java.util.List; +import javax.ejb.Singleton; +import javax.ejb.Startup; +import javax.persistence.Query; +import org.mxchange.jcoreee.database.BaseDatabaseBean; + +/** + * A singleton bean for country informations + *

+ * @author Roland Haeder + */ +@Startup +@Singleton (name = "country", mappedName = "ejb/addressbook-singleton-country", description = "A singleton session bean for country informations") +public class AddressbookCountrySingletonBean extends BaseDatabaseBean implements AddressbookCountrySingletonBeanRemote { + + /** + * Serial number + */ + private static final long serialVersionUID = 15_846_983_298_691_207L; + + @Override + @SuppressWarnings ("unchecked") + public List allCountries () { + // Init query + Query query = this.getEntityManager().createNamedQuery("AllCountries", List.class); //NOI18N + + // Return it + return query.getResultList(); + } + +} diff --git a/src/java/org/mxchange/jphone/phonenumbers/smsprovider/AddressbookSmsProviderSingletonBean.java b/src/java/org/mxchange/jphone/phonenumbers/smsprovider/AddressbookSmsProviderSingletonBean.java new file mode 100644 index 0000000..3f348d2 --- /dev/null +++ b/src/java/org/mxchange/jphone/phonenumbers/smsprovider/AddressbookSmsProviderSingletonBean.java @@ -0,0 +1,49 @@ +/* + * 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 . + */ +package org.mxchange.jphone.phonenumbers.smsprovider; + +import java.util.List; +import javax.ejb.Singleton; +import javax.ejb.Startup; +import javax.persistence.Query; +import org.mxchange.jcoreee.database.BaseDatabaseBean; + +/** + * A singleton bean for country informations + *

+ * @author Roland Haeder + */ +@Startup +@Singleton (name = "smsprovider", mappedName = "ejb/addressbook-singleton-smsprovider", description = "A singleton session bean for SMS provider informations") +public class AddressbookSmsProviderSingletonBean extends BaseDatabaseBean implements AddressbookSmsProviderSingletonBeanRemote { + + /** + * Serial number + */ + private static final long serialVersionUID = 15_846_983_298_691_207L; + + @Override + @SuppressWarnings ("unchecked") + public List allSmsProvider () { + // Init query + Query query = this.getEntityManager().createNamedQuery("AllSmsProvider", List.class); //NOI18N + + // Return it + return query.getResultList(); + } + +} -- 2.39.5