Search in sources :

Example 1 with BwView

use of org.bedework.calfacade.svc.BwView in project bw-calendar-engine by Bedework.

the class SimpleFilterParser method viewFilter.

private FilterBase viewFilter(final String val) throws ParseFailed {
    final BwView view = callGetView(val);
    if (view == null) {
        throw parseResult.fail("Unknown view: " + val + " source: " + source);
    }
    FilterBase filter = view.getFilter();
    if (filter != null) {
        return filter;
    }
    for (final String vpath : view.getCollectionPaths()) {
        final FilterBase vpf = resolveVpath(vpath);
        filter = or(filter, vpf);
    }
    final BwViewFilter vf = new BwViewFilter(null);
    vf.setEntity(view);
    vf.setFilter(filter);
    view.setFilter(filter);
    return vf;
}
Also used : ToString(org.bedework.util.misc.ToString) FilterBase(org.bedework.caldav.util.filter.FilterBase) BwView(org.bedework.calfacade.svc.BwView)

Example 2 with BwView

use of org.bedework.calfacade.svc.BwView in project bw-calendar-engine by Bedework.

the class Users method remove.

@Override
public void remove(final BwPrincipal pr) throws CalFacadeException {
    final String userRoot = getSvc().getPrincipalInfo().getCalendarHomePath(pr);
    /* views */
    final Collection<BwView> views = getSvc().getViewsHandler().getAll(pr);
    for (final BwView view : views) {
        getSvc().getViewsHandler().remove(view);
    }
    /* Set default calendar to null so we don't get blocked. */
    final BwPreferences prefs = getSvc().getPrefsHandler().get(pr);
    if (prefs != null) {
        prefs.setDefaultCalendarPath(null);
        getSvc().getPrefsHandler().update(prefs);
    }
    /* collections and user home */
    final BwCalendar home = getSvc().getCalendarsHandler().get(userRoot);
    if (home != null) {
        ((Calendars) getCols()).delete(home, true, true, false, true);
    }
    /* Remove preferences */
    getSvc().getPrefsHandler().delete(prefs);
    getCal().delete(pr);
}
Also used : BwPreferences(org.bedework.calfacade.svc.BwPreferences) BwCalendar(org.bedework.calfacade.BwCalendar) BwView(org.bedework.calfacade.svc.BwView)

Example 3 with BwView

use of org.bedework.calfacade.svc.BwView in project bw-calendar-engine by Bedework.

the class Views method remove.

/* (non-Javadoc)
   * @see org.bedework.calsvci.ViewsI#remove(org.bedework.calfacade.svc.BwView)
   */
@Override
public boolean remove(final BwView val) throws CalFacadeException {
    if (val == null) {
        return false;
    }
    BwPreferences prefs = getSvc().getPrefsHandler().get();
    checkOwnerOrSuper(prefs);
    // setupOwnedEntity(val, getUser());
    Collection<BwView> views = prefs.getViews();
    if ((views == null) || (!views.contains(val))) {
        return false;
    }
    String name = val.getName();
    views.remove(val);
    if (name.equals(prefs.getPreferredView())) {
        prefs.setPreferredView(null);
    }
    getSvc().getPrefsHandler().update(prefs);
    return true;
}
Also used : BwPreferences(org.bedework.calfacade.svc.BwPreferences) BwView(org.bedework.calfacade.svc.BwView)

Example 4 with BwView

use of org.bedework.calfacade.svc.BwView in project bw-calendar-engine by Bedework.

the class Views method addCollection.

/* (non-Javadoc)
   * @see org.bedework.calsvci.ViewsI#addCollection(java.lang.String, java.lang.String)
   */
@Override
public boolean addCollection(final String name, final String path) throws CalFacadeException {
    BwPreferences prefs = getSvc().getPrefsHandler().get();
    checkOwnerOrSuper(prefs);
    BwView view = find(name);
    if (view == null) {
        return false;
    }
    view.addCollectionPath(path);
    getSvc().getPrefsHandler().update(prefs);
    return true;
}
Also used : BwPreferences(org.bedework.calfacade.svc.BwPreferences) BwView(org.bedework.calfacade.svc.BwView)

Example 5 with BwView

use of org.bedework.calfacade.svc.BwView in project bw-calendar-engine by Bedework.

the class Views method find.

@Override
public BwView find(String val) throws CalFacadeException {
    if (val == null) {
        BwPreferences prefs = getSvc().getPrefsHandler().get();
        val = prefs.getPreferredView();
        if (val == null) {
            return null;
        }
    }
    /* val may be a name in which case it's for the current user or it
     * may be a fully qualified path referencing another users views.
     */
    if (!val.startsWith("/")) {
        // This user
        Collection<BwView> views = getAll();
        for (BwView view : views) {
            if (view.getName().equals(val)) {
                return view;
            }
        }
        return null;
    }
    /* Other user - we expect a path of th eform
     *  /user/<id>/<bedework-resource-name>/views/<view-name>
     */
    String[] pathEls = val.split("/");
    BasicSystemProperties bsp = getBasicSyspars();
    if ((pathEls.length != 5) || !bsp.getBedeworkResourceDirectory().equals(pathEls[2]) || !"views".equals(pathEls[3])) {
        return null;
    }
    StringBuilder sb = new StringBuilder();
    if (bsp.getUserCalendarRoot().equals(pathEls[0])) {
        sb.append(BwPrincipal.userPrincipalRoot);
    } else {
        return null;
    }
    // user id
    sb.append(pathEls[1]);
    BwPrincipal pr = getPrincipal(sb.toString());
    if (pr == null) {
        return null;
    }
    Collection<BwView> views = getAll(pr);
    String viewName = pathEls[4];
    for (BwView view : views) {
        if (view.getName().equals(viewName)) {
            return view;
        }
    }
    return null;
}
Also used : BwPreferences(org.bedework.calfacade.svc.BwPreferences) BwPrincipal(org.bedework.calfacade.BwPrincipal) BasicSystemProperties(org.bedework.calfacade.configs.BasicSystemProperties) BwView(org.bedework.calfacade.svc.BwView)

Aggregations

BwView (org.bedework.calfacade.svc.BwView)13 BwPreferences (org.bedework.calfacade.svc.BwPreferences)7 BwCalendar (org.bedework.calfacade.BwCalendar)2 BwPrincipal (org.bedework.calfacade.BwPrincipal)2 ArrayList (java.util.ArrayList)1 FilterBase (org.bedework.caldav.util.filter.FilterBase)1 BwOrganizer (org.bedework.calfacade.BwOrganizer)1 BwOwnedDbentity (org.bedework.calfacade.base.BwOwnedDbentity)1 BasicSystemProperties (org.bedework.calfacade.configs.BasicSystemProperties)1 BwAdminGroup (org.bedework.calfacade.svc.BwAdminGroup)1 EventInfo (org.bedework.calfacade.svc.EventInfo)1 OwnerUidKey (org.bedework.dumprestore.restore.OwnerUidKey)1 SkipThis (org.bedework.icalendar.IcalTranslator.SkipThis)1 ToString (org.bedework.util.misc.ToString)1