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