protected void chooseEntity(EntityPanel panel, AddUserForm form, ActionMessages errors, HttpServletRequest request, HttpServletResponse response)
{
if (log.isDebugEnabled())
log.debug("add calendar for user with ID: " + form.getId());
UserVO user = new UserDAO().getById(form.getId());
if (user == null || user.getCalendar() == null)
{
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("default.error.invalidEntity", form.getId()));
log.error("problems loading calendar for user (ID:" + form.getId() + ")");
}
else
{
EventVO event = (EventVO) panel.getEntity();
EventCalendarVO eventCalendar = new EventCalendarVO();
eventCalendar.setEvent(event);
eventCalendar.setCalendar(user.getCalendar());
eventCalendar.setInvitationStatus(EventCalendarVO.InvitationStatus.NEW);
eventCalendar.setParticipiantType(EventCalendarVO.ParticipiantType.GUEST);
eventCalendar.setOwnerUser(user.getCalendar().getOwnerUser());
eventCalendar.setOwnerGroup(user.getCalendar().getOwnerGroup());
eventCalendar.setAccessUser(user.getCalendar().getAccessUser());
eventCalendar.setAccessGroup(user.getCalendar().getAccessGroup());
eventCalendar.setAccessGlobal(user.getCalendar().getAccessGlobal());
if (!event.getEventCalendars().contains(eventCalendar))
event.getEventCalendars().add(eventCalendar);
}
}