use of org.bedework.calfacade.filter.SimpleFilterParser 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);
}
}
use of org.bedework.calfacade.filter.SimpleFilterParser in project bw-calendar-engine by Bedework.
the class Events method get.
@Override
public EventInfo get(final BwCalendar col, final String name, final String recurrenceId, final List<String> retrieveList) throws CalFacadeException {
if ((col == null) || (name == null)) {
throw new CalFacadeException(CalFacadeException.badRequest);
}
if (col.getInternalAlias()) {
final String expr = "(vpath='" + SfpTokenizer.escapeQuotes(col.getPath()) + "') and (name='" + SfpTokenizer.escapeQuotes(name) + "')";
final SimpleFilterParser sfp = getSvc().getFilterParser();
final ParseResult pr = sfp.parse(expr, true, null);
if (!pr.ok) {
throw new CalFacadeException("Failed to parse " + expr + ": message was " + pr.message);
}
final Collection<EventInfo> evs = getEvents(null, pr.filter, // start
null, // end
null, RetrieveList.getRetrieveList(retrieveList), DeletedState.noDeleted, RecurringRetrievalMode.overrides);
if (evs.size() == 0) {
return null;
}
if (evs.size() == 1) {
return evs.iterator().next();
}
throw new CalFacadeException("Multiple results");
}
String path = col.getPath();
if (col.getCalType() == BwCalendar.calTypeEventList) {
/* Find the event in the list using the name */
final SortedSet<EventListEntry> eles = col.getEventList();
findHref: {
for (final EventListEntry ele : eles) {
if (ele.getName().equals(name)) {
path = ele.getPath();
break findHref;
}
}
// Not in list
return null;
}
// findHref
}
return get(path, name, null);
}
Aggregations