use of org.bedework.webdav.servlet.shared.WebdavBadRequest in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method updateEvent.
@Override
public void updateEvent(final CalDAVEvent event) throws WebdavException {
try {
EventInfo ei = getEvinfo(event);
getSvci().getEventsHandler().update(ei, false);
} 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 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.WebdavBadRequest 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.WebdavBadRequest in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method fromIcal.
@Override
public SysiIcalendar fromIcal(final CalDAVCollection col, final IcalendarType ical, final IcalResultType rtype) throws WebdavException {
// Ensure open
getSvci();
boolean rollback = true;
try {
BwCalendar bwcol = null;
if (col != null) {
bwcol = unwrap(col.resolveAlias(true));
}
Icalendar ic = trans.fromIcal(bwcol, ical, // diff the contents
true);
if (rtype == IcalResultType.OneComponent) {
if (ic.getComponents().size() != 1) {
throw new WebdavBadRequest(CaldavTags.validCalendarObjectResource);
}
if (!(ic.getComponents().iterator().next() instanceof EventInfo)) {
throw new WebdavBadRequest(CaldavTags.validCalendarObjectResource);
}
} else if (rtype == IcalResultType.TimeZone) {
if (ic.getTimeZones().size() != 1) {
throw new WebdavBadRequest("Expected one timezone");
}
}
SysiIcalendar sic = new MySysiIcalendar(this, ic);
rollback = false;
return sic;
} catch (WebdavException wde) {
throw wde;
} catch (IcalMalformedException ime) {
throw new WebdavForbidden(CaldavTags.validCalendarData, ime.getMessage());
} catch (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 (Throwable t) {
}
}
}
}
Aggregations