use of org.bedework.calfacade.svc.BwPreferences in project bw-calendar-engine by Bedework.
the class CalSuites method getResourcesPath.
/* ====================================================================
* Resource methods
* =================================================================== */
public String getResourcesPath(final BwCalSuite suite, final ResourceClass cl) throws CalFacadeException {
if (cl == ResourceClass.global) {
return getBasicSyspars().getGlobalResourcesPath();
}
final BwPrincipal eventsOwner = getPrincipal(suite.getGroup().getOwnerHref());
final String home = getSvc().getPrincipalInfo().getCalendarHomePath(eventsOwner);
final BwPreferences prefs = getSvc().getPrefsHandler().get(eventsOwner);
String col = null;
if (cl == ResourceClass.admin) {
col = prefs.getAdminResourcesDirectory();
if (col == null) {
col = ".adminResources";
}
} else if (cl == ResourceClass.calsuite) {
col = prefs.getSuiteResourcesDirectory();
if (col == null) {
col = ".csResources";
}
}
if (col != null) {
return Util.buildPath(colPathEndsWithSlash, home, "/", col);
}
throw new RuntimeException("System error");
}
use of org.bedework.calfacade.svc.BwPreferences in project bw-calendar-engine by Bedework.
the class Notifications method subscribe.
@Override
public void subscribe(final String principalHref, final List<String> emails) throws CalFacadeException {
try {
pushPrincipal(principalHref);
final BwPreferences prefs = getSvc().getPrefsHandler().get();
prefs.setNotificationToken(UUID.randomUUID().toString());
getNoteClient().subscribe(principalHref, emails, prefs.getNotificationToken());
} finally {
popPrincipal();
}
}
use of org.bedework.calfacade.svc.BwPreferences in project bw-calendar-engine by Bedework.
the class Notifications method subscribe.
public void subscribe(final BwPrincipal principal, final List<String> emails) throws CalFacadeException {
final BwPreferences prefs = getSvc().getPrefsHandler().get(principal);
prefs.setNotificationToken(UUID.randomUUID().toString());
getNoteClient().subscribe(principal.getPrincipalRef(), emails, prefs.getNotificationToken());
}
use of org.bedework.calfacade.svc.BwPreferences in project bw-calendar-engine by Bedework.
the class Preferences method get.
/**
* Get the preferences for the current user
*
* @return the preferences for the current user
* @throws CalFacadeException
*/
@Override
public BwPreferences get() throws CalFacadeException {
if (prefs != null) {
if (prefs.getOwnerHref() == null) {
if (getPrincipal().getUnauthenticated()) {
return prefs;
}
} else if (prefs.getOwnerHref().equals(getPrincipal().getPrincipalRef())) {
return prefs;
}
}
prefs = fetch();
if (prefs == null) {
if (getPrincipal().getUnauthenticated()) {
prefs = new BwPreferences();
return prefs;
}
getSvc().getUsersHandler().initPrincipal(getPrincipal());
prefs = fetch();
}
if (prefs == null) {
throw new CalFacadeException("org.bedework.unable.to.initialise", getPrincipal().getAccount());
}
return prefs;
}
use of org.bedework.calfacade.svc.BwPreferences in project bw-calendar-engine by Bedework.
the class RestoreImpl method restoreUserPrefs.
@Override
public void restoreUserPrefs(final BwPreferences o) throws Throwable {
try {
startTransaction();
/* If the indexer or some other activity is running this can result in
* a preferences object being created. See if one exists.
*/
BwPreferences p = getSvc().getPreferences(o.getOwnerHref());
if (p != null) {
warn("Found instance of preferences for " + o.getOwnerHref());
o.setId(p.getId());
// noinspection UnusedAssignment
p = (BwPreferences) getSvc().merge(o);
} else {
p = o;
/* Ensure views are unsaved objects */
final Collection<BwView> v = p.getViews();
if (v != null) {
for (final BwView view : v) {
view.markUnsaved();
}
}
p.markUnsaved();
}
getCal().saveOrUpdate(o);
} finally {
endTransaction();
}
}
Aggregations