BusinessRuleException bre = new BusinessRuleException();
bre.addCodedMessage("seteUser.EmailAlreadyExists", new String[]{vo.getEmailAddress()});
throw bre;
}
SeteUser su = new SeteUser();
su.setFirstName(vo.getFirstName());
su.setMiddleName(vo.getMiddleName());
su.setLastName(vo.getLastName());
//do dob
SimpleDateFormat sim = new SimpleDateFormat("MM/dd/yyyy");
java.util.Date date = new java.util.Date();
try{
date = sim.parse(vo.getDateOfBirth());
su.setDateOfBirth(date);
}
catch(ParseException pe)
{
System.err.println("Invalid date recieved "+vo.getDateOfBirth());
}
su.setLoginName(vo.getLoginName());
su.setPassword(passwordEncoder.encodePassword(vo.getPassword(), null));
//contactInformation
ContactInformation ci = new ContactInformation();
ci.setAddress(vo.getAddress());
ci.setEmailAddress(vo.getEmailAddress());
ci.setPhoneNumber( vo.getPhoneNumber());
su.setContactInformation(ci);
//massage UserPrivilegeType
/* Contains all sets of Roles privilege/action mappings for User*/
Set<UserRolePrivilege> rolePrivs = new HashSet<UserRolePrivilege>();
/* Contains instance of Role and associated privilege/action mapping */
UserRolePrivilege p = new UserRolePrivilege();
p.setUserRoleType(TypeUtil.forKey(UserRoleType.class, vo.getUserRole()));
Set<UserPrivilege> privs = new HashSet<UserPrivilege>();
UserPrivilege up = null;
for(String pk: vo.getUserRolePrivileges())
{
up = new UserPrivilege();
up.setUserPrivilegeType(TypeUtil.forKey(UserPrivilegeType.class, pk));
up.setPrivilegeActionType(TypeUtil.forKey(PrivilegeActionType.class, PrivilegeActionType.READ));
privs.add(up);
}
p.setUserPrivileges(privs);
rolePrivs.add(p);
su.setUserRolePrivileges(rolePrivs);
seteUserDao.saveSeteUser(su);
}