use of org.bedework.calfacade.svc.BwAuthUser in project bw-calendar-engine by Bedework.
the class PrincipalsAndPrefsDAO method getAuthUser.
public BwAuthUser getAuthUser(final String href) throws CalFacadeException {
final HibSession sess = getSess();
sess.createQuery(getUserQuery);
sess.setString("userHref", href);
return (BwAuthUser) sess.getUnique();
}
use of org.bedework.calfacade.svc.BwAuthUser in project bw-calendar-engine by Bedework.
the class AuthUserFieldRule method field.
/* (non-Javadoc)
* @see org.bedework.dumprestore.restore.rules.EntityFieldRule#field(java.lang.String)
*/
@Override
public void field(final String name) throws Throwable {
BwEventProperty ep = null;
BwCalendar cal = null;
try {
if (top() instanceof BwEventProperty) {
ep = (BwEventProperty) pop();
} else if (top() instanceof BwCalendar) {
cal = (BwCalendar) pop();
}
BwAuthUser au = (BwAuthUser) top();
if (name.equals("id") || name.equals("seq")) {
return;
}
if (name.equals("userHref")) {
au.setUserHref(Util.buildPath(false, stringFld()));
// } else if (name.equals("account")) { old?
// au.setUserHref(globals.rintf.getUser(stringFld()).getPrincipalRef());
// } else if (name.equals("user")) {
// // done above
} else if (name.equals("usertype")) {
int type = intFld();
au.setUsertype(type);
/* Prefs stuff next */
} else if (name.equals("autoAdd")) {
if (inCategoryPrefs) {
getCategoryPrefs(au).setAutoAdd(booleanFld());
} else if (inCollectionsPrefs) {
getCalendarPrefs(au).setAutoAdd(booleanFld());
} else if (inContactPrefs) {
getContactPrefs(au).setAutoAdd(booleanFld());
} else if (inLocationPrefs) {
getLocationPrefs(au).setAutoAdd(booleanFld());
} else {
error("Not in any prefs for autoAdd");
}
} else if (name.equals("category")) {
au.getPrefs().getCategoryPrefs().add((BwCategory) ep);
} else if (name.equals("collection")) {
au.getPrefs().getCalendarPrefs().add(cal);
} else if (name.equals("contact")) {
au.getPrefs().getContactPrefs().add((BwContact) ep);
} else if (name.equals("location")) {
au.getPrefs().getLocationPrefs().add((BwLocation) ep);
} else if (name.equals("categoryPrefs")) {
inCategoryPrefs = false;
} else if (name.equals("calendarPrefs")) {
inCollectionsPrefs = false;
} else if (name.equals("contactPrefs")) {
inContactPrefs = false;
} else if (name.equals("locationPrefs")) {
inLocationPrefs = false;
} else if (name.equals("prefs")) {
} else if (name.equals("byteSize")) {
} else {
unknownTag(name);
}
} catch (Throwable t) {
handleException(t);
}
}
use of org.bedework.calfacade.svc.BwAuthUser in project bw-calendar-engine by Bedework.
the class AuthUserRule method end.
@Override
public void end(final String ns, final String name) throws Exception {
final BwAuthUser au = (BwAuthUser) pop();
globals.counts[globals.authusers]++;
try {
globals.rintf.restoreAuthUser(au);
} catch (final Throwable t) {
error("Error restoring " + au);
throw new Exception(t);
}
}
use of org.bedework.calfacade.svc.BwAuthUser 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());
}
}
use of org.bedework.calfacade.svc.BwAuthUser in project bw-calendar-engine by Bedework.
the class Calendars method getHomePath.
@Override
public String getHomePath() throws CalFacadeException {
if (isGuest()) {
return publicCalendarRootPath;
}
if (isPublicAdmin()) {
if (!getSyspars().getWorkflowEnabled()) {
return publicCalendarRootPath;
}
final BwAuthUser au = getSvc().getUserAuth().getUser(getPars().getAuthUser());
final boolean isApprover = isSuper() || (au != null) && au.isApproverUser();
// Do they have approver status?
if (isApprover) {
return publicCalendarRootPath;
}
return Util.buildPath(colPathEndsWithSlash, // "/",
getSyspars().getWorkflowRoot());
// getPrincipal().getAccountNoSlash());
}
return getSvc().getPrincipalInfo().getCalendarHomePath();
}
Aggregations