use of org.bedework.calcorei.CoreCalendarsI.GetSpecialCalendarResult in project bw-calendar-engine by Bedework.
the class Events method validate.
private BwCalendar validate(final BwEvent ev, final boolean adding, final boolean schedulingInbox, final boolean autoCreateCollection) throws CalFacadeException {
if (ev.getColPath() == null) {
throw new CalFacadeException(CalFacadeException.noEventCalendar);
}
if (ev.getNoStart() == null) {
throw new CalFacadeException(CalFacadeException.missingEventProperty, "noStart");
}
if (ev.getDtstart() == null) {
throw new CalFacadeException(CalFacadeException.missingEventProperty, "dtstart");
}
if (ev.getDtend() == null) {
throw new CalFacadeException(CalFacadeException.missingEventProperty, "dtend");
}
if (ev.getDuration() == null) {
throw new CalFacadeException(CalFacadeException.missingEventProperty, "duration");
}
if (ev.getRecurring() == null) {
throw new CalFacadeException(CalFacadeException.missingEventProperty, "recurring");
}
setScheduleState(ev, adding, schedulingInbox);
BwCalendar col = getCols().get(ev.getColPath());
if (col == null) {
if (!autoCreateCollection) {
throw new CalFacadeException(CalFacadeException.collectionNotFound);
}
// TODO - need a configurable default display name
// TODO - this all needs a rework
final String entityType = IcalDefs.entityTypeIcalNames[ev.getEntityType()];
final int calType;
switch(entityType) {
case Component.VEVENT:
calType = BwCalendar.calTypeCalendarCollection;
break;
case Component.VTODO:
calType = BwCalendar.calTypeTasks;
break;
case Component.VPOLL:
calType = BwCalendar.calTypePoll;
break;
default:
return null;
}
final GetSpecialCalendarResult gscr = getCal().getSpecialCalendar(getPrincipal(), calType, true, PrivilegeDefs.privAny);
col = gscr.cal;
}
Preferences prefs = null;
if (getPars().getPublicAdmin() && !getPars().getService()) {
prefs = (Preferences) getSvc().getPrefsHandler();
prefs.updateAdminPrefs(false, col, ev.getCategories(), ev.getLocation(), ev.getContact());
}
return col;
}
use of org.bedework.calcorei.CoreCalendarsI.GetSpecialCalendarResult in project bw-calendar-engine by Bedework.
the class Calendars method getPreferred.
@Override
public String getPreferred(final String entityType) throws CalFacadeException {
final int calType;
switch(entityType) {
case Component.VEVENT:
final String path = getSvc().getPrefsHandler().get().getDefaultCalendarPath();
if (path != null) {
return path;
}
calType = BwCalendar.calTypeCalendarCollection;
break;
case Component.VTODO:
calType = BwCalendar.calTypeTasks;
break;
case Component.VPOLL:
calType = BwCalendar.calTypePoll;
break;
default:
return null;
}
final GetSpecialCalendarResult gscr = getCal().getSpecialCalendar(getPrincipal(), calType, true, PrivilegeDefs.privAny);
return gscr.cal.getPath();
}
Aggregations