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);
}
}
}
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;
}
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());
}
}
Aggregations