protected void chooseEntity(EntityPanel panel, AddUserForm form, ActionMessages errors, HttpServletRequest request, HttpServletResponse response)
{
if (log.isDebugEnabled())
log.debug("add user with ID: " + form.getId());
UserVO user = new UserDAO().getById(form.getId());
if (user == null)
{
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("default.error.invalidEntity", new Integer(form.getId())));
log.error("problems loading user (ID:" + form.getId() + ")");
}
else
{
CompanyVO company = (CompanyVO) panel.getEntity();
if(!EntityAccessUtility.isAccessGranted(user, company, EntityAccess.Access.WRITE))
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("module.generic.pageSystem.error.missingWriteAccessForAssignedUser", user.getUserName()));
else
company.setAssignedUser(user);
}
}