]> git.mxchange.org Git - jfinancials-mailer-ejb.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Thu, 25 Aug 2016 13:54:23 +0000 (15:54 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 9 Jun 2017 20:26:47 +0000 (22:26 +0200)
- made user instance managed which causes not persisting it all over again
- renamed variable

src/java/org/mxchange/jusercore/model/email_address/AddressbookUserEmailChangeSessionBean.java

index b4065f6a56e828b9b360c0ee12a1dfd52be037c2..807e2e7053cf213012a26bb09f41854bbd177bbb 100644 (file)
@@ -108,6 +108,9 @@ public class AddressbookUserEmailChangeSessionBean extends BaseAddressbookDataba
                emailChange.setEmailChangeCreated(new GregorianCalendar());
                this.generateSecureHash(emailChange);
 
+               // Make user managed
+               emailChange.setEmailChangeUser(this.getManagedUser(emailChange.getEmailChangeUser()));
+
                // Persist it
                //@TODO Fix email delivery then allow this: this.getEntityManager().persist(emailChange);
                // Init variable
@@ -194,16 +197,16 @@ public class AddressbookUserEmailChangeSessionBean extends BaseAddressbookDataba
         * Generates a secure, unique hash for given email address change. This
         * requires to check if the hash is really not there.
         * <p>
-        * @param emailAddress Email address change
+        * @param emailAddressChange Email address change
         */
-       private void generateSecureHash (final ChangeableEmailAddress emailAddress) {
+       private void generateSecureHash (final ChangeableEmailAddress emailAddressChange) {
                // Email address change should be valid
-               if (null == emailAddress) {
+               if (null == emailAddressChange) {
                        // Abort here
-                       throw new NullPointerException("emailAddress is null"); //NOI18N
-               } else if (emailAddress.getEmailAddress().trim().isEmpty()) {
+                       throw new NullPointerException("emailAddressChange is null"); //NOI18N
+               } else if (emailAddressChange.getEmailAddress().trim().isEmpty()) {
                        // Email address is empty
-                       throw new IllegalArgumentException("emailAddress.emaiLAddress is empty."); //NOI18N
+                       throw new IllegalArgumentException("emailAddressChange.emaiLAddress is empty."); //NOI18N
                }
 
                // Initialize loop with null
@@ -215,7 +218,7 @@ public class AddressbookUserEmailChangeSessionBean extends BaseAddressbookDataba
                // Search for free hash
                while (isUsed) {
                        // Generate hash, there is already in UserUtils a nice method that can be used for this purpose.
-                       hash = UserUtils.encryptPassword(String.format("%s:%s", emailAddress.getEmailAddress(), emailAddress.toString())); //NOI18N
+                       hash = UserUtils.encryptPassword(String.format("%s:%s", emailAddressChange.getEmailAddress(), emailAddressChange.toString())); //NOI18N
 
                        // The hash *may* be unique, better test it
                        Query query = this.getEntityManager().createNamedQuery("SearchEmailChangeByHash", EmailAddressChange.class); //NOI18N
@@ -238,7 +241,7 @@ public class AddressbookUserEmailChangeSessionBean extends BaseAddressbookDataba
                assert (!hash.isEmpty()) : "hash is empty"; //NOI18N
 
                // Set it in email change
-               emailAddress.setEmailChangeHash(hash);
+               emailAddressChange.setEmailChangeHash(hash);
        }
 
 }