use of org.bedework.webdav.servlet.shared.WebdavException 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.webdav.servlet.shared.WebdavException 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.webdav.servlet.shared.WebdavException 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.webdav.servlet.shared.WebdavException in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method fromIcal.
/* (non-Javadoc)
* @see org.bedework.caldav.server.sysinterface.SysIntf#fromIcal(org.bedework.caldav.server.CalDAVCollection, java.io.Reader, java.lang.String, org.bedework.caldav.server.sysinterface.SysIntf.IcalResultType, boolean)
*/
@Override
public SysiIcalendar fromIcal(final CalDAVCollection col, final Reader rdr, final String contentType, final IcalResultType rtype, final boolean mergeAttendees) throws WebdavException {
// Ensure open
getSvci();
boolean rollback = true;
/* (CALDAV:supported-calendar-data) */
if ((contentType == null) || (!contentType.equals("text/calendar") && !contentType.equals("application/calendar+json"))) {
if (debug) {
debug("Bad content type: " + contentType);
}
throw new WebdavForbidden(CaldavTags.supportedCalendarData, "Bad content type: " + contentType);
}
try {
BwCalendar bwcol = null;
if (col != null) {
bwcol = unwrap(col);
}
final Icalendar ic = trans.fromIcal(bwcol, new SysIntfReader(rdr), contentType, // diff the contents
true, mergeAttendees);
if (rtype == IcalResultType.OneComponent) {
if (ic.getComponents().size() != 1) {
throw new WebdavForbidden(CaldavTags.validCalendarObjectResource);
}
if (!(ic.getComponents().iterator().next() instanceof EventInfo)) {
throw new WebdavForbidden(CaldavTags.validCalendarObjectResource);
}
} else if (rtype == IcalResultType.TimeZone) {
if (ic.getTimeZones().size() != 1) {
throw new WebdavForbidden("Expected one timezone");
}
}
final SysiIcalendar sic = new MySysiIcalendar(this, ic);
rollback = false;
return sic;
} catch (final IcalMalformedException ime) {
throw new WebdavForbidden(CaldavTags.validCalendarData, ime.getMessage());
} catch (final CalFacadeException cfe) {
if (CalFacadeException.unknownTimezone.equals(cfe.getDetailMessage())) {
throw new WebdavForbidden(CaldavTags.validTimezone, cfe.getMessage());
}
throw new WebdavForbidden(CaldavTags.validCalendarObjectResource, cfe.getMessage());
} catch (final WebdavException wde) {
throw wde;
} catch (final Throwable t) {
if (debug) {
error(t);
}
// Assume bad data in some way
throw new WebdavForbidden(CaldavTags.validCalendarObjectResource, t.getMessage());
} finally {
if (rollback) {
try {
getSvci().rollbackTransaction();
} catch (final Throwable ignored) {
}
}
}
}
use of org.bedework.webdav.servlet.shared.WebdavException in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method getPrincipalCollectionSet.
@Override
public Collection<String> getPrincipalCollectionSet(final String resourceUri) throws WebdavException {
try {
ArrayList<String> al = new ArrayList<>();
al.add(BwPrincipal.principalRoot);
return al;
} catch (Throwable t) {
throw new WebdavException(t);
}
}
Aggregations