use of org.bedework.webdav.servlet.shared.WebdavException in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method getSpecialFreeBusy.
/* (non-Javadoc)
* @see org.bedework.caldav.server.sysinterface.SysIntf#getSpecialFreeBusy(java.lang.String, java.util.Set, java.lang.String, org.bedework.caldav.util.TimeRange, java.io.Writer)
*/
@Override
public void getSpecialFreeBusy(final String cua, final Set<String> recipients, final String originator, final TimeRange tr, final Writer wtr) throws WebdavException {
BwOrganizer org = new BwOrganizer();
org.setOrganizerUri(cua);
BwEvent ev = new BwEventObj();
ev.setDtstart(getBwDt(tr.getStart()));
ev.setDtend(getBwDt(tr.getEnd()));
ev.setEntityType(IcalDefs.entityTypeFreeAndBusy);
ev.setScheduleMethod(ScheduleMethods.methodTypeRequest);
ev.setRecipients(recipients);
ev.setOriginator(originator);
ev.setOrganizer(org);
Collection<SchedRecipientResult> srrs = requestFreeBusy(new BwCalDAVEvent(this, new EventInfo(ev)), false);
for (SchedRecipientResult srr : srrs) {
// We expect one only
BwCalDAVEvent rfb = (BwCalDAVEvent) srr.freeBusy;
if (rfb != null) {
rfb.getEv().setOrganizer(org);
try {
VFreeBusy vfreeBusy = VFreeUtil.toVFreeBusy(rfb.getEv());
net.fortuna.ical4j.model.Calendar ical = IcalTranslator.newIcal(ScheduleMethods.methodTypeReply);
ical.getComponents().add(vfreeBusy);
IcalTranslator.writeCalendar(ical, wtr);
} catch (Throwable t) {
if (debug) {
error(t);
}
throw new WebdavException(t);
}
}
}
}
use of org.bedework.webdav.servlet.shared.WebdavException 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.WebdavException in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method subscribeNotification.
/* ====================================================================
* Notifications
* ==================================================================== */
public boolean subscribeNotification(final String principalHref, final String action, final List<String> emails) throws WebdavException {
final boolean add = "add".equals(action);
final boolean remove = "remove".equals(action);
if (!add && !remove) {
return false;
}
try {
if (remove) {
svci.getNotificationsHandler().unsubscribe(principalHref, emails);
return true;
}
if (Util.isEmpty(emails)) {
return false;
}
svci.getNotificationsHandler().subscribe(principalHref, emails);
return true;
} catch (final CalFacadeException cfe) {
throw new WebdavException(cfe);
}
}
use of org.bedework.webdav.servlet.shared.WebdavException in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method writeCalendar.
@Override
public String writeCalendar(final Collection<CalDAVEvent> evs, final MethodEmitted method, final XmlEmit xml, final Writer wtr, final String contentType) throws WebdavException {
try {
Collection<EventInfo> bwevs = new ArrayList<EventInfo>();
int meth = ScheduleMethods.methodTypeNone;
if (method == MethodEmitted.publish) {
meth = ScheduleMethods.methodTypePublish;
}
for (CalDAVEvent cde : evs) {
BwCalDAVEvent bcde = (BwCalDAVEvent) cde;
if (method == MethodEmitted.eventMethod) {
meth = getEvent(bcde).getScheduleMethod();
}
bwevs.add(bcde.getEvinfo());
}
String ctype = contentType;
if ((ctype == null) || (!ctype.equals("text/calendar") && !ctype.equals("application/calendar+json") && !ctype.equals(XcalTags.mimetype))) {
ctype = getDefaultContentType();
}
if (ctype.equals("text/calendar")) {
Calendar ical = trans.toIcal(bwevs, meth);
if (xml == null) {
IcalTranslator.writeCalendar(ical, wtr);
} else {
xml.cdataValue(toIcalString(ical, "text/calendar"));
}
} else if (ctype.equals("application/calendar+json")) {
if (xml == null) {
trans.writeJcal(bwevs, meth, wtr);
} else {
final StringWriter sw = new StringWriter();
trans.writeJcal(bwevs, meth, sw);
xml.cdataValue(sw.toString());
}
} else if (ctype.equals(XcalTags.mimetype)) {
XmlEmit x;
if (xml == null) {
x = new XmlEmit();
x.startEmit(wtr);
} else {
x = xml;
}
trans.writeXmlCalendar(bwevs, meth, x);
}
return ctype;
} catch (WebdavException we) {
throw we;
} 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 getSyncToken.
@Override
public String getSyncToken(final CalDAVCollection col) throws WebdavException {
try {
BwCalendar bwcol = ((BwCalDAVCollection) col).getCol();
String path = col.getPath();
if (bwcol.getInternalAlias()) {
path = bwcol.getAliasTarget().getPath();
}
return "data:," + getSvci().getCalendarsHandler().getSyncToken(path);
} catch (CalFacadeAccessException cfae) {
throw new WebdavForbidden();
} catch (CalFacadeException cfe) {
throw new WebdavException(cfe);
} catch (Throwable t) {
throw new WebdavException(t);
}
}
Aggregations