use of org.bedework.calfacade.BwCalendar 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.calfacade.BwCalendar in project bw-calendar-engine by Bedework.
the class CoreCalendars method findAlias.
@Override
public List<BwCalendar> findAlias(final String val) throws CalFacadeException {
final List<BwCalendar> aliases = dao.findCollectionAlias(fixPath(val), currentPrincipal());
final List<BwCalendar> waliases = new ArrayList<>();
if (Util.isEmpty(aliases)) {
return waliases;
}
for (final BwCalendar alias : aliases) {
waliases.add(wrap(alias));
}
return waliases;
}
use of org.bedework.calfacade.BwCalendar in project bw-calendar-engine by Bedework.
the class CoreCalendars method getCalendar.
@Override
public BwCalendar getCalendar(final String path, final int desiredAccess, final boolean alwaysReturnResult) throws CalFacadeException {
BwCalendar col = getCollection(path);
if ((col != null) && (col.getCalType() == BwCalendar.calTypeAlias) && (!col.getOwnerHref().equals(col.getCreatorHref())) && ("/principals/users/public-user".equals(col.getOwnerHref()))) {
col.setOwnerHref(col.getCreatorHref());
}
col = checkAccess((CalendarWrapper) col, desiredAccess, alwaysReturnResult);
return col;
}
use of org.bedework.calfacade.BwCalendar in project bw-calendar-engine by Bedework.
the class CoreCalendars method getChildren.
/* No access checks performed */
@SuppressWarnings("unchecked")
private Collection<BwCalendar> getChildren(final BwCalendar col) throws CalFacadeException {
final List<BwCalendar> ch;
final List<BwCalendar> wch = new ArrayList<>();
if (col == null) {
return wch;
}
if (sessionless) {
/*
Maybe we should just fetch them. We've probably not seen them and
we're just working our way down a tree. The 2 phase might be slower.
*/
ch = dao.getChildCollections(col.getPath());
} else {
/* Fetch the lastmod and paths of all children then fetch those we haven't
* got in the cache.
*/
final List<CoreCalendarsDAO.LastModAndPath> lmps = dao.getChildLastModsAndPaths(col.getPath());
final List<String> paths = new ArrayList<>();
if (Util.isEmpty(lmps)) {
return wch;
}
for (final CoreCalendarsDAO.LastModAndPath lmp : lmps) {
final String token = BwLastMod.getTagValue(lmp.timestamp, lmp.sequence);
final BwCalendar c = colCache.get(lmp.path, token);
if ((c != null) && !c.getTombstoned()) {
wch.add(c);
continue;
}
paths.add(lmp.path);
}
if (paths.isEmpty()) {
return wch;
}
/* paths lists those we couldn't find in the cache. */
ch = dao.getCollections(paths);
}
if (Util.isEmpty(ch)) {
return wch;
}
for (final BwCalendar c : ch) {
final CalendarWrapper wc = wrap(c);
colCache.put(wc);
wch.add(wc);
}
return wch;
}
use of org.bedework.calfacade.BwCalendar in project bw-calendar-engine by Bedework.
the class CoreCalendarsDAO method getCollection.
public BwCalendar getCollection(final String path) throws CalFacadeException {
final HibSession sess = getSess();
sess.createQuery(getCalendarByPathQuery);
sess.setString("path", path);
sess.cacheableQuery();
return (BwCalendar) sess.getUnique();
}
Aggregations