]> git.mxchange.org Git - addressbook-ejb.git/commitdiff
Don't cherry-pick:
authorRoland Häder <roland@mxchange.org>
Wed, 23 Nov 2022 22:01:13 +0000 (23:01 +0100)
committerRoland Häder <roland@mxchange.org>
Wed, 23 Nov 2022 22:01:13 +0000 (23:01 +0100)
- synchronized from JFinancials project
- updated jar(s)

13 files changed:
lib/jcoreee.jar
src/java/org/mxchange/jcontactsbusiness/model/employee/AddressbookAdminEmployeeSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookAdminHeadquarterSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/headquarter/AddressbookHeadquarterSessionBean.java
src/java/org/mxchange/jcontactsbusiness/model/opening_time/AddressbookAdminOpeningTimesSessionBean.java
src/java/org/mxchange/jcountry/model/data/AddressbookAdminCountrySingletonBean.java
src/java/org/mxchange/jcountry/model/data/AddressbookCountrySingletonBean.java
src/java/org/mxchange/jphone/model/phonenumbers/mobile/AddressbookAdminMobileSessionBean.java
src/java/org/mxchange/jphone/model/phonenumbers/phone/AddressbookAdminPhoneSessionBean.java
src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java
src/java/org/mxchange/jusercore/model/user/AddressbookUserSessionBean.java
src/java/org/mxchange/juserlogincore/model/user/login/AddressbookUserLoginSessionBean.java [deleted file]
src/java/org/mxchange/juserlogincore/model/user/register/AddressbookUserRegistrationSessionBean.java

index 7875d1e28aa5c7870a87df416ff27491d35ee45d..fa82023e537b42f98b05c403a446c558650e5f35 100644 (file)
Binary files a/lib/jcoreee.jar and b/lib/jcoreee.jar differ
index 0ee124594100a79a1f3cfae8296421ab8f541349..0dc39442b6aed1635cf6465454ac8452e8dc8dd8 100644 (file)
@@ -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;
index cc7738a4fdfd4a659985c81447aa190a2c50a668..2718e0a6066931b92ad6f29a741d0d1565748fd6 100644 (file)
@@ -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;
index c74aab798d4cd042f9d4c06b499618f970e67e64..734ffde745b00aa51c71d298268b10f8537499ef 100644 (file)
  */
 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
index a9848c8b4a0a0987a91dded0506eeff6bd662280..27fc345e5a310e75f2c17514f370cba330be93e2 100644 (file)
@@ -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
                }
index 249307badf0ecc5835796f4fa13e15087dd5704e..95d92ff080625da00128b58201267416924e1fd5 100644 (file)
@@ -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
index 55c5758b20afb68b6879ef198ca26d7356c700ab..2ecfe8d1c9b02a5206e0ae171e17670ba8c7e6ee 100644 (file)
@@ -13,7 +13,7 @@
  *
  * 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.jcountry.model.data;
 
 import java.text.MessageFormat;
index 269fc32113d065eef6dc3b0ec53c35270acafe9a..3f3fd17b31be27f5347fd5faa18311106ec463db 100644 (file)
@@ -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
index e3c8f8cc6bbc02fe29ce2897ff40d804e43938f2..d28655f2b0e46ab79975de7d2c76a34bc70c724c 100644 (file)
@@ -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
index 72207800d79ae144f8cb8474b6326fc3fcf9a795..55dec9642c732ea3bc380077c8337d6daca6ca68 100644 (file)
@@ -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);
index 5469f782a2edd4bf27fa8180678ed2a3c7c4e686..9c2aa17d62ac299ff2fabc62eefb98f337628a2d 100644 (file)
@@ -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 (file)
index eff0454..0000000
+++ /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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@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.
-        * <p>
-        * @param container   Container instance holding the user instance and
-        *                    clear-text password
-        * @param updatedUser Updated user instance found for given user name
-        * <p>
-        * @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);
-       }
-
-}
index 4d5ad00c5e5cbc09a0347db128a3a70b3ea1a0c1..427a4087f901569258fcafe8bc0600773f8ae638 100644 (file)
 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<User> 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
                }