{
UserVO activeUser = (UserVO) request.getSession().getAttribute(Globals.USER_KEY);
boolean update = true;
// Pr�fe ob schon ein Standardkalender besteht
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);
}
String title = MessageUtil.message(request, "module.calendar.showCalendar.month.headLine")+" - ";
if(calendar.getUser().equals(activeUser)) {
title += MessageUtil.message(request, "module.calendar.personalCalendar");
} else {
title += calendar.getUser().getUserName();
}
panel.setTitle(title);
// update calendar
if (!calendar.equals(panel.getAttribute("calendar"))) {
if (log.isDebugEnabled())
log.debug("update calendar");
panel.removeAttribute("calendar");
panel.removeAttribute("calendarView");
}