]> git.mxchange.org Git - pizzaservice-mailer-ejb.git/commitdiff
Tried to fix: (please cherry-pick)
authorRoland Häder <roland@mxchange.org>
Thu, 11 Aug 2016 12:26:39 +0000 (14:26 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 16 Aug 2016 19:42:53 +0000 (21:42 +0200)
- update all data in user instance and hande it over to updateUserData()

src/java/org/mxchange/jusercore/model/user/AddressbookAdminUserSessionBean.java

index 5b2e102c51e25484333a70f44b7a030b7ae50d6d..c9853a4686b7a107f71acaa11bd5cc05cc9d6530 100644 (file)
@@ -207,25 +207,10 @@ public class AddressbookAdminUserSessionBean extends BaseAddressbookDatabaseBean
                // Remove contact instance as this is not updated
                user.setUserContact(null);
 
-               // Find the instance
-               User foundUser = this.getEntityManager().find(user.getClass(), user.getUserId());
-
-               // Should be found!
-               assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
-
-               // Copy all data
-               foundUser.copyAll(user);
-
-               // Set as locked
-               foundUser.setUserAccountStatus(UserAccountStatus.LOCKED);
-               foundUser.setUserLastLocked(new GregorianCalendar());
-               foundUser.setUserLastLockedReason(userLockReason);
-
-               // Merge user
-               User detachedUser = this.getEntityManager().merge(foundUser);
-
-               // Should be found!
-               assert (detachedUser instanceof User) : MessageFormat.format("User with id {0} not merged, but should be.", user.getUserId()); //NOI18N
+               // Set as locked, set timestamp and lock reason
+               user.setUserAccountStatus(UserAccountStatus.LOCKED);
+               user.setUserLastLocked(new GregorianCalendar());
+               user.setUserLastLockedReason(userLockReason);
 
                // Update user
                User updatedUser = this.userBean.updateUserData(user);
@@ -247,10 +232,10 @@ public class AddressbookAdminUserSessionBean extends BaseAddressbookDatabaseBean
                this.sendEmail("Account locked", "account_locked", emailAddress, updatedUser, baseUrl); //NOI18N
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.lockUserAccount: detachedUser={1} - EXIT!", this.getClass().getSimpleName(), detachedUser)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.lockUserAccount: updatedUser={1} - EXIT!", this.getClass().getSimpleName(), updatedUser)); //NOI18N
 
                // Return detached (and updated) user
-               return detachedUser;
+               return updatedUser;
        }
 
        @Override
@@ -294,23 +279,8 @@ public class AddressbookAdminUserSessionBean extends BaseAddressbookDatabaseBean
                // Remove contact instance as this is not updated
                user.setUserContact(null);
 
-               // Find the instance
-               User foundUser = this.getEntityManager().find(user.getClass(), user.getUserId());
-
-               // Should be found!
-               assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
-
-               // Copy all data
-               foundUser.copyAll(user);
-
                // Unlock account
-               foundUser.setUserAccountStatus(UserAccountStatus.CONFIRMED);
-
-               // Merge user
-               User detachedUser = this.getEntityManager().merge(foundUser);
-
-               // Should be found!
-               assert (detachedUser instanceof User) : MessageFormat.format("User with id {0} not merged, but should be.", user.getUserId()); //NOI18N
+               user.setUserAccountStatus(UserAccountStatus.CONFIRMED);
 
                // Update user
                User updatedUser = this.userBean.updateUserData(user);
@@ -332,10 +302,10 @@ public class AddressbookAdminUserSessionBean extends BaseAddressbookDatabaseBean
                this.sendEmail("Account unlocked", "account_unlocked", emailAddress, updatedUser, baseUrl); //NOI18N
 
                // Trace message
-               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.lockUserAccount: detachedUser={1} - EXIT!", this.getClass().getSimpleName(), detachedUser)); //NOI18N
+               this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.lockUserAccount: updatedUser={1} - EXIT!", this.getClass().getSimpleName(), updatedUser)); //NOI18N
 
                // Return changed account
-               return detachedUser;
+               return updatedUser;
        }
 
 }