throw new UserPasswordMismatchException(this.loginController.getLoggedInUser());
}
- // Create new user instance from existing data
- User user = this.createUserInstance();
+ // Get user instance
+ User user = this.loginController.getLoggedInUser();
- // Update it from logged-in user (e.g. user and contact id)
- user.setUserId(this.loginController.getLoggedInUser().getUserId());
- user.getUserContact().setContactId(this.loginController.getLoggedInUser().getUserContact().getContactId());
+ // Update all fields
+ this.updateUserFromFields(user);
// Send it to the EJB
this.userBean.updateUserPersonalData(user);
return Collections.unmodifiableList(this.visibleUserList);
}
- @Override
- public User createUserInstance () {
- // User message
- //this.getLogger().logTrace("createUserInstance: CALLED!");
-
- // Required personal data must be set
- assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
+ /**
+ * Updates given user instance with all (updated) data from this controller
+ * <p>
+ * @param user User instance to to be updated
+ */
+ private void updateUserFromFields (final User user) {
+ // Make sure it is valid
+ if (null == user) {
+ // Throw NPE
+ throw new NullPointerException("user is null"); //NOI18N
+ }
- // Create new user instance
- User user = new LoginUser();
+ // Update all data ...
user.setUserName(this.getUserName());
user.setUserProfileMode(this.getUserProfileMode());
user.setUserCreated(new GregorianCalendar());
// Set contact in user
user.setUserContact(contact);
+ }
+
+ @Override
+ public User createUserInstance () {
+ // User message
+ //this.getLogger().logTrace("createUserInstance: CALLED!");
+
+ // Required personal data must be set
+ assert (this.isRequiredPersonalDataSet()) : "not all personal data is set"; //NOI18N
+
+ // Create new user instance
+ User user = new LoginUser();
+
+ // Update all fields
+ this.updateUserFromFields(user);
// Trace message
//this.getLogger().logTrace(MessageFormat.format("createUserInstance: user={0} - EXIT!", user));
+
// Return it
return user;
}