* @param password
*/
@Transactional
public Account createNewUser(String name, String email, String password,
String firstName, String lastName, String role) {
Account account = loadAccountByUserName(name);
if (account == null) {
account = new Account();
Role r = loadOrCreateRole(role);
account.addRole(r);
account.setUserName(name);
account.setEmail(email);
account.setFirstName(firstName);
account.setLastName(lastName);
Person userProf = new Person();
userProf.setRole(UserRole.MEMBER);
userProf.setLinkedAccount(account);
account.setUserProfile(userProf);
getAccountDAO().persist(account);
// now update password once we have the account created (we need the
// ID to have been generated)
account.setAndEncodePassword(password);
// account = getAccountDAO().merge(account);
}
return account;
}