// Loop until a user name is found
while ((userName == null) || (userList.contains(userName))) {
// Generate random name
- userName = UserUtils.generateRandomUserName();
+ userName = Users.generateRandomUserName();
}
// Trace message
}
@Override
- public User updateUserData (final User user) {
+ public User updateUserData (final User detachedUser) {
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: detachedUser={1} - CALLED!", this.getClass().getSimpleName(), detachedUser)); //NOI18N
// user should not be null
- if (null == user) {
+ if (null == detachedUser) {
// Abort here
- throw new NullPointerException("user is null"); //NOI18N
- } else if (user.getUserId() == null) {
+ throw new NullPointerException("detachedUser is null"); //NOI18N
+ } else if (detachedUser.getUserId() == null) {
// Throw NPE again
- throw new NullPointerException("user.userId is null"); //NOI18N
- } else if (user.getUserId() < 1) {
+ throw new NullPointerException("detachedUser.userId is null"); //NOI18N
+ } else if (detachedUser.getUserId() < 1) {
// Not valid
- throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
- } else if (user.getUserAccountStatus() == null) {
+ throw new IllegalArgumentException(MessageFormat.format("detachedUser.userId={0} is not valid", detachedUser.getUserId())); //NOI18N
+ } else if (detachedUser.getUserAccountStatus() == null) {
// Throw NPE again
- throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
- } else if (!this.ifUserExists(user)) {
+ throw new NullPointerException("detachedUser.userAccountStatus is null"); //NOI18N
+ } else if (!this.ifUserExists(detachedUser)) {
// User does not exist
- throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
+ throw new EJBException(MessageFormat.format("User with id {0} does not exist.", detachedUser.getUserId())); //NOI18N
}
// Find the instance
- final User foundUser = this.getEntityManager().find(user.getClass(), user.getUserId());
+ final User foundUser = this.getEntityManager().find(detachedUser.getClass(), detachedUser.getUserId());
// Should be found!
- assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
+ assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", detachedUser.getUserId()); //NOI18N
// Merge user
final User managedUser = this.getEntityManager().merge(foundUser);
assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not merged, but should be.", managedUser.getUserId()); //NOI18N
// Copy all data
- UserUtils.copyAll(user, managedUser);
+ Users.copyAll(detachedUser, managedUser);
// Set as updated
managedUser.setUserUpdated(new Date());
assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
// Copy all data
- UserUtils.copyAll(user, managedUser);
+ Users.copyAll(user, managedUser);
// Set as updated
managedUser.setUserUpdated(new Date());