CalendarVO calendar = (CalendarVO) panel.getAttribute("calendar");
ActionMessages errors = getErrors(request);
if(errors.isEmpty()) {
if (form.getId() > 0) {
calendar = new CalendarDAO().getById(form.getId());
if (!EntityAccessUtility.isAccessGranted(activeUser, calendar, EntityAccess.Access.READ)) {
log.debug("user tries to access an invalid calendar");
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("default.error.invalidEntity", calendar.getId()));
calendar = null;
// refresh the user
UserVO user = (UserVO)request.getSession().getAttribute(Globals.USER_KEY);
user = new UserDAO().getById(user.getId());
if(user != null) {
request.getSession().setAttribute(Globals.USER_KEY, user);
} else {
log.info("could not reload user (may be deleted)");
}
} else {
if (log.isDebugEnabled())
log.debug("use calendar: " + calendar);
}
}
if (form.isMain() || calendar == null) {
calendar = new CalendarDAO().getForUser(activeUser);
if (log.isDebugEnabled())
log.debug("use calendar: " + calendar);
}
} else if (log.isDebugEnabled()) {
log.debug("found errors > use old calendar: " + calendar);