use of org.bedework.webdav.servlet.shared.WebdavForbidden in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method requestFreeBusy.
@Override
public Collection<SchedRecipientResult> requestFreeBusy(final CalDAVEvent val, final boolean iSchedule) throws WebdavException {
try {
ScheduleResult sr;
BwEvent ev = getEvent(val);
if (currentPrincipal != null) {
ev.setOwnerHref(currentPrincipal.getPrincipalRef());
}
if (Icalendar.itipReplyMethodType(ev.getScheduleMethod())) {
sr = getSvci().getScheduler().scheduleResponse(getEvinfo(val));
} else {
sr = getSvci().getScheduler().schedule(getEvinfo(val), null, null, iSchedule);
}
return checkStatus(sr);
} catch (CalFacadeAccessException cfae) {
if (debug) {
error(cfae);
}
throw new WebdavForbidden();
} catch (CalFacadeException cfe) {
if (CalFacadeException.duplicateGuid.equals(cfe.getMessage())) {
throw new WebdavBadRequest("Duplicate-guid");
}
throw new WebdavException(cfe);
} catch (WebdavException wde) {
throw wde;
} catch (Throwable t) {
throw new WebdavException(t);
}
}
use of org.bedework.webdav.servlet.shared.WebdavForbidden in project bw-calendar-engine by Bedework.
the class BwCalDAVResource method setBinaryContent.
@Override
public void setBinaryContent(final InputStream val) throws WebdavException {
BwResource r = getRsrc();
BwResourceContent rc = r.getContent();
if (rc == null) {
if (!isNew()) {
intf.getFileContent(this);
rc = r.getContent();
}
if (rc == null) {
rc = new BwResourceContent();
r.setContent(rc);
}
}
try {
/* If this is a notification we need to unprefix the data */
final InputStream str;
if (!isNotification()) {
str = val;
} else {
final NotificationType note = Parser.fromXml(val);
note.getNotification().unprefixHrefs(intf.getUrlHandler());
str = new ByteArrayInputStream(note.toXml(true).getBytes());
}
final ByteArrayOutputStream outBuff = new ByteArrayOutputStream();
byte[] inBuffer = new byte[1000];
long clen = 0;
int chunkSize;
int maxSize = intf.getAuthProperties().getMaxUserEntitySize();
long oldSize = r.getContentLength();
while (clen <= maxSize) {
chunkSize = str.read(inBuffer);
if (chunkSize < 0) {
break;
}
outBuff.write(inBuffer, 0, chunkSize);
clen += chunkSize;
}
if (clen > maxSize) {
throw new WebdavForbidden(CaldavTags.maxResourceSize);
}
rc.setValue(intf.getBlob(outBuff.toByteArray()));
r.setContentLength(clen);
if (!intf.updateQuota(getOwner(), clen - oldSize)) {
throw new WebdavForbidden(WebdavTags.quotaNotExceeded);
}
} catch (WebdavException wde) {
throw wde;
} catch (Throwable t) {
throw new WebdavException(t);
}
}
use of org.bedework.webdav.servlet.shared.WebdavForbidden in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method checkStatus.
/**
* @param sr schedule result
* @return recipient results
* @throws WebdavException
*/
private Collection<SchedRecipientResult> checkStatus(final ScheduleResult sr) throws WebdavException {
if ((sr.errorCode == null) || (sr.errorCode.equals(CalFacadeException.schedulingNoRecipients))) {
final Collection<SchedRecipientResult> srrs = new ArrayList<>();
for (final ScheduleRecipientResult bwsrr : sr.recipientResults.values()) {
final SchedRecipientResult srr = new SchedRecipientResult();
srr.recipient = bwsrr.recipient;
srr.status = bwsrr.getStatus();
if (bwsrr.freeBusy != null) {
srr.freeBusy = new BwCalDAVEvent(this, new EventInfo(bwsrr.freeBusy));
}
srrs.add(srr);
}
return srrs;
}
if (sr.errorCode.equals(CalFacadeException.schedulingBadMethod)) {
throw new WebdavForbidden(CaldavTags.validCalendarData, "Bad METHOD");
}
if (sr.errorCode.equals(CalFacadeException.schedulingBadAttendees)) {
throw new WebdavForbidden(CaldavTags.attendeeAllowed, "Bad attendees");
}
if (sr.errorCode.equals(CalFacadeException.schedulingAttendeeAccessDisallowed)) {
throw new WebdavForbidden(CaldavTags.attendeeAllowed, "attendeeAccessDisallowed");
}
throw new WebdavForbidden(sr.errorCode);
}
use of org.bedework.webdav.servlet.shared.WebdavForbidden in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method deleteFile.
/* (non-Javadoc)
* @see org.bedework.caldav.server.SysIntf#deleteFile(org.bedework.caldav.server.CalDAVResource)
*/
@Override
public void deleteFile(final CalDAVResource val) throws WebdavException {
try {
updateQuota(val.getOwner(), -val.getQuotaSize());
getSvci().getResourcesHandler().delete(Util.buildPath(false, val.getParentPath(), "/", val.getName()));
} catch (CalFacadeAccessException cfae) {
throw new WebdavForbidden();
} catch (CalFacadeException cfe) {
throw new WebdavException(cfe);
} catch (Throwable t) {
throw new WebdavException(t);
}
}
use of org.bedework.webdav.servlet.shared.WebdavForbidden in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method tzidFromTzdef.
@Override
public String tzidFromTzdef(final String val) throws WebdavException {
try {
// Ensure open
getSvci();
StringReader sr = new StringReader(val);
Icalendar ic = trans.fromIcal(null, sr);
if ((ic == null) || // No components other than timezones
(ic.size() != 0) || (ic.getTimeZones().size() != 1)) {
if (debug) {
debug("Not single timezone");
}
throw new WebdavForbidden(CaldavTags.calendarTimezone, "Not single timezone");
}
/* This should be the only timezone ion the Calendar object
*/
TimeZone tz = ic.getTimeZones().iterator().next().tz;
return tz.getID();
} catch (CalFacadeException cfe) {
throw new WebdavException(cfe);
}
}
Aggregations