+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
+
+ // user should not be null
+ if (null == user) {
+ // Abort here
+ throw new NullPointerException("user is null"); //NOI18N
+ } else if (user.getUserId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("user.userId is null"); //NOI18N
+ } else if (user.getUserId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N
+ } else if (user.getUserAccountStatus() == null) {
+ // Throw NPE again
+ throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
+ } else if (!this.ifUserExists(user)) {
+ // User does not exist
+ throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
+ }
+
+ // 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
+
+ // 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 updated
+ detachedUser.setUserUpdated(new GregorianCalendar());
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: detachedUser={1} - CALLED!", this.getClass().getSimpleName(), detachedUser)); //NOI18N
+
+ // Return updated instance
+ return detachedUser;
+ }
+
+ @Override
+ public PasswordHistory updateUserPassword (final User user) throws UserNotFoundException, UserStatusUnconfirmedException, UserStatusLockedException {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
+
+ // user should not be null
+ if (null == user) {
+ // Abort here
+ throw new NullPointerException("user is null"); //NOI18N
+ } else if (user.getUserId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("user.userId is null"); //NOI18N
+ } else if (user.getUserId() < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
+ } else if (user.getUserAccountStatus() == null) {
+ // Throw NPE again
+ throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
+ } else if (!this.ifUserExists(user)) {
+ // User does not exist
+ throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
+ }
+
+ // Call other method
+ User updatedUser = this.updateUserData(user);
+
+ // Create history entry
+ PasswordHistory entry = new UserPasswordHistory(user.getUserEncryptedPassword(), updatedUser);
+
+ // Set created timestamp
+ entry.setUserPasswordHistoryCreated(new GregorianCalendar());
+
+ // Persist it
+ this.getEntityManager().persist(entry);
+
+ // Flush it to get id number back
+ this.getEntityManager().flush();
+
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPassword: entry.userPasswordHistoryId={1} - EXIT!", this.getClass().getSimpleName(), entry.getUserPasswordHistoryId())); //NOI18N
+
+ // Return it
+ return entry;
+ }
+
+ @Override
+ public User updateUserPersonalData (final User user) {
+ // Trace message
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserPersonalData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N