Search in sources :

Example 26 with EventInfo

use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.

the class BwCalDAVEvent method getEvinfo.

/* ====================================================================
   *                      Private methods
   * ==================================================================== */
EventInfo getEvinfo() throws WebdavException {
    if (evi == null) {
        evi = new EventInfo(new BwEventObj());
        ev = evi.getEvent();
    }
    return evi;
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) BwEventObj(org.bedework.calfacade.BwEventObj)

Example 27 with EventInfo

use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.

the class BwSysIntfImpl method validateAlarm.

/**
 * Validate an alarm component
 *
 * @param val
 * @return boolean false for failure
 * @throws WebdavException
 */
@Override
public boolean validateAlarm(final String val) throws WebdavException {
    try {
        // Ensure open
        getSvci();
        StringReader sr = new StringReader(ValidateAlarmPrefix + val + ValidateAlarmSuffix);
        Icalendar ic = trans.fromIcal(null, sr);
        if ((ic == null) || (ic.getEventInfo() == null)) {
            if (debug) {
                debug("Not single event");
            }
            return false;
        }
        /* There should be alarms in the Calendar object
       */
        EventInfo ei = ic.getEventInfo();
        BwEvent ev = ei.getEvent();
        if ((ev.getAlarms() == null) || ev.getAlarms().isEmpty()) {
            return false;
        }
        return true;
    } catch (CalFacadeException cfe) {
        if (debug) {
            error(cfe);
        }
        return false;
    }
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) Icalendar(org.bedework.icalendar.Icalendar) SysiIcalendar(org.bedework.caldav.server.SysiIcalendar) StringReader(java.io.StringReader) BwEvent(org.bedework.calfacade.BwEvent) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 28 with EventInfo

use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.

the class BwSysIntfImpl method getEvents.

@Override
public Collection<CalDAVEvent> getEvents(final CalDAVCollection col, final FilterBase filter, final List<String> retrieveList, final RetrievalMode recurRetrieval) throws WebdavException {
    try {
        /* Limit the results to just this collection by adding an ANDed filter */
        final SimpleFilterParser sfp = getSvci().getFilterParser();
        final String expr = "(colPath='" + SfpTokenizer.escapeQuotes(col.getPath()) + "')";
        final ParseResult pr = sfp.parse(expr, true, null);
        if (!pr.ok) {
            throw new WebdavBadRequest("Failed to reference collection " + col.getPath() + ": message was " + pr.message);
        }
        final FilterBase f = FilterBase.addAndChild(filter, pr.filter);
        final Collection<EventInfo> bwevs = // Collection
        getSvci().getEventsHandler().getEvents(// Collection
        null, f, // start
        null, // end
        null, RetrieveList.getRetrieveList(retrieveList), DeletedState.noDeleted, getRrm(recurRetrieval));
        if (bwevs == null) {
            return null;
        }
        final Collection<CalDAVEvent> evs = new ArrayList<>();
        for (final EventInfo ei : bwevs) {
            if (recurRetrieval != null) {
                ei.getEvent().setForceUTC(recurRetrieval.getExpand() != null);
            }
            evs.add(new BwCalDAVEvent(this, ei));
        }
        return evs;
    } catch (final CalFacadeAccessException cfae) {
        throw new WebdavForbidden();
    } catch (final CalFacadeException cfe) {
        if (CalFacadeException.unknownProperty.equals(cfe.getMessage())) {
            throw new WebdavBadRequest("Unknown property " + cfe.getExtra());
        }
        throw new WebdavException(cfe);
    } catch (final WebdavException wde) {
        throw wde;
    } catch (final Throwable t) {
        throw new WebdavException(t);
    }
}
Also used : WebdavBadRequest(org.bedework.webdav.servlet.shared.WebdavBadRequest) ParseResult(org.bedework.calfacade.filter.SimpleFilterParser.ParseResult) EventInfo(org.bedework.calfacade.svc.EventInfo) WebdavForbidden(org.bedework.webdav.servlet.shared.WebdavForbidden) ArrayList(java.util.ArrayList) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) SimpleFilterParser(org.bedework.calfacade.filter.SimpleFilterParser) CalFacadeAccessException(org.bedework.calfacade.exc.CalFacadeAccessException) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) CalDAVEvent(org.bedework.caldav.server.CalDAVEvent) FilterBase(org.bedework.caldav.util.filter.FilterBase)

Example 29 with EventInfo

use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.

the class BwSysIntfImpl method updateEvent.

@Override
public UpdateResult updateEvent(final CalDAVEvent event, final List<ComponentSelectionType> updates) throws WebdavException {
    try {
        EventInfo ei = getEvinfo(event);
        if (updates == null) {
            return new UpdateResult("No updates");
        }
        UpdateResult ur = new BwUpdates(getPrincipal().getPrincipalRef()).updateEvent(ei, updates, getSvci().getIcalCallback());
        if (!ur.getOk()) {
            getSvci().rollbackTransaction();
            return ur;
        }
        getSvci().getEventsHandler().update(ei, false);
        return ur;
    } catch (CalFacadeAccessException cfae) {
        throw new WebdavForbidden();
    } catch (CalFacadeForbidden cff) {
        throw new WebdavForbidden(cff.getQname(), cff.getMessage());
    } catch (CalFacadeException cfe) {
        if (CalFacadeException.duplicateGuid.equals(cfe.getMessage())) {
            throw new WebdavBadRequest("Duplicate-guid");
        }
        throw new WebdavException(cfe);
    } catch (Throwable t) {
        throw new WebdavException(t);
    }
}
Also used : WebdavBadRequest(org.bedework.webdav.servlet.shared.WebdavBadRequest) EventInfo(org.bedework.calfacade.svc.EventInfo) WebdavForbidden(org.bedework.webdav.servlet.shared.WebdavForbidden) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) CalFacadeForbidden(org.bedework.calfacade.exc.CalFacadeForbidden) CalFacadeAccessException(org.bedework.calfacade.exc.CalFacadeAccessException) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 30 with EventInfo

use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.

the class BwUpdates method match.

/* Return matching entities. */
private List<EventInfo> match(final List<EventInfo> eis, // final SelectElementType sel,
final BaseComponentType selComp) throws WebdavException {
    List<EventInfo> matched = new ArrayList<EventInfo>();
    CompSelector cs = getCompSelector(selComp);
    for (EventInfo ei : eis) {
        if ((cs.uid == null) && (cs.recurrenceId == null)) {
            /* Only valid for a single non-recurring entity */
            if (ei.getEvent().isRecurringEntity() || (eis.size() > 1)) {
                return null;
            }
            matched.add(ei);
            return matched;
        }
        // matched.addAll(ei.getOverrideProxies());
        if (cs.uid == null) {
            // Not valid
            return null;
        }
        BwEvent ev = ei.getEvent();
        // UID must match
        if (!cs.uid.equals(ev.getUid())) {
            continue;
        }
        if (cs.recurrenceId == null) {
            // if ((ev.getRecurrenceId() == null) || sel.isAll()) {
            if (ev.getRecurrenceId() == null) {
                matched.add(ei);
            }
            continue;
        }
        // Looking for override
        if ((ev.getRecurrenceId() != null) && ev.getRecurrenceId().equals(cs.recurrenceId.getDate())) {
            matched.add(ei);
            continue;
        }
    }
    return matched;
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) ArrayList(java.util.ArrayList) BwEvent(org.bedework.calfacade.BwEvent)

Aggregations

EventInfo (org.bedework.calfacade.svc.EventInfo)111 BwEvent (org.bedework.calfacade.BwEvent)80 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)37 BwCalendar (org.bedework.calfacade.BwCalendar)27 BwEventProxy (org.bedework.calfacade.BwEventProxy)24 BwAttendee (org.bedework.calfacade.BwAttendee)19 ArrayList (java.util.ArrayList)16 CoreEventInfo (org.bedework.calcorei.CoreEventInfo)15 BwEventAnnotation (org.bedework.calfacade.BwEventAnnotation)15 BwString (org.bedework.calfacade.BwString)11 BwDateTime (org.bedework.calfacade.BwDateTime)10 BwEventObj (org.bedework.calfacade.BwEventObj)10 TreeSet (java.util.TreeSet)9 BwXproperty (org.bedework.calfacade.BwXproperty)9 BwPrincipal (org.bedework.calfacade.BwPrincipal)7 CalFacadeAccessException (org.bedework.calfacade.exc.CalFacadeAccessException)7 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)7 Calendar (net.fortuna.ical4j.model.Calendar)6 Period (net.fortuna.ical4j.model.Period)6 BwOrganizer (org.bedework.calfacade.BwOrganizer)6