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);
}
}
Aggregations