use of org.bedework.calfacade.BwPrincipal 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.BwPrincipal in project bw-calendar-engine by Bedework.
the class CalSvc method pushPrincipal.
/**
* Switch to the given principal to allow us to update their stuff - for
* example - send a notification.
*
* @param principal a principal object
*/
void pushPrincipal(final BwPrincipal principal) throws CalFacadeException {
BwPrincipal pr = getUsersHandler().getUser(principal.getPrincipalRef());
if (pr == null) {
pr = addUser(principal.getPrincipalRef());
}
((SvciPrincipalInfo) principalInfo).pushPrincipal(pr);
getCal().principalChanged();
}
use of org.bedework.calfacade.BwPrincipal in project bw-calendar-engine by Bedework.
the class CalSvc method addUser.
/* Create the user. Get a new CalSvc object for that purpose.
*
*/
BwPrincipal addUser(final String val) throws CalFacadeException {
final Users users = (Users) getUsersHandler();
/* Run this in a separate transaction to ensure we don't fail if the user
* gets created by a concurrent process.
*/
// if (creating) {
// // Get a fake user
// return users.initUserObject(val);
// }
// In case we need to replace the session
getCal().flush();
try {
users.createUser(val);
} catch (final CalFacadeException cfe) {
if (cfe.getCause() instanceof ConstraintViolationException) {
// We'll assume it was created by another process.
warn("ConstraintViolationException trying to create " + val);
// Does this session still work?
} else {
rollbackTransaction();
if (debug) {
cfe.printStackTrace();
}
throw cfe;
}
} catch (final Throwable t) {
rollbackTransaction();
if (debug) {
t.printStackTrace();
}
throw new CalFacadeException(t);
}
final BwPrincipal principal = users.getUser(val);
if (principal == null) {
return null;
}
final String caladdr = getDirectories().userToCaladdr(principal.getPrincipalRef());
if (caladdr != null) {
final List<String> emails = Collections.singletonList(caladdr.substring("mailto:".length()));
final Notifications notify = (Notifications) getNotificationsHandler();
notify.subscribe(principal, emails);
}
return principal;
}
use of org.bedework.calfacade.BwPrincipal in project bw-calendar-engine by Bedework.
the class CalSvcDb method pushPrincipal.
protected void pushPrincipal(final String href) throws CalFacadeException {
final BwPrincipal pr = caladdrToPrincipal(href);
if (pr == null) {
throw new CalFacadeException(CalFacadeException.badRequest, "unknown principal");
}
getSvc().pushPrincipal(pr);
}
use of org.bedework.calfacade.BwPrincipal in project bw-calendar-engine by Bedework.
the class CalSvcDb method pushPrincipalReturn.
protected boolean pushPrincipalReturn(final String href) throws CalFacadeException {
final BwPrincipal pr = caladdrToPrincipal(href);
if (pr == null) {
return false;
}
getSvc().pushPrincipal(pr);
return true;
}
Aggregations