Search in sources :

Example 1 with InstancesResponse

use of org.bedework.calfacade.responses.InstancesResponse in project bw-calendar-engine by Bedework.

the class Events method getInstances.

@Override
public InstancesResponse getInstances(final GetInstancesRequest req) {
    final InstancesResponse resp = new InstancesResponse();
    resp.setId(req.getId());
    if (!req.validate(resp)) {
        return resp;
    }
    // Use a BwEvent to build the instance set
    final BwEvent ev = new BwEventObj();
    try {
        final BwDateTime st = req.getStartDt();
        ev.setDtstart(st);
        ev.setDtend(req.getEndDt());
        ev.addRrule(req.getRrule());
        if (!Util.isEmpty(req.getExdates())) {
            for (final String dt : req.getExdates()) {
                ev.addExdate(BwDateTime.makeBwDateTime(st.getDateType(), dt, st.getTzid()));
            }
        }
        if (!Util.isEmpty(req.getRdates())) {
            for (final String dt : req.getRdates()) {
                ev.addRdate(BwDateTime.makeBwDateTime(st.getDateType(), dt, st.getTzid()));
            }
        }
        final RecurPeriods rp = RecurUtil.getPeriods(ev, getAuthpars().getMaxYears(), getAuthpars().getMaxInstances(), req.getBegin(), req.getEnd());
        resp.setInstances(rp.instances);
        return resp;
    } catch (final Throwable t) {
        return Response.error(resp, t);
    }
}
Also used : BwDateTime(org.bedework.calfacade.BwDateTime) BwEvent(org.bedework.calfacade.BwEvent) InstancesResponse(org.bedework.calfacade.responses.InstancesResponse) RecurPeriods(org.bedework.icalendar.RecurUtil.RecurPeriods) BwEventObj(org.bedework.calfacade.BwEventObj)

Aggregations

BwDateTime (org.bedework.calfacade.BwDateTime)1 BwEvent (org.bedework.calfacade.BwEvent)1 BwEventObj (org.bedework.calfacade.BwEventObj)1 InstancesResponse (org.bedework.calfacade.responses.InstancesResponse)1 RecurPeriods (org.bedework.icalendar.RecurUtil.RecurPeriods)1