]> git.mxchange.org Git - jjobs-ejb.git/blobdiff - src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java
Don't cherry-pick:
[jjobs-ejb.git] / src / java / org / mxchange / jusercore / model / user / JobsUserSessionBean.java
index b814bda5335086539128cf4e1240bf83db8f3116..7a4339379b74f79d265a486dbe738ee1b2f5e2d5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 - 2020 Free Software Foundation
+ * 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
@@ -26,11 +26,11 @@ import javax.persistence.Query;
 import org.mxchange.jcontacts.model.contact.Contact;
 import org.mxchange.jjobs.enterprise.BaseJobsEnterpriseBean;
 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;
@@ -38,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
@@ -151,8 +152,15 @@ public class JobsUserSessionBean extends BaseJobsEnterpriseBean implements UserS
 
                // Fetch whole list
                for (final User currentUser : this.fetchAllUsers()) {
-                       // Is found?
-                       if (Objects.equals(user, currentUser)) {
+                       /*
+                        * E.g. userAccountStatus can be fifferent because lockUserAccount
+                        * is setting it BEFORE this method is invoked. So this is enough
+                        * for us in this case. But otherwise e.g. when a new user is
+                        * created with same data, then this method must return FALSE even
+                        * when userId is currently NULL.
+                        */
+                       //* NOISY-DEBUG: */ this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.ifUserExists: currentUser={1},currentUser.userId={2}", this.getClass(), currentUser, currentUser.getUserId())); //NOI18N
+                       if ((Objects.equals(user.getUserId(), currentUser.getUserId()) && user.getUserId() != null) || Objects.equals(user, currentUser)) {
                                // Yes, then set flag and exit iteration
                                isFound = true;
                                break;
@@ -282,7 +290,7 @@ public class JobsUserSessionBean extends BaseJobsEnterpriseBean implements UserS
                assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
 
                // Copy all data
-               Users.copyUserData(user, foundUser);
+               UserUtils.copyUserData(user, foundUser);
 
                // Merge user
                final User managedUser = this.getEntityManager().merge(foundUser);
@@ -406,7 +414,7 @@ public class JobsUserSessionBean extends BaseJobsEnterpriseBean implements UserS
                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.setUserEntryUpdated(new Date());
@@ -435,7 +443,7 @@ public class JobsUserSessionBean extends BaseJobsEnterpriseBean implements UserS
                        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);
@@ -462,7 +470,7 @@ public class JobsUserSessionBean extends BaseJobsEnterpriseBean implements UserS
                        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);
@@ -489,7 +497,7 @@ public class JobsUserSessionBean extends BaseJobsEnterpriseBean implements UserS
                        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);