use of org.bedework.webdav.servlet.shared.WebdavBadRequest 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.webdav.servlet.shared.WebdavBadRequest 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.webdav.servlet.shared.WebdavBadRequest in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method getRrm.
private RecurringRetrievalMode getRrm(final RetrievalMode rm) throws WebdavException {
if (rm == null) {
return RecurringRetrievalMode.overrides;
}
try {
if (rm.getExpand() != null) {
/* expand with time range */
ExpandType ex = rm.getExpand();
DateTime s = new DateTime(XcalUtil.getIcalFormatDateTime(ex.getStart()));
DateTime e = new DateTime(XcalUtil.getIcalFormatDateTime(ex.getEnd()));
return new RecurringRetrievalMode(Rmode.expanded, getBwDt(s), getBwDt(e));
}
if (rm.getLimitRecurrenceSet() != null) {
/* Only return master event and overrides in range */
LimitRecurrenceSetType l = rm.getLimitRecurrenceSet();
DateTime s = new DateTime(XcalUtil.getIcalFormatDateTime(l.getStart()));
DateTime e = new DateTime(XcalUtil.getIcalFormatDateTime(l.getEnd()));
return new RecurringRetrievalMode(Rmode.overrides, getBwDt(s), getBwDt(e));
}
} catch (Throwable t) {
throw new WebdavBadRequest(CaldavTags.validFilter, "Invalid time-range");
}
/* Return master + overrides */
return RecurringRetrievalMode.overrides;
}
use of org.bedework.webdav.servlet.shared.WebdavBadRequest in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method doNoteHeader.
/* ====================================================================
* Private methods
* ==================================================================== */
private String doNoteHeader(final String hdr, final String account) throws WebdavException {
if (hdr == null) {
return account;
}
try {
final String[] hparts = hdr.split(":");
if (hparts.length != 2) {
throw new WebdavBadRequest();
}
final String id = hparts[0];
final NotificationProperties nprops = configs.getNotificationProps();
final String token = hparts[1];
if (id == null) {
throw new WebdavBadRequest();
}
if (!id.equals(nprops.getNotifierId()) || (token == null) || !token.equals(nprops.getNotifierToken())) {
throw new WebdavBadRequest();
}
if (account != null) {
return account;
}
return id;
} catch (final WebdavException wde) {
throw wde;
} catch (final Throwable t) {
throw new WebdavException(t);
}
}
use of org.bedework.webdav.servlet.shared.WebdavBadRequest in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method requestFreeBusy.
@Override
public Collection<SchedRecipientResult> requestFreeBusy(final CalDAVEvent val, final boolean iSchedule) throws WebdavException {
try {
ScheduleResult sr;
BwEvent ev = getEvent(val);
if (currentPrincipal != null) {
ev.setOwnerHref(currentPrincipal.getPrincipalRef());
}
if (Icalendar.itipReplyMethodType(ev.getScheduleMethod())) {
sr = getSvci().getScheduler().scheduleResponse(getEvinfo(val));
} else {
sr = getSvci().getScheduler().schedule(getEvinfo(val), null, null, iSchedule);
}
return checkStatus(sr);
} catch (CalFacadeAccessException cfae) {
if (debug) {
error(cfae);
}
throw new WebdavForbidden();
} catch (CalFacadeException cfe) {
if (CalFacadeException.duplicateGuid.equals(cfe.getMessage())) {
throw new WebdavBadRequest("Duplicate-guid");
}
throw new WebdavException(cfe);
} catch (WebdavException wde) {
throw wde;
} catch (Throwable t) {
throw new WebdavException(t);
}
}
Aggregations