}
@Override
- public void lockUserAccount (final User user, final String userLockReason, final String baseUrl) throws UserStatusLockedException, UserStatusUnconfirmedException, UserNotFoundException {
+ public User lockUserAccount (final User user, final String userLockReason, final String baseUrl) throws UserStatusLockedException, UserStatusUnconfirmedException, UserNotFoundException {
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.lockUserAccount: user={1},userLockReason={2},baseUrl={3} - CALLED!", this.getClass().getSimpleName(), user, userLockReason, baseUrl)); //NOI18N
// 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
- // Copy all data
- detachedUser.copyAll(user);
-
- // Set as locked
- detachedUser.setUserAccountStatus(UserAccountStatus.LOCKED);
- detachedUser.setUserLastLocked(new GregorianCalendar());
- detachedUser.setUserLastLockedReason(userLockReason);
-
// Update user
User updatedUser = this.userBean.updateUserData(user);
this.sendEmail("Account locked", "account_locked", emailAddress, updatedUser, baseUrl); //NOI18N
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.lockUserAccount - EXIT!", this.getClass().getSimpleName())); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.lockUserAccount: detachedUser={1} - EXIT!", this.getClass().getSimpleName(), detachedUser)); //NOI18N
+
+ // Return detached (and updated) user
+ return detachedUser;
}
@Override
- public void unlockUserAccount (final User user, final String baseUrl) throws UserStatusConfirmedException, UserStatusUnconfirmedException, UserNotFoundException {
+ public User unlockUserAccount (final User user, final String baseUrl) throws UserStatusConfirmedException, UserStatusUnconfirmedException, UserNotFoundException {
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.lockUserAccount: user={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), user, baseUrl)); //NOI18N
// 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
- // Copy all data
- detachedUser.copyAll(user);
-
- // Unlock account
- detachedUser.setUserAccountStatus(UserAccountStatus.CONFIRMED);
-
// Update user
User updatedUser = this.userBean.updateUserData(user);
this.sendEmail("Account unlocked", "account_unlocked", emailAddress, updatedUser, baseUrl); //NOI18N
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.lockUserAccount - EXIT!", this.getClass().getSimpleName())); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.lockUserAccount: detachedUser={1} - EXIT!", this.getClass().getSimpleName(), detachedUser)); //NOI18N
+
+ // Return changed account
+ return detachedUser;
}
}