use of org.bedework.calfacade.exc.CalFacadeAccessException in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method copyMove.
/* (non-Javadoc)
* @see org.bedework.caldav.server.SysIntf#copyMove(org.bedework.caldav.server.CalDAVCollection, org.bedework.caldav.server.CalDAVCollection, boolean, boolean)
*/
@Override
public void copyMove(final CalDAVCollection from, final CalDAVCollection to, final boolean copy, final boolean overwrite) throws WebdavException {
try {
BwCalendar bwFrom = unwrap(from);
BwCalendar bwTo = unwrap(to);
if (!copy) {
/* Move the from collection to the new location "to".
* If the parent calendar is the same in both cases, this is just a rename.
*/
if ((bwFrom.getColPath() == null) || (bwTo.getColPath() == null)) {
throw new WebdavForbidden("Cannot move root");
}
if (bwFrom.getColPath().equals(bwTo.getColPath())) {
// Rename
getSvci().getCalendarsHandler().rename(bwFrom, to.getName());
return;
}
}
} catch (CalFacadeAccessException cfae) {
throw new WebdavForbidden();
} catch (CalFacadeException cfe) {
throw new WebdavException(cfe);
} catch (Throwable t) {
throw new WebdavException(t);
}
throw new WebdavException("unimplemented");
}
use of org.bedework.calfacade.exc.CalFacadeAccessException in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method getSyncReport.
@Override
public SynchReportData getSyncReport(final String path, final String token, final int limit, final boolean recurse) throws WebdavException {
try {
String syncToken = null;
if (token != null) {
if (!token.startsWith("data:,")) {
throw new WebdavForbidden(WebdavTags.validSyncToken, token);
}
syncToken = token.substring(6);
}
if ((syncToken != null) && (syncToken.length() == 16)) {
// Force a full reload
syncToken = null;
}
final SynchReport sr = getSvci().getSynchReport(path, syncToken, limit, recurse);
if (sr == null) {
return null;
}
final SynchReportData srd = new SynchReportData();
srd.items = new ArrayList<>();
srd.token = "data:," + sr.getToken();
srd.truncated = sr.getTruncated();
for (final SynchReportItem sri : sr.getItems()) {
final SynchReportDataItem srdi;
if (sri.getEvent() != null) {
srdi = new SynchReportDataItem(sri.getVpath(), new BwCalDAVEvent(this, sri.getEvent()), sri.getToken());
} else if (sri.getResource() != null) {
srdi = new SynchReportDataItem(sri.getVpath(), new BwCalDAVResource(this, sri.getResource()), sri.getToken());
} else if (sri.getCol() != null) {
srdi = new SynchReportDataItem(sri.getVpath(), new BwCalDAVCollection(this, sri.getCol()), sri.getToken(), sri.getCanSync());
} else {
throw new RuntimeException("Unhandled sync report item type");
}
srd.items.add(srdi);
}
return srd;
} catch (final CalFacadeAccessException cfae) {
throw new WebdavForbidden();
} catch (final CalFacadeInvalidSynctoken cist) {
throw new WebdavBadRequest(WebdavTags.validSyncToken);
} catch (final CalFacadeException cfe) {
throw new WebdavException(cfe);
} catch (final WebdavException we) {
throw we;
} catch (final Throwable t) {
throw new WebdavException(t);
}
}
use of org.bedework.calfacade.exc.CalFacadeAccessException in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method schedule.
@Override
public Collection<SchedRecipientResult> schedule(final CalDAVEvent ev) throws WebdavException {
try {
ScheduleResult sr;
BwEvent event = getEvent(ev);
event.setOwnerHref(currentPrincipal.getPrincipalRef());
if (Icalendar.itipReplyMethodType(event.getScheduleMethod())) {
sr = getSvci().getScheduler().scheduleResponse(getEvinfo(ev));
} else {
sr = getSvci().getScheduler().schedule(getEvinfo(ev), null, null, // iSchedule
true);
}
return checkStatus(sr);
} catch (WebdavException we) {
throw we;
} catch (CalFacadeAccessException cfae) {
throw new WebdavForbidden();
} 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.CalFacadeAccessException in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method addEvent.
/* ====================================================================
* Events
* ==================================================================== */
/* (non-Javadoc)
* @see org.bedework.caldav.server.SysIntf#addEvent(org.bedework.caldav.server.CalDAVEvent, boolean, boolean)
*/
@Override
public Collection<CalDAVEvent> addEvent(final CalDAVEvent ev, final boolean noInvites, final boolean rollbackOnError) throws WebdavException {
try {
/* Is the event a scheduling object? */
final EventInfo ei = getEvinfo(ev);
final Collection<BwEventProxy> bwevs = getSvci().getEventsHandler().add(ei, noInvites, // scheduling - inbox
false, // autocreate
false, rollbackOnError).failedOverrides;
if (bwevs == null) {
return null;
}
final Collection<CalDAVEvent> evs = new ArrayList<CalDAVEvent>();
for (final BwEvent bwev : bwevs) {
evs.add(new BwCalDAVEvent(this, new EventInfo(bwev)));
}
return evs;
} catch (final CalFacadeAccessException cfae) {
throw new WebdavForbidden();
} catch (final CalFacadeException cfe) {
if (CalFacadeException.schedulingTooManyAttendees.equals(cfe.getDetailMessage())) {
throw new WebdavForbidden(CaldavTags.maxAttendeesPerInstance, ev.getParentPath() + "/" + cfe.getExtra());
}
if (CalFacadeException.invalidOverride.equals(cfe.getDetailMessage())) {
throw new WebdavForbidden(CaldavTags.validCalendarData, ev.getParentPath() + "/" + cfe.getExtra());
}
if (CalFacadeException.duplicateGuid.equals(cfe.getDetailMessage())) {
throw new WebdavForbidden(CaldavTags.noUidConflict, ev.getParentPath() + "/" + cfe.getExtra());
}
if (CalFacadeException.duplicateName.equals(cfe.getDetailMessage())) {
throw new WebdavForbidden(CaldavTags.noUidConflict, ev.getParentPath() + "/" + ev.getName());
}
throw new WebdavException(cfe);
} catch (Throwable t) {
throw new WebdavException(t);
}
}
use of org.bedework.calfacade.exc.CalFacadeAccessException in project bw-calendar-engine by Bedework.
the class CoreCalendars method resolveAlias.
/*
indexer != null => Use ES for the searches
*/
private BwCalendar resolveAlias(final BwCalendar val, final boolean resolveSubAlias, final boolean freeBusy, final ArrayList<String> pathElements, final BwIndexer indexer) throws CalFacadeException {
if ((val == null) || !val.getInternalAlias()) {
return val;
}
final BwCalendar c = val.getAliasTarget();
if (c != null) {
if (!resolveSubAlias) {
return c;
}
final BwCalendar res = resolveAlias(c, true, freeBusy, pathElements, indexer);
res.setAliasOrigin(val);
return res;
}
if (val.getDisabled()) {
return null;
}
int desiredAccess = privRead;
if (freeBusy) {
desiredAccess = privReadFreeBusy;
}
final String path = val.getInternalAliasPath();
if (pathElements.contains(path)) {
disableAlias(val);
return null;
}
pathElements.add(path);
// if (debug) {
// trace("Search for calendar \"" + path + "\"");
// }
BwCalendar col;
try {
if (indexer != null) {
col = getCollectionIdx(indexer, path, desiredAccess, false);
} else {
col = getCalendar(path, desiredAccess, false);
}
} catch (final CalFacadeAccessException cfae) {
col = null;
}
if (col == null) {
/* Assume deleted - flag in the subscription if it's ours or a temp.
*/
if ((val.getId() == CalFacadeDefs.unsavedItemKey) || val.getOwnerHref().equals(getPrincipal().getPrincipalRef())) {
disableAlias(val);
}
return null;
}
val.setAliasTarget(col);
if (!resolveSubAlias) {
col.setAliasOrigin(val);
return col;
}
final BwCalendar res = resolveAlias(col, true, freeBusy, pathElements, indexer);
res.setAliasOrigin(val);
return res;
}
Aggregations