+ // Trace message
+ //* NOISY-DEBUG: */ System.out.println("UserWebBean:afterRegistration: EXIT!"); //NOI18N
+ }
+
+ @Override
+ public String editUserData () {
+ // Get user instance
+ User user = this.beanHelper.getUser();
+
+ // Null password means not setting it
+ String encryptedPassword = null;
+
+ // Check if user instance is in helper and valid
+ if (null == user) {
+ // Throw NPE
+ throw new NullPointerException("beanHelper.user is null"); //NOI18N
+ } else if (user.getUserId() == null) {
+ // Throw NPE again
+ throw new NullPointerException("beanHelper.user.userId is null"); //NOI18N //NOI18N
+ } else if (user.getUserId() < 1) {
+ // Invalid id
+ throw new IllegalStateException(MessageFormat.format("beanHelper.user.userId={0} is invalid", user.getUserId())); //NOI18N
+ } else if (this.getUserName() == null) {
+ // Not all required fields are set
+ throw new NullPointerException("this.userName is null"); //NOI18N
+ } else if (this.getUserName().isEmpty()) {
+ // Not all required fields are set
+ throw new IllegalArgumentException("this.userName is empty"); //NOI18N
+ } else if (((!this.getUserPassword().isEmpty()) || (!this.getUserPasswordRepeat().isEmpty())) && (!this.isSamePasswordEntered())) {
+ // Not same password entered
+ this.setUserPassword(null);
+ this.setUserPasswordRepeat(null);
+
+ // Throw exception
+ throw new FaceletException("Not same password entered"); //NOI18N
+ } else if (this.userBean.ifUserNameExists(this.getUserName())) {
+ // User name already exists
+ throw new FaceletException(new UserNameAlreadyRegisteredException(this.getUserName()));
+ } else if (this.isSamePasswordEntered()) {
+ // Same password entered, create container
+ if (UserUtils.ifPasswordMatches(new UserLoginContainer(user, this.getUserPassword()))) {
+ // Same password entered
+ throw new FaceletException("Same password as stored entered."); //NOI18N
+ }
+
+ // Encrypt password
+ encryptedPassword = UserUtils.encryptPassword(this.getUserPassword());
+ }
+
+ // Set user name and flag
+ user.setUserName(this.getUserName());
+ user.setUserMustChangePassword(this.getUserMustChangePassword());
+
+ // Is a password set?
+ if (encryptedPassword != null) {
+ // Set it as well
+ user.setUserEncryptedPassword(encryptedPassword);
+ }
+
+ // Call EJB for updating user data
+ User updatedUser = this.userBean.updateUserData(user);
+
+ // Fire event
+ this.updatedUserDataEvent.fire(new AdminUserDataUpdatedEvent(updatedUser));
+
+ // Return to user list (for now)
+ return "admin_list_user"; //NOI18N
+ }
+
+ @Override
+ public String getUserLockReason () {
+ return this.userLockReason;