@Override
protected boolean validateData(EditPanel panel, ActionMessages errors, HttpServletRequest request)
{
UserVO user = (UserVO) request.getSession().getAttribute(Globals.USER_KEY);
EventVO event = (EventVO) panel.getAttribute("event");
CalendarVO calendar = (CalendarVO) panel.getAttribute("calendar");
EntityAccess testEntity = null;
if (event.getId() == null)
testEntity = calendar;
else {
EventCalendarVO myEventCalendar = null;
for(EventCalendarVO eventCalendar : event.getEventCalendars()) {
if(calendar.equals(eventCalendar.getCalendar())) {
testEntity = eventCalendar;
break;
}
}
}
if (!EntityAccessUtility.isAccessGranted(user, testEntity, EntityAccess.Access.WRITE))
errors.add("globalAccess", new ActionMessage("default.error.noEntityAccess"));
if(event.isOccupied()) { // validiere Termin, wenn dieser besetzt ist
for(EventCalendarVO eventCalendar : event.getEventCalendars()) { // pr�fe jeden Kalender, von dem es Beteiligte gibt
if(log.isDebugEnabled())
log.debug("validate calendar with id="+eventCalendar.getCalendar().getId());
EventBeanCalculator calc = new EventBeanCalculator(eventCalendar.getCalendar(), event.getStartDate(), event.getEndDate());
for(EventBean eventBean : calc.getEventBeans()) {
if(!eventBean.getEvent().equals(event)
&& eventBean.getEvent().isOccupied()
&& isEventValid(eventBean.getEvent(), eventCalendar.getCalendar())) { // mu� der Termin gepr�ft werden? (abgelehnte und gel�schte interessieren nicht)
if(DateUtility.isMatching(eventBean.getStartDate(), eventBean.getEndDate(), event.getStartDate(), event.getEndDate())) {
if(eventCalendar.getCalendar().getUser() != null) {
if(eventCalendar.getCalendar().getUser().equals(user)) {
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("module.calendar.event.error.isOccupied"));
} else {
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("module.calendar.event.error.userIsOccupied", eventCalendar.getCalendar().getUser().getUserName()));