Search in sources :

Example 1 with LocationPref

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

the class Preferences method updateAdminPrefs.

/* (non-Javadoc)
   * @see org.bedework.calsvci.PreferencesI#updateAdminPrefs(boolean, org.bedework.calfacade.BwCalendar, org.bedework.calfacade.BwCategory, org.bedework.calfacade.BwLocation, org.bedework.calfacade.BwContact)
   */
public void updateAdminPrefs(final boolean remove, final BwCalendar cal, final Collection<BwCategory> cats, final BwLocation loc, final BwContact ctct) throws CalFacadeException {
    BwCommonUserPrefs prefs = null;
    boolean update = false;
    BwAuthUser au = null;
    if (getPars().getPublicAdmin()) {
        au = getSvc().getUserAuth().getUser(getPars().getAuthUser());
        if (au != null) {
            prefs = au.getPrefs();
        }
    }
    if (prefs == null) {
        // XXX until we get non admin user preferred calendars etc
        return;
    }
    if (cal != null) {
        if (!remove) {
            if (cal.getCalendarCollection()) {
                CalendarPref p = prefs.getCalendarPrefs();
                if (p.getAutoAdd() && p.add(cal)) {
                    update = true;
                }
            }
        } else {
            getSvc().removeFromAllPrefs(cal);
        }
    }
    if (!Util.isEmpty(cats)) {
        for (final BwCategory cat : cats) {
            if (!remove) {
                CategoryPref p = prefs.getCategoryPrefs();
                if (p.getAutoAdd() && p.add(cat)) {
                    update = true;
                }
            } else {
                getSvc().removeFromAllPrefs(cat);
            }
        }
    }
    if (loc != null) {
        if (!remove) {
            LocationPref p = prefs.getLocationPrefs();
            if (p.getAutoAdd() && p.add(loc)) {
                update = true;
            }
        } else {
            getSvc().removeFromAllPrefs(loc);
        }
    }
    if (ctct != null) {
        if (!remove) {
            ContactPref p = prefs.getContactPrefs();
            if (p.getAutoAdd() && p.add(ctct)) {
                update = true;
            }
        } else {
            getSvc().removeFromAllPrefs(ctct);
        }
    }
    if (update) {
        if (getPars().getPublicAdmin()) {
            getSvc().getUserAuth().updateUser(au);
        }
    }
}
Also used : BwAuthUser(org.bedework.calfacade.svc.BwAuthUser) CategoryPref(org.bedework.calfacade.svc.prefs.CategoryPref) ContactPref(org.bedework.calfacade.svc.prefs.ContactPref) BwCommonUserPrefs(org.bedework.calfacade.svc.prefs.BwCommonUserPrefs) CalendarPref(org.bedework.calfacade.svc.prefs.CalendarPref) BwCategory(org.bedework.calfacade.BwCategory) LocationPref(org.bedework.calfacade.svc.prefs.LocationPref)

Example 2 with LocationPref

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

the class AuthUserFieldRule method getLocationPrefs.

private LocationPref getLocationPrefs(final BwAuthUser au) {
    BwAuthUserPrefs aup = getPrefs(au);
    LocationPref p = aup.getLocationPrefs();
    if (p == null) {
        p = new LocationPref();
        aup.setLocationPrefs(p);
    }
    return p;
}
Also used : BwAuthUserPrefs(org.bedework.calfacade.svc.prefs.BwAuthUserPrefs) LocationPref(org.bedework.calfacade.svc.prefs.LocationPref)

Example 3 with LocationPref

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

the class AuthUserRule method begin.

@Override
public void begin(final String ns, final String name, final Attributes att) throws Exception {
    super.begin(ns, name, att);
    BwAuthUser au = (BwAuthUser) top();
    BwAuthUserPrefs prefs = au.getPrefs();
    if (prefs == null) {
        prefs = new BwAuthUserPrefs();
        au.setPrefs(prefs);
    }
    if (prefs.getCalendarPrefs() == null) {
        prefs.setCalendarPrefs(new CalendarPref());
    }
    if (prefs.getContactPrefs() == null) {
        prefs.setContactPrefs(new ContactPref());
    }
    if (prefs.getLocationPrefs() == null) {
        prefs.setLocationPrefs(new LocationPref());
    }
    if (prefs.getCategoryPrefs() == null) {
        prefs.setCategoryPrefs(new CategoryPref());
    }
}
Also used : BwAuthUser(org.bedework.calfacade.svc.BwAuthUser) CategoryPref(org.bedework.calfacade.svc.prefs.CategoryPref) ContactPref(org.bedework.calfacade.svc.prefs.ContactPref) CalendarPref(org.bedework.calfacade.svc.prefs.CalendarPref) BwAuthUserPrefs(org.bedework.calfacade.svc.prefs.BwAuthUserPrefs) LocationPref(org.bedework.calfacade.svc.prefs.LocationPref)

Aggregations

LocationPref (org.bedework.calfacade.svc.prefs.LocationPref)3 BwAuthUser (org.bedework.calfacade.svc.BwAuthUser)2 BwAuthUserPrefs (org.bedework.calfacade.svc.prefs.BwAuthUserPrefs)2 CalendarPref (org.bedework.calfacade.svc.prefs.CalendarPref)2 CategoryPref (org.bedework.calfacade.svc.prefs.CategoryPref)2 ContactPref (org.bedework.calfacade.svc.prefs.ContactPref)2 BwCategory (org.bedework.calfacade.BwCategory)1 BwCommonUserPrefs (org.bedework.calfacade.svc.prefs.BwCommonUserPrefs)1