use of org.bedework.webdav.servlet.shared.WebdavException 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.WebdavException in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method getCalPrincipalInfo.
private CalPrincipalInfo getCalPrincipalInfo(final BwPrincipalInfo pi) throws WebdavException {
try {
// SCHEDULE - just get home path and get default cal from user prefs.
String userHomePath = Util.buildPath(false, "/", basicSysProperties.getUserCalendarRoot());
if (pi.getPrincipalHref() == null) {
return new CalPrincipalInfo(null, pi.getCard(), pi.getCardStr(), // userHomePath,
null, // defaultCalendarPath,
null, // inboxPath,
null, // outboxPath,
null, // notificationsPath,
null, 0);
}
final BwPrincipal p = getSvci().getDirectories().getPrincipal(pi.getPrincipalHref());
if (pi.getPrincipalHref().startsWith(BwPrincipal.userPrincipalRoot)) {
userHomePath = Util.buildPath(true, userHomePath, pi.getPrincipalHref().substring(BwPrincipal.userPrincipalRoot.length()));
} else {
userHomePath = Util.buildPath(true, userHomePath, pi.getPrincipalHref());
}
final String defaultCalendarPath = Util.buildPath(true, userHomePath + basicSysProperties.getUserDefaultCalendar());
final String inboxPath = Util.buildPath(true, userHomePath, "/", basicSysProperties.getUserInbox());
final String outboxPath = Util.buildPath(true, userHomePath, "/", basicSysProperties.getUserOutbox());
final String notificationsPath = Util.buildPath(true, userHomePath, "/", basicSysProperties.getDefaultNotificationsName());
return new CalPrincipalInfo(p, pi.getCard(), pi.getCardStr(), userHomePath, defaultCalendarPath, inboxPath, outboxPath, notificationsPath, 0);
} 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 getFreebusySet.
/* ====================================================================
* Scheduling
* ==================================================================== */
@Override
public Collection<String> getFreebusySet() throws WebdavException {
try {
Collection<BwCalendar> cals = svci.getScheduler().getFreebusySet();
Collection<String> hrefs = new ArrayList<String>();
if (cals == null) {
return hrefs;
}
for (BwCalendar cal : cals) {
hrefs.add(getUrlHandler().prefix(cal.getPath()));
// hrefs.add(getUrlPrefix() + cal.getPath());
}
return hrefs;
} 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 toIcalString.
@Override
public String toIcalString(final Calendar cal, final String contentType) throws WebdavException {
try {
String ctype = null;
if (contentType != null) {
final String[] contentTypePars = contentType.split(";");
ctype = contentTypePars[0];
}
if (ctype == null) {
throw new WebdavException("Null content type");
}
if (ctype.equals("text/calendar")) {
return IcalTranslator.toIcalString(cal);
}
if (ctype.equals("application/calendar+json")) {
return IcalTranslator.toJcal(cal, null);
}
throw new WebdavException("Unhandled content type" + contentType);
} 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 getInviteStatus.
@Override
public InviteType getInviteStatus(final CalDAVCollection col) throws WebdavException {
try {
InviteType inv = svci.getSharingHandler().getInviteStatus(unwrap(col));
if (inv == null) {
return null;
}
UrlHandler uh = getUrlHandler();
for (UserType u : inv.getUsers()) {
u.setHref(uh.prefix(u.getHref()));
}
return inv;
} catch (CalFacadeForbidden cf) {
throw new WebdavForbidden(cf.getMessage());
} catch (WebdavException we) {
throw we;
} catch (Throwable t) {
throw new WebdavException(t);
}
}
Aggregations