use of org.bedework.access.Acl.CurrentAccess in project bw-calendar-engine by Bedework.
the class CalintfImpl method getResource.
/* ====================================================================
* resources
* ==================================================================== */
@Override
public BwResource getResource(final String name, final BwCalendar coll, final int desiredAccess) throws CalFacadeException {
final BwResource res = entityDao.getResource(name, coll, desiredAccess);
if (res == null) {
return null;
}
final CurrentAccess ca = checkAccess(res, desiredAccess, true);
if (!ca.getAccessAllowed()) {
return null;
}
return res;
}
use of org.bedework.access.Acl.CurrentAccess in project bw-calendar-engine by Bedework.
the class CoreCalendars method checkAccess.
BwCalendar checkAccess(final CalendarWrapper col, final int desiredAccess, final boolean alwaysReturnResult) throws CalFacadeException {
if (col == null) {
return null;
}
final boolean noAccessNeeded = desiredAccess == privNone;
final CurrentAccess ca = ac.checkAccess(col, desiredAccess, alwaysReturnResult || noAccessNeeded);
if (!noAccessNeeded && !ca.getAccessAllowed()) {
return null;
}
return col;
}
use of org.bedework.access.Acl.CurrentAccess in project bw-calendar-engine by Bedework.
the class CoreCalendars method getSynchCols.
@Override
public Set<BwCalendar> getSynchCols(final String path, final String token) throws CalFacadeException {
@SuppressWarnings("unchecked") final List<BwCalendar> cols = dao.getSynchCollections(fixPath(path), token);
final Set<BwCalendar> res = new TreeSet<>();
for (final BwCalendar col : cols) {
final BwCalendar wcol = wrap(col);
final CurrentAccess ca = ac.checkAccess(wcol, privAny, true);
if (!ca.getAccessAllowed()) {
continue;
}
res.add(wcol);
}
return res;
}
use of org.bedework.access.Acl.CurrentAccess in project bw-calendar-engine by Bedework.
the class CoreEvents method doRecurrence.
/* Retrieves the overides for a recurring event and if required,
* retrieves the instances.
*
* The overrides we retrieve are optionally limited by date.
*
* The CalDAV spec requires that we retrieve all overrides which fall within
* the given date range AND all instances in that date range including
* overriden instances that WOULD have fallen in that range had they not been
* overriden.
*
* Thus we need to search both overrides and instances - unless no date range
* is given in which case all overrides will appear along with the instances.
*
* If the calendars parameter is non-null, as it usually will be for a call
* from getEvents, we limit the result to instances that appear within that
* set of calendars. This handles the case of an overriden instance moved to a
* different calendar, for example the trash.
*/
@SuppressWarnings("unchecked")
private void doRecurrence(final CoreEventInfo cei, final RecurringRetrievalMode recurRetrieval) throws CalFacadeException {
final BwEvent master = cei.getEvent();
final Set<String> overrides = new HashSet<>();
final CurrentAccess ca = cei.getCurrentAccess();
// Always fetch all overrides
final Collection<BwEventAnnotation> ovs = dao.eventQuery(BwEventAnnotation.class, null, null, null, master, // overrides
true, // recurRetrieval);
null);
if (ovs != null) {
for (final BwEventAnnotation override : ovs) {
final CoreEventInfo ocei = makeOverrideProxy(override, ca);
cei.addOverride(ocei);
overrides.add(ocei.getEvent().getRecurrenceId());
}
}
if ((recurRetrieval == null) || (recurRetrieval.mode != Rmode.expanded)) {
return;
}
/* Create a list of all instance date/times before overrides. */
final int maxYears;
final int maxInstances;
maxYears = getAuthprops().getMaxYears();
maxInstances = getAuthprops().getMaxInstances();
final RecurPeriods rp = RecurUtil.getPeriods(master, maxYears, maxInstances);
if (rp.instances.isEmpty()) {
// No instances for an alleged recurring event.
return;
// throw new CalFacadeException(CalFacadeException.noRecurrenceInstances);
}
final String stzid = master.getDtstart().getTzid();
final boolean dateOnly = master.getDtstart().getDateType();
/* Emit all instances that aren't overridden. */
final TreeSet<CoreEventInfo> ceis = new TreeSet<>();
for (final Period p : rp.instances) {
String dtval = p.getStart().toString();
if (dateOnly) {
dtval = dtval.substring(0, 8);
}
final BwDateTime rstart = BwDateTime.makeBwDateTime(dateOnly, dtval, stzid);
if (overrides.contains(rstart.getDate())) {
// Overrides built separately - skip this instance.
continue;
}
final String recurrenceId = rstart.getDate();
dtval = p.getEnd().toString();
if (dateOnly) {
dtval = dtval.substring(0, 8);
}
final BwDateTime rend = BwDateTime.makeBwDateTime(dateOnly, dtval, stzid);
final BwRecurrenceInstance inst = new BwRecurrenceInstance(rstart, rend, recurrenceId, master, null);
final CoreEventInfo instcei = makeInstanceProxy(inst, ca);
if (instcei != null) {
// if (debug) {
// debugMsg("Ev: " + proxy);
// }
ceis.add(instcei);
}
}
cei.setInstances(ceis);
}
use of org.bedework.access.Acl.CurrentAccess in project bw-calendar-engine by Bedework.
the class CalSuites method wrap.
private BwCalSuiteWrapper wrap(final BwCalSuite cs, final boolean alwaysReturn) throws CalFacadeException {
final CurrentAccess ca = checkAccess(cs, PrivilegeDefs.privAny, alwaysReturn);
if ((ca == null) || !ca.getAccessAllowed()) {
return null;
}
final BwCalSuiteWrapper w = new BwCalSuiteWrapper(cs, ca);
final BwAdminGroup agrp = cs.getGroup();
if (agrp == null) {
return w;
}
final BwPrincipal eventsOwner = getSvc().getUsersHandler().getPrincipal(agrp.getOwnerHref());
if (eventsOwner == null) {
return w;
}
final BwCalendar home = getCols().getHome(eventsOwner, false);
if (home == null) {
return w;
}
w.setResourcesHome(home.getPath());
return w;
}
Aggregations