use of org.bedework.calfacade.exc.CalFacadeException in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method updateQuota.
boolean updateQuota(final AccessPrincipal principal, final long inc) throws WebdavException {
try {
BwPrincipal p = getSvci().getUsersHandler().getPrincipal(principal.getPrincipalRef());
if (p == null) {
// No quota - fail
return false;
}
if (p.getKind() != WhoDefs.whoTypeUser) {
// No quota - fail
return false;
}
BwPreferences prefs = getPrefs();
long used = prefs.getQuotaUsed() + inc;
prefs.setQuotaUsed(used);
getSvci().getUsersHandler().update(p);
return // Decreasing usage - let it pass
(inc < 0) || (used <= p.getQuota());
} catch (CalFacadeException cfe) {
throw new WebdavException(cfe);
}
}
use of org.bedework.calfacade.exc.CalFacadeException 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.exc.CalFacadeException 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.exc.CalFacadeException in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method getCollection.
/* (non-Javadoc)
* @see org.bedework.caldav.server.SysIntf#getCollection(java.lang.String)
*/
@Override
public CalDAVCollection getCollection(final String path) throws WebdavException {
try {
BwCalendar col = getSvci().getCalendarsHandler().get(path);
if (col == null) {
return null;
}
getSvci().getCalendarsHandler().resolveAlias(col, true, false);
return new BwCalDAVCollection(this, col);
} catch (CalFacadeAccessException cfae) {
throw new WebdavForbidden();
} catch (CalFacadeException cfe) {
throw new WebdavException(cfe);
} catch (Throwable t) {
throw new WebdavException(t);
}
}
use of org.bedework.calfacade.exc.CalFacadeException 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