From 9b9d514c63acf6d60c6dfb91ec1d5468545e6f77 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 23 Nov 2022 23:01:13 +0100 Subject: [PATCH] Don't cherry-pick: - synchronized from JFinancials project - updated jar(s) --- lib/jcoreee.jar | Bin 48061 -> 47956 bytes .../AddressbookAdminEmployeeSessionBean.java | 3 +- ...ddressbookAdminHeadquarterSessionBean.java | 17 ++- .../AddressbookHeadquarterSessionBean.java | 2 - ...dressbookAdminOpeningTimesSessionBean.java | 8 +- .../AddressbookAdminCountrySingletonBean.java | 2 +- .../data/AddressbookCountrySingletonBean.java | 2 +- .../AddressbookAdminMobileSessionBean.java | 3 +- .../AddressbookAdminPhoneSessionBean.java | 8 +- .../user/AddressbookAdminUserSessionBean.java | 6 +- .../user/AddressbookUserSessionBean.java | 84 ++++------- .../AddressbookUserLoginSessionBean.java | 140 ------------------ ...ddressbookUserRegistrationSessionBean.java | 37 ++--- 13 files changed, 76 insertions(+), 236 deletions(-) delete mode 100644 src/java/org/mxchange/juserlogincore/model/user/login/AddressbookUserLoginSessionBean.java diff --git a/lib/jcoreee.jar b/lib/jcoreee.jar index 7875d1e28aa5c7870a87df416ff27491d35ee45d..fa82023e537b42f98b05c403a446c558650e5f35 100644 GIT binary patch delta 1758 zcmZWpYgANK6#nj+VeZVGJ1|H%!+^AV+`;J}E3sAbx!UuLgA{ZQ*i|7tB;D|1!0Y~QP*t!C!#^L=}t{W$0D*_ZE$ z@Ba|C7Zw?e3Sb7l9&GBgW!P>EHkIwnh`SX45a=wZ@J-B}=&kVO_$K5AG`ZU6n=na} z?u?@P$~84r?m2b!{<`|g#&vbInKs3ykYBhue?Dd4NTCktH_33Ly^a)-Mv1kiP|#2k zq34J(#C9LC14k&zGJo6W3R2)#FbNwq;g?ZwMuP$)8WjZaii{>RHYr?ZqZzN7v027z z3T*IOu?1UYG|Sj#VaFCL>}b`{>oVT3;!U(^WV;oy*rB1FGIq(>En|;@1nf0qpNw`( zFQ$GRR_&@N2~LYf_HJ)im^Ci#(SFOs2RtsIF1u$ zyf33i#s{>j#1kq~?g^RMhcZr5p>4W>lZV=Dnr)9D(o zhn?vM;*9jAGtaON)ntepPFar{NLb4KWQ54JV}p()#Iv@Ru|Qqu$GF(V(cC9x<9`jN z-ZlZ+lSReC$z78?b`mCQ*E~hRR7}%EjwW(7k;j56YTcH(m}ka(1(BgWwMQj~j6xN~ zh*wdfiBe50Mm){(FO`^kxufCFEpA=cNrQ5C7oR$W(wWC8Z_pziJXS?g zE7NBUdW?=rE8PfkZXP_hg7KpHp_=CpIr}{#tkEQ@>i2Nv9sR{(nvtY^X=EAjh)qV_ z)@QU(#XyF*q)`ur7$Smh4!GUgd>olwJin&#MLquXv_3HF2lrYMXvd(PszNU54z+|< zNeAht&e>EpB`#Sfn9x) zXIX*1r=vjDjm76(B6}XIGO6plSNvJ5UxRj)!BW1c5-0r=`g6eWwFGG$V8*eiCG zJyJ!|aG8V3hg7;VXr%jLmuOk?$dpM-hP>jtr8@1XOronyv#LjEUA2w!E~xJR{e>Tw z%xh2U-y3v?#M;q%)rSI4A1Nik#w5CZVUAe8jXL|&sBn0$*s_;j%}lyJ>=Dgf`i4HE gOyvh-XjZq0)pjbp=n_{>uqlJuFJ_vyp3zeN3(_aiX#fBK delta 1850 zcmZWpX>b%(5dP-vvTrk)O(ubm&AG#6$cB(Cgb)tF3Wos-ksNZ!wLpYmvb#w(AcsZ- zJRk~5BOss#34$0Bk`3fQ4$B`{ASG5|6+bLWE!3hYz#o>Ng-6cwZ1` zdi%=n;`CkNcy@-xsseUkeQSBWW2j?YYkA4_+BKVf0DSfNiwAp#XAk$}X5?iC{MEtC z$)!unyuM7&^3tUqPmRYI8Yb$$`jVzw^iY#>U7-kzPN^b+T$Q#^r=_q@OkPWQiFL!( z)jM^-d~@jsC50}xC)Zy1yXOp_GZLSx7zCe+5%8PBClRotQiT;&D(0hFB4|gA%6V4V zvD%I`5-+K6z!!I?RZCGyNX2YP*INt6$3z~ai^KpyLRj{^W3ds58jJ}3w!O@XIl2# z@qQ#ez=w7;N*s{*hysP~&~xftVLd3(M8%GAp$5k~MOi?O=qGK5G<=N1)Nf!Kt&3h{ zJEGwe9Hnc~<1L?}nNsv5{g{Rpv}%}&r!^c$8x`n_ly*9-|CtyV7?jL9!~BaohJBVT_cgBa)XRgk%3%Oj5bA{DaNoMzt7NyVX_@lR77E_J+#O7 zq0&#oY$R(aG)0jqijhpu1PYW)+8rpNJAt^lnHa8M)+Ddb=MNg*Wy`om##Apall;D5 z=}W<3Mum6n(o$oszs6YUU0rGftIA538$rKOQ_Wx{7js#;mz`dy@>dvMpD|^6{zL^s zsD4yj$W^Hc*^d)a5Jy=%<02yXyOSBE(6iNDN-9MJXVtp63WeO#TVR2~oo0hXBL;GZ z0UGvUFmnoGunR+26X?$^`2=egjvBIg)?3{Qyddw|mJW#VjeaLw{nW9>v#HRnK z%k5U0(Bc+nA5oE1$M7!`rqH)7ZY8&&b(#`rXm!!KB1wT(x6<|iIOsfsdnTAUM{;nt zGKT7pJE_qdNsVpEbfhIpS;I_$ay-oMs8{Je@4D5CrnO~>ENeK`9re-d#)%@zq?Ni0~2@hd`c+<`|tWgj8{9OqlNJ@Q4HB!)p8qkEoeQ2PS%G{Ry|2 zo*!l#^Cewn=$gVXoia~miyN~^X-(zAIq0cECna@i)N(RaWmoU6 c+q)C#Vo$b6KNzO;roohVs=w{$X7k{G0o>8{(f|Me diff --git a/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookAdminEmployeeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookAdminEmployeeSessionBean.java index 0ee1245..0dc3944 100644 --- a/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookAdminEmployeeSessionBean.java +++ b/src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookAdminEmployeeSessionBean.java @@ -27,6 +27,7 @@ import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice; import org.mxchange.jcontactsbusiness.model.department.Department; import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; import org.mxchange.jcontactsbusiness.model.jobposition.HireableJobPosition; +import org.mxchange.jcontactsbusiness.model.utils.EmployeeUtils; import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider; import org.mxchange.jusercore.model.user.User; @@ -233,7 +234,7 @@ public class AddressbookAdminEmployeeSessionBean extends BaseAddressbookEnterpri // Check all entries for (final Employable otherEmployee : this.employeeBean.fetchAllEmployees()) { // Is same found? - if (Employees.isSameEmployeeFound(employee, otherEmployee)) { + if (EmployeeUtils.isSameEmployeeFound(employee, otherEmployee)) { // Found it isFound = true; break; diff --git a/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookAdminHeadquarterSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookAdminHeadquarterSessionBean.java index cc7738a..2718e0a 100644 --- a/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookAdminHeadquarterSessionBean.java +++ b/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookAdminHeadquarterSessionBean.java @@ -21,10 +21,12 @@ import java.util.Date; import java.util.List; import javax.ejb.EJB; import javax.ejb.Stateless; +import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean; +import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterAlreadyAddedException; import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; +import org.mxchange.jcontactsbusiness.model.utils.HeadquarterUtils; import org.mxchange.jcountry.model.data.Country; -import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean; import org.mxchange.jusercore.model.user.User; /** @@ -72,7 +74,16 @@ public class AddressbookAdminHeadquarterSessionBean extends BaseAddressbookEnter } // Add created timestamp - headquarter.setHeadquarterCreated(new Date()); + headquarter.setHeadquarterEntryCreated(new Date()); + + // Is contact employee set? + if (headquarter.getHeadquarterContactEmployee() instanceof Contact) { + // Get managed lead contact + final Contact managedContact = this.createManaged(headquarter.getHeadquarterContactEmployee()); + + // Set it back + headquarter.setHeadquarterContactEmployee(managedContact); + } // Is user instance set? if (headquarter.getHeadquarterUserOwner() instanceof User) { @@ -139,7 +150,7 @@ public class AddressbookAdminHeadquarterSessionBean extends BaseAddressbookEnter // Check all single addresses for (final Headquarter hq : headquarters) { // Is the same address found? - if (Headquarters.isSameAddress(hq, headquarter)) { + if (HeadquarterUtils.isSameAddress(hq, headquarter)) { // Found one isFound = true; break; diff --git a/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookHeadquarterSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookHeadquarterSessionBean.java index c74aab7..734ffde 100644 --- a/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookHeadquarterSessionBean.java +++ b/src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookHeadquarterSessionBean.java @@ -16,13 +16,11 @@ */ package org.mxchange.jcontactsbusiness.model.headquarter; -import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; import java.text.MessageFormat; import java.util.List; import javax.ejb.Stateless; import javax.persistence.Query; import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean; -import org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterSessionBeanRemote; /** * A stateless session bean for general headquarter purposes diff --git a/src/java/org/mxchange/jcontactsbusiness/model/opening_time/AddressbookAdminOpeningTimesSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/opening_time/AddressbookAdminOpeningTimesSessionBean.java index a9848c8..27fc345 100644 --- a/src/java/org/mxchange/jcontactsbusiness/model/opening_time/AddressbookAdminOpeningTimesSessionBean.java +++ b/src/java/org/mxchange/jcontactsbusiness/model/opening_time/AddressbookAdminOpeningTimesSessionBean.java @@ -54,16 +54,16 @@ public class AddressbookAdminOpeningTimesSessionBean extends BaseAddressbookEnte } else if (openingTime.getOpeningTimeId() instanceof Long) { // Should not happen throw new IllegalArgumentException("openingTime.openingId should not be set."); //NOI18N - } else if (openingTime.getOpeningStartDay()== null) { + } else if (openingTime.getOpeningStartDay() == null) { // Throw NPE throw new NullPointerException("openingTime.openingStartDay is null"); //NOI18N - } else if (openingTime.getOpeningStartTime()== null) { + } else if (openingTime.getOpeningStartTime() == null) { // Throw NPE throw new NullPointerException("openingTime.openingStartTime is null"); //NOI18N - } else if (openingTime.getOpeningEndDay()== null) { + } else if (openingTime.getOpeningEndDay() == null) { // Throw NPE throw new NullPointerException("openingTime.openingEndDay is null"); //NOI18N - } else if (openingTime.getOpeningEndTime()== null) { + } else if (openingTime.getOpeningEndTime() == null) { // Throw NPE throw new NullPointerException("openingTime.openingEndTime is null"); //NOI18N } diff --git a/src/java/org/mxchange/jcountry/model/data/AddressbookAdminCountrySingletonBean.java b/src/java/org/mxchange/jcountry/model/data/AddressbookAdminCountrySingletonBean.java index 249307b..95d92ff 100644 --- a/src/java/org/mxchange/jcountry/model/data/AddressbookAdminCountrySingletonBean.java +++ b/src/java/org/mxchange/jcountry/model/data/AddressbookAdminCountrySingletonBean.java @@ -21,8 +21,8 @@ import java.util.Date; import java.util.Objects; import javax.ejb.EJB; import javax.ejb.Stateless; -import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException; import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean; +import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException; /** * A stateless EJB for administrative country purposes diff --git a/src/java/org/mxchange/jcountry/model/data/AddressbookCountrySingletonBean.java b/src/java/org/mxchange/jcountry/model/data/AddressbookCountrySingletonBean.java index 55c5758..2ecfe8d 100644 --- a/src/java/org/mxchange/jcountry/model/data/AddressbookCountrySingletonBean.java +++ b/src/java/org/mxchange/jcountry/model/data/AddressbookCountrySingletonBean.java @@ -13,7 +13,7 @@ * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . -*/ + */ package org.mxchange.jcountry.model.data; import java.text.MessageFormat; diff --git a/src/java/org/mxchange/jphone/model/phonenumbers/mobile/AddressbookAdminMobileSessionBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/mobile/AddressbookAdminMobileSessionBean.java index 269fc32..3f3fd17 100644 --- a/src/java/org/mxchange/jphone/model/phonenumbers/mobile/AddressbookAdminMobileSessionBean.java +++ b/src/java/org/mxchange/jphone/model/phonenumbers/mobile/AddressbookAdminMobileSessionBean.java @@ -20,6 +20,7 @@ import java.text.MessageFormat; import java.util.Date; import javax.ejb.Stateless; import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean; +import org.mxchange.jphone.model.utils.MobileNumberUtils; /** * An EJB for administrative mobile number purposes @@ -126,7 +127,7 @@ public class AddressbookAdminMobileSessionBean extends BaseAddressbookEnterprise this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateMobileData: managedNumber.phoneId={1}", this.getClass().getSimpleName(), managedNumber.getMobileId())); //NOI18N // Set updated timestamp - MobileNumbers.copyMobileNumberData(mobileNumber, managedNumber); + MobileNumberUtils.copyMobileNumberData(mobileNumber, managedNumber); managedNumber.setMobileEntryUpdated(new Date()); // Trace message diff --git a/src/java/org/mxchange/jphone/model/phonenumbers/phone/AddressbookAdminPhoneSessionBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/phone/AddressbookAdminPhoneSessionBean.java index e3c8f8c..d28655f 100644 --- a/src/java/org/mxchange/jphone/model/phonenumbers/phone/AddressbookAdminPhoneSessionBean.java +++ b/src/java/org/mxchange/jphone/model/phonenumbers/phone/AddressbookAdminPhoneSessionBean.java @@ -21,9 +21,9 @@ import java.util.Date; import javax.ejb.Stateless; import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; -import org.mxchange.jphone.model.phonenumbers.fax.FaxNumbers; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; -import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumbers; +import org.mxchange.jphone.model.utils.FaxNumberUtils; +import org.mxchange.jphone.model.utils.LandLineNumberUtils; /** * An EJB for administrative phone purposes @@ -190,7 +190,7 @@ public class AddressbookAdminPhoneSessionBean extends BaseAddressbookEnterpriseB this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateFaxData: managedNumber.phoneId={1}", this.getClass().getSimpleName(), managedNumber.getPhoneId())); //NOI18N // Set updated timestamp - FaxNumbers.copyFaxNumberData(faxNumber, managedNumber); + FaxNumberUtils.copyFaxNumberData(faxNumber, managedNumber); managedNumber.setPhoneEntryUpdated(new Date()); // Trace message @@ -248,7 +248,7 @@ public class AddressbookAdminPhoneSessionBean extends BaseAddressbookEnterpriseB this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateLandLineData: managedNumber.phoneId={1}", this.getClass().getSimpleName(), managedNumber.getPhoneId())); //NOI18N // Set updated timestamp - LandLineNumbers.copyLandLineNumberData(landLineNumber, managedNumber); + LandLineNumberUtils.copyLandLineNumberData(landLineNumber, managedNumber); managedNumber.setPhoneEntryUpdated(new Date()); // Trace message diff --git a/src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java index 7220780..55dec96 100644 --- a/src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java @@ -20,8 +20,8 @@ import java.text.MessageFormat; import java.util.Date; import javax.ejb.EJB; import javax.ejb.Stateless; -import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean; +import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException; import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException; import org.mxchange.jusercore.exceptions.UserNotFoundException; @@ -87,7 +87,7 @@ public class AddressbookAdminUserSessionBean extends BaseAddressbookEnterpriseBe } // Set created timestamp - user.setUserCreated(new Date()); + user.setUserEntryCreated(new Date()); user.getUserContact().setContactEntryCreated(new Date()); // Update mobile, land-line and fax instance @@ -184,7 +184,7 @@ public class AddressbookAdminUserSessionBean extends BaseAddressbookEnterpriseBe user.setUserContact(foundContact); // Set timestamp - user.setUserCreated(new Date()); + user.setUserEntryCreated(new Date()); // Perist it this.getEntityManager().persist(user); diff --git a/src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java index 5469f78..9c2aa17 100644 --- a/src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java @@ -25,13 +25,12 @@ import javax.ejb.Stateless; import javax.persistence.Query; import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean; import org.mxchange.jcontacts.model.contact.Contact; -import org.mxchange.jcontacts.model.contact.Contacts; import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber; -import org.mxchange.jphone.model.phonenumbers.fax.FaxNumbers; import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber; -import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumbers; import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber; -import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumbers; +import org.mxchange.jphone.model.utils.FaxNumberUtils; +import org.mxchange.jphone.model.utils.LandLineNumberUtils; +import org.mxchange.jphone.model.utils.MobileNumberUtils; import org.mxchange.jusercore.exceptions.UserNotFoundException; import org.mxchange.jusercore.exceptions.UserStatusConfirmedException; import org.mxchange.jusercore.exceptions.UserStatusLockedException; @@ -39,6 +38,7 @@ import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException; import org.mxchange.jusercore.model.user.password_history.PasswordHistory; import org.mxchange.jusercore.model.user.password_history.UserPasswordHistory; import org.mxchange.jusercore.model.user.status.UserAccountStatus; +import org.mxchange.jusercore.model.utils.UserUtils; /** * A user EJB @@ -62,7 +62,7 @@ public class AddressbookUserSessionBean extends BaseAddressbookEnterpriseBean im } @Override - public User confirmAccount (final User user, final String baseUrl) throws UserStatusConfirmedException, UserStatusLockedException { + public User confirmAccount (final User user, final String baseUrl) throws UserStatusConfirmedException, UserStatusLockedException, UserNotFoundException { // Trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.confirmAccount: user={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), user, baseUrl)); //NOI18N @@ -99,7 +99,7 @@ public class AddressbookUserSessionBean extends BaseAddressbookEnterpriseBean im // Update user status and remove confirmation key managedUser.setUserAccountStatus(UserAccountStatus.CONFIRMED); managedUser.setUserConfirmKey(null); - managedUser.setUserUpdated(new Date()); + managedUser.setUserEntryUpdated(new Date()); // Send out email this.sendEmail("User account confirmed", "user_account_confirmed", managedUser, baseUrl, null); //NOI18N @@ -261,39 +261,39 @@ public class AddressbookUserSessionBean extends BaseAddressbookEnterpriseBean im } @Override - public User updateUserData (final User user) { + public User updateUserData (final User detachedUser) throws UserNotFoundException { // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: detachedUser={1} - CALLED!", this.getClass().getSimpleName(), detachedUser)); //NOI18N // user should not be null - if (null == user) { + if (null == detachedUser) { // Abort here - throw new NullPointerException("user is null"); //NOI18N - } else if (user.getUserId() == null) { + throw new NullPointerException("detachedUser is null"); //NOI18N + } else if (detachedUser.getUserId() == null) { // Throw NPE again - throw new NullPointerException("user.userId is null"); //NOI18N - } else if (user.getUserId() < 1) { + throw new NullPointerException("detachedUser.userId is null"); //NOI18N + } else if (detachedUser.getUserId() < 1) { // Not valid - throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N - } else if (user.getUserAccountStatus() == null) { + throw new IllegalArgumentException(MessageFormat.format("detachedUser.userId={0} is not valid.", detachedUser.getUserId())); //NOI18N + } else if (detachedUser.getUserAccountStatus() == null) { // Throw NPE again - throw new NullPointerException("user.userAccountStatus is null"); //NOI18N - } else if (!this.ifUserExists(user)) { + throw new NullPointerException("detachedUser.userAccountStatus is null"); //NOI18N + } else if (!this.ifUserExists(detachedUser)) { // User does not exist - throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N + throw new UserNotFoundException(detachedUser.getUserId()); } // Remove contact instance as this is not updated - user.setUserContact(null); + detachedUser.setUserContact(null); // Find the instance - final User foundUser = this.getEntityManager().find(user.getClass(), user.getUserId()); + final User foundUser = this.getEntityManager().find(detachedUser.getClass(), detachedUser.getUserId()); // Should be found! - assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N + assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", detachedUser.getUserId()); //NOI18N // Copy all data - Users.copyUserData(user, foundUser); + UserUtils.copyUserData(detachedUser, foundUser); // Merge user final User managedUser = this.getEntityManager().merge(foundUser); @@ -302,7 +302,7 @@ public class AddressbookUserSessionBean extends BaseAddressbookEnterpriseBean im assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not merged, but should be.", managedUser.getUserId()); //NOI18N // Set as updated - managedUser.setUserUpdated(new Date()); + managedUser.setUserEntryUpdated(new Date()); // Trace message this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: managedUser={1} - CALLED!", this.getClass().getSimpleName(), managedUser)); //NOI18N @@ -362,7 +362,7 @@ public class AddressbookUserSessionBean extends BaseAddressbookEnterpriseBean im final User managedUser = this.updateUserData(user); // Update user account - managedUser.setUserUpdated(new Date()); + managedUser.setUserEntryUpdated(new Date()); // Create history entry final PasswordHistory entry = new UserPasswordHistory(user.getUserEncryptedPassword(), managedUser); @@ -417,26 +417,13 @@ public class AddressbookUserSessionBean extends BaseAddressbookEnterpriseBean im assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N // Copy all data - Users.copyUserData(user, managedUser); + UserUtils.copyUserData(user, managedUser); // Set as updated - managedUser.setUserUpdated(new Date()); - managedUser.getUserContact().setContactEntryUpdated(new Date()); + managedUser.setUserEntryUpdated(new Date()); - // Get contact from it and find it - final Contact foundContact = this.getEntityManager().find(managedUser.getUserContact().getClass(), managedUser.getUserContact().getContactId()); - - // Should be found - assert (foundContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", managedUser.getUserContact().getContactId()); //NOI18N - - // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: contact.contactId={0}", foundContact.getContactId())); //NOI18N - - // Merge contact instance - final Contact managedContact = this.getEntityManager().merge(foundContact); - - // Copy all - Contacts.copyContactData(managedUser.getUserContact(), managedContact); + // Update user data + final Contact managedContact = this.mergeContactData(managedUser.getUserContact()); // Set it back in user managedUser.setUserContact(managedContact); @@ -459,7 +446,7 @@ public class AddressbookUserSessionBean extends BaseAddressbookEnterpriseBean im assert (foundMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", foundMobile.getMobileId()); //NOI18N // Copy all - MobileNumbers.copyMobileNumberData(managedUser.getUserContact().getContactMobileNumber(), foundMobile); + MobileNumberUtils.copyMobileNumberData(managedUser.getUserContact().getContactMobileNumber(), foundMobile); // Then merge it, too final DialableMobileNumber managedMobile = this.getEntityManager().merge(foundMobile); @@ -467,9 +454,6 @@ public class AddressbookUserSessionBean extends BaseAddressbookEnterpriseBean im // Should be there assert (managedMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", managedMobile.getMobileId()); //NOI18N - // Copy all - MobileNumbers.copyMobileNumberData(managedUser.getUserContact().getContactMobileNumber(), managedMobile); - // Set it back managedContact.setContactMobileNumber(managedMobile); } @@ -489,7 +473,7 @@ public class AddressbookUserSessionBean extends BaseAddressbookEnterpriseBean im assert (foundFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", foundFax.getPhoneId()); //NOI18N // Copy all - FaxNumbers.copyFaxNumberData(managedUser.getUserContact().getContactFaxNumber(), foundFax); + FaxNumberUtils.copyFaxNumberData(managedUser.getUserContact().getContactFaxNumber(), foundFax); // Then merge it, too final DialableFaxNumber managedFax = this.getEntityManager().merge(foundFax); @@ -497,9 +481,6 @@ public class AddressbookUserSessionBean extends BaseAddressbookEnterpriseBean im // Should be there assert (managedFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", managedFax.getPhoneId()); //NOI18N - // Copy all - FaxNumbers.copyFaxNumberData(managedUser.getUserContact().getContactFaxNumber(), managedFax); - // Set it back managedContact.setContactFaxNumber(managedFax); } @@ -519,7 +500,7 @@ public class AddressbookUserSessionBean extends BaseAddressbookEnterpriseBean im assert (foundLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", foundLandLine.getPhoneId()); //NOI18N // Copy all - LandLineNumbers.copyLandLineNumberData(managedUser.getUserContact().getContactLandLineNumber(), foundLandLine); + LandLineNumberUtils.copyLandLineNumberData(managedUser.getUserContact().getContactLandLineNumber(), foundLandLine); // Then merge it, too final DialableLandLineNumber managedLandLine = this.getEntityManager().merge(foundLandLine); @@ -527,9 +508,6 @@ public class AddressbookUserSessionBean extends BaseAddressbookEnterpriseBean im // Should be there assert (managedLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", managedLandLine.getPhoneId()); //NOI18N - // Copy all - LandLineNumbers.copyLandLineNumberData(managedUser.getUserContact().getContactLandLineNumber(), managedLandLine); - // Set it back managedContact.setContactLandLineNumber(managedLandLine); } diff --git a/src/java/org/mxchange/juserlogincore/model/user/login/AddressbookUserLoginSessionBean.java b/src/java/org/mxchange/juserlogincore/model/user/login/AddressbookUserLoginSessionBean.java deleted file mode 100644 index eff0454..0000000 --- a/src/java/org/mxchange/juserlogincore/model/user/login/AddressbookUserLoginSessionBean.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2016 - 2022 Free Software Foundation - * - * 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 . - */ -package org.mxchange.juserlogincore.model.user.login; - -import java.text.MessageFormat; -import javax.ejb.EJB; -import javax.ejb.Stateless; -import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean; -import org.mxchange.jusercore.exceptions.UserNotFoundException; -import org.mxchange.jusercore.exceptions.UserStatusLockedException; -import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException; -import org.mxchange.jusercore.model.user.User; -import org.mxchange.jusercore.model.user.UserSessionBeanRemote; -import org.mxchange.jusercore.model.user.status.UserAccountStatus; -import org.mxchange.juserlogincore.container.login.LoginContainer; -import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException; -import org.mxchange.juserlogincore.login.UserLoginUtils; - -/** - * A session EJB for user logins - *

- * @author Roland Häder - */ -@Stateless (name = "userLogin", description = "A bean handling the application-specific user login") -public class AddressbookUserLoginSessionBean extends BaseAddressbookEnterpriseBean implements UserLoginSessionBeanRemote { - - /** - * Serial number - */ - private static final long serialVersionUID = 21_785_978_127_581_965L; - - /** - * User EJB - */ - @EJB (lookup = "java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote") - private UserSessionBeanRemote userBean; - - /** - * Default constructor - */ - public AddressbookUserLoginSessionBean () { - // Call super constructor - super(); - } - - @Override - public User validateUserAccountStatus (final LoginContainer container) throws UserNotFoundException, UserStatusLockedException, UserStatusUnconfirmedException, UserPasswordMismatchException { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.loginUser: container={1} - CALLED!", this.getClass().getSimpleName(), container)); //NOI18N - - // user should not be null - if (null == container) { - // Abort here - throw new NullPointerException("container is null"); //NOI18N - } else if (container.getUser() == null) { - // NPE again - throw new NullPointerException("container.user is null"); //NOI18N - } else if (container.getUserPassword() == null) { - // And yet again NPE - throw new NullPointerException("container.userPassword is null"); //NOI18N - } else if (container.getUserPassword().isEmpty()) { - // Empty password is not allowed, hardcoded. - throw new IllegalArgumentException("container.userPassword is empty"); //NOI18N - } - - // Is the account there? - if (!this.userBean.isUserNameRegistered(container.getUser())) { - // Not registered - throw new UserNotFoundException(container.getUser()); - } - - // Get user instance from persistance - // @TODO Rewrite this to use JCache instead - final User updatedUser = this.userBean.fillUserData(container.getUser()); - - // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("loginUser: updatedUser={0}", updatedUser)); //NOI18N - - // Is the user account unconfirmed? - if (updatedUser.getUserAccountStatus().equals(UserAccountStatus.UNCONFIRMED)) { - // Is unconfirmed - throw new UserStatusUnconfirmedException(container.getUser()); - } else if (updatedUser.getUserAccountStatus().equals(UserAccountStatus.LOCKED)) { - // Is locked - throw new UserStatusLockedException(container.getUser()); - } else if (!this.isPasswordMatching(container, updatedUser)) { - // Not matcing passwords - throw new UserPasswordMismatchException(container.getUser()); - } - - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.loginUser: updatedUser={1} - EXIT!", this.getClass().getSimpleName(), updatedUser)); //NOI18N - - // Return it - return updatedUser; - } - - /** - * Checks if password matches of both instances. Both user instances must - * not match, the first one is the one from the calling bean/controller, the - * second is the from database. - *

- * @param container Container instance holding the user instance and - * clear-text password - * @param updatedUser Updated user instance found for given user name - *

- * @return Whether the password matches - */ - private boolean isPasswordMatching (final LoginContainer container, final User updatedUser) { - // First math both instances - if (null == container) { - // Throw NPE - throw new NullPointerException("container is null"); //NOI18N - } else if (null == updatedUser) { - // Throw NPE - throw new NullPointerException("updatedUser is null"); //NOI18N - } else if (container.getUser().equals(updatedUser)) { - // Both same instance! - throw new IllegalArgumentException(MessageFormat.format("container.user matches updatedUser: {0}", container.getUser())); //NOI18N - } - - // Is it the same same password? - return UserLoginUtils.ifPasswordMatches(container, updatedUser); - } - -} diff --git a/src/java/org/mxchange/juserlogincore/model/user/register/AddressbookUserRegistrationSessionBean.java b/src/java/org/mxchange/juserlogincore/model/user/register/AddressbookUserRegistrationSessionBean.java index 4d5ad00..427a408 100644 --- a/src/java/org/mxchange/juserlogincore/model/user/register/AddressbookUserRegistrationSessionBean.java +++ b/src/java/org/mxchange/juserlogincore/model/user/register/AddressbookUserRegistrationSessionBean.java @@ -17,17 +17,14 @@ package org.mxchange.juserlogincore.model.user.register; import java.text.MessageFormat; +import java.util.List; import java.util.Objects; import javax.ejb.EJB; import javax.ejb.Stateless; -import javax.persistence.NoResultException; -import javax.persistence.Query; import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean; -import org.mxchange.jcontacts.model.contact.Contact; import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException; import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException; import org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote; -import org.mxchange.jusercore.model.user.LoginUser; import org.mxchange.jusercore.model.user.User; import org.mxchange.jusercore.model.user.UserSessionBeanRemote; import org.mxchange.juserlogincore.login.UserLoginUtils; @@ -76,8 +73,8 @@ public class AddressbookUserRegistrationSessionBean extends BaseAddressbookEnter throw new NullPointerException("user is null"); //NOI18N } - // Create named instance - final Query query = this.getEntityManager().createNamedQuery("SearchUserByConfirmKey", LoginUser.class); //NOI18N + // Fetch whole list + final List users = this.userBean.fetchAllUsers(); // Init confirmation key String confirmationKey = null; @@ -85,22 +82,16 @@ public class AddressbookUserRegistrationSessionBean extends BaseAddressbookEnter // Find a free one while (confirmationKey == null) { // Create new one - final String key = UserLoginUtils.generatedConfirmationKey(user); - - // Set key as parameter - query.setParameter("confirmKey", key); //NOI18N - - // Try it - try { - // Get contact instance - final Contact contact = (Contact) query.getSingleResult(); - - // Warning message - this.getLoggerBeanLocal().logWarning(MessageFormat.format("{0}.generateConfirmationKey: key {1} already found: contact.contactId={2}", this.getClass().getSimpleName(), key, contact.getContactId())); //NOI18N - } catch (final NoResultException ex) { - // Not found, normal case - confirmationKey = key; - break; + confirmationKey = UserLoginUtils.generatedConfirmationKey(user); + + // Check all entries + for (final User currentUser : users) { + // Does the key match? + if (Objects.equals(currentUser.getUserConfirmKey(), confirmationKey)) { + // Set key to null and exit loop + confirmationKey = null; + break; + } } } @@ -154,7 +145,7 @@ public class AddressbookUserRegistrationSessionBean extends BaseAddressbookEnter // Is password set? if ((randomPassword instanceof String) && (!randomPassword.isEmpty())) { - // Switch to other template + // Switch to template with random password exposed templateName = "user_registration_random"; //NOI18N } -- 2.39.5