use of org.bedework.webdav.servlet.shared.WebdavForbidden in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method getEvents.
@Override
public Collection<CalDAVEvent> getEvents(final CalDAVCollection col, final FilterBase filter, final List<String> retrieveList, final RetrievalMode recurRetrieval) throws WebdavException {
try {
/* Limit the results to just this collection by adding an ANDed filter */
final SimpleFilterParser sfp = getSvci().getFilterParser();
final String expr = "(colPath='" + SfpTokenizer.escapeQuotes(col.getPath()) + "')";
final ParseResult pr = sfp.parse(expr, true, null);
if (!pr.ok) {
throw new WebdavBadRequest("Failed to reference collection " + col.getPath() + ": message was " + pr.message);
}
final FilterBase f = FilterBase.addAndChild(filter, pr.filter);
final Collection<EventInfo> bwevs = // Collection
getSvci().getEventsHandler().getEvents(// Collection
null, f, // start
null, // end
null, RetrieveList.getRetrieveList(retrieveList), DeletedState.noDeleted, getRrm(recurRetrieval));
if (bwevs == null) {
return null;
}
final Collection<CalDAVEvent> evs = new ArrayList<>();
for (final EventInfo ei : bwevs) {
if (recurRetrieval != null) {
ei.getEvent().setForceUTC(recurRetrieval.getExpand() != null);
}
evs.add(new BwCalDAVEvent(this, ei));
}
return evs;
} catch (final CalFacadeAccessException cfae) {
throw new WebdavForbidden();
} catch (final CalFacadeException cfe) {
if (CalFacadeException.unknownProperty.equals(cfe.getMessage())) {
throw new WebdavBadRequest("Unknown property " + cfe.getExtra());
}
throw new WebdavException(cfe);
} catch (final WebdavException wde) {
throw wde;
} catch (final 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 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.WebdavForbidden 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);
}
}
use of org.bedework.webdav.servlet.shared.WebdavForbidden in project bw-calendar-engine by Bedework.
the class BwSysIntfImpl method getCollections.
@Override
public Collection<CalDAVCollection> getCollections(final CalDAVCollection col) throws WebdavException {
try {
final BwCalendar bwCol = unwrap(col);
boolean isUserHome = false;
List<Integer> provisionedTypes = null;
/* Is this the calendar home? If so we have to ensure all
provisioned collections exist */
if (getPrincipal() != null) {
final String userHomePath = Util.buildPath(true, getSvci().getPrincipalInfo().getCalendarHomePath(getPrincipal()));
if (Util.buildPath(true, bwCol.getPath()).equals(userHomePath)) {
isUserHome = true;
provisionedTypes = new ArrayList<>();
for (final BwCalendar.CollectionInfo ci : BwCalendar.getAllCollectionInfo()) {
if (ci.provision) {
provisionedTypes.add(ci.collectionType);
}
}
}
}
final CalendarsI ci = getSvci().getCalendarsHandler();
final Collection<BwCalendar> bwch = ci.getChildren(bwCol);
final Collection<CalDAVCollection> ch = new ArrayList<>();
if (bwch == null) {
return ch;
}
for (final BwCalendar c : bwch) {
if (bedeworkExtensionsEnabled() || !c.getName().startsWith(".")) {
ci.resolveAlias(c, true, false);
ch.add(new BwCalDAVCollection(this, c));
}
if (isUserHome && !c.getAlias()) {
provisionedTypes.remove(new Integer(c.getCalType()));
}
}
if (isUserHome && !provisionedTypes.isEmpty()) {
// Need to add some
for (final int colType : provisionedTypes) {
final BwCalendar pcol = ci.getSpecial(currentPrincipal, colType, true, PrivilegeDefs.privAny);
ch.add(new BwCalDAVCollection(this, pcol));
}
}
return ch;
} catch (final CalFacadeAccessException cfae) {
throw new WebdavForbidden();
} catch (final 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 getCollection.
/* (non-Javadoc)
* @see org.bedework.caldav.server.SysIntf#getCollection(java.lang.String)
*/
@Override
public CalDAVCollection getCollection(final String path) throws WebdavException {
try {
BwCalendar col = getSvci().getCalendarsHandler().get(path);
if (col == null) {
return null;
}
getSvci().getCalendarsHandler().resolveAlias(col, true, false);
return new BwCalDAVCollection(this, col);
} catch (CalFacadeAccessException cfae) {
throw new WebdavForbidden();
} catch (CalFacadeException cfe) {
throw new WebdavException(cfe);
} catch (Throwable t) {
throw new WebdavException(t);
}
}
Aggregations