Search in sources :

Example 81 with BwCalendar

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;
}
Also used : TreeSet(java.util.TreeSet) CurrentAccess(org.bedework.access.Acl.CurrentAccess) BwCalendar(org.bedework.calfacade.BwCalendar)

Example 82 with BwCalendar

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;
}
Also used : ArrayList(java.util.ArrayList) BwCalendar(org.bedework.calfacade.BwCalendar)

Example 83 with BwCalendar

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;
}
Also used : BwCalendar(org.bedework.calfacade.BwCalendar) CalendarWrapper(org.bedework.calfacade.wrappers.CalendarWrapper)

Example 84 with BwCalendar

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;
}
Also used : ArrayList(java.util.ArrayList) BwCalendar(org.bedework.calfacade.BwCalendar) CalendarWrapper(org.bedework.calfacade.wrappers.CalendarWrapper)

Example 85 with BwCalendar

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();
}
Also used : HibSession(org.bedework.calcorei.HibSession) BwCalendar(org.bedework.calfacade.BwCalendar)

Aggregations

BwCalendar (org.bedework.calfacade.BwCalendar)134 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)46 EventInfo (org.bedework.calfacade.svc.EventInfo)23 BwEvent (org.bedework.calfacade.BwEvent)19 ArrayList (java.util.ArrayList)18 CalFacadeAccessException (org.bedework.calfacade.exc.CalFacadeAccessException)18 BwPrincipal (org.bedework.calfacade.BwPrincipal)15 TreeSet (java.util.TreeSet)10 CoreEventInfo (org.bedework.calcorei.CoreEventInfo)10 BwCategory (org.bedework.calfacade.BwCategory)10 BwResource (org.bedework.calfacade.BwResource)10 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)9 FilterBase (org.bedework.caldav.util.filter.FilterBase)8 BwPreferences (org.bedework.calfacade.svc.BwPreferences)8 BwEventProxy (org.bedework.calfacade.BwEventProxy)7 CalendarWrapper (org.bedework.calfacade.wrappers.CalendarWrapper)7 CurrentAccess (org.bedework.access.Acl.CurrentAccess)6 CalendarsI (org.bedework.calsvci.CalendarsI)6 Acl (org.bedework.access.Acl)5 BwEventAnnotation (org.bedework.calfacade.BwEventAnnotation)5