Search in sources :

Example 1 with GetSpecialCalendarResult

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;
}
Also used : BwCalendar(org.bedework.calfacade.BwCalendar) GetSpecialCalendarResult(org.bedework.calcorei.CoreCalendarsI.GetSpecialCalendarResult) BwPreferences(org.bedework.calfacade.svc.BwPreferences) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 2 with GetSpecialCalendarResult

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();
}
Also used : GetSpecialCalendarResult(org.bedework.calcorei.CoreCalendarsI.GetSpecialCalendarResult)

Aggregations

GetSpecialCalendarResult (org.bedework.calcorei.CoreCalendarsI.GetSpecialCalendarResult)2 BwCalendar (org.bedework.calfacade.BwCalendar)1 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)1 BwPreferences (org.bedework.calfacade.svc.BwPreferences)1