use of org.bedework.calsvci.CalSvcI in project bw-calendar-engine by Bedework.
the class AbstractScheduler method getSvci.
/**
* Get an svci object as a different user.
*
* @param principalHref
* @return CalSvcI
* @throws CalFacadeException
*/
protected CalSvcI getSvci(final String principalHref) throws CalFacadeException {
CalSvcI svci;
/* account is what we authenticated with.
* user, if non-null, is the user calendar we want to access.
*/
CalSvcIPars runAsPars = CalSvcIPars.getServicePars("scheduler", // principal.getAccount(),
principalHref, // publicAdmin
false, // allow SuperUser
"/principals/users/root".equals(principalHref));
svci = new CalSvcFactoryDefault().getSvc(runAsPars);
setSvc(svci);
svci.open();
svci.beginTransaction();
return svci;
}
use of org.bedework.calsvci.CalSvcI in project bw-calendar-engine by Bedework.
the class BwDumpRestore method deleteUser.
@Override
public String deleteUser(final String account) {
try {
final CalSvcI svci = getSvci(getConfig().getAccount(), true);
final BwPrincipal pr = svci.getUsersHandler().getUser(account);
if (pr == null) {
return "No principal for " + account;
}
svci.getUsersHandler().remove(pr);
return "ok";
} catch (final Throwable t) {
error(t);
return "Exception: " + t.getLocalizedMessage();
} finally {
try {
closeSvci();
} catch (final Throwable t) {
error(t);
}
}
}
use of org.bedework.calsvci.CalSvcI in project bw-calendar-engine by Bedework.
the class InScheduler method processScheduleUpdateEvent.
private ProcessMessageResult processScheduleUpdateEvent(final ScheduleUpdateEvent msg) {
try (final CalSvcI svci = getSvci(msg.getOwnerHref())) {
if (debug) {
trace("ScheduleUpdateEvent for principal " + msg.getOwnerHref());
}
final EventInfo ei = svci.getEventsHandler().get(getParentPath(msg.getHref()), getName(msg.getHref()));
if (ei == null) {
// Event deleted?.
if (debug) {
trace("InSchedule event deleted?");
}
return ProcessMessageResult.NO_ACTION;
}
final BwEvent ev = ei.getEvent();
SchedProcessor proc = null;
switch(msg.getChange()) {
case attendeeChange:
{
proc = new SchedAttendeeUpdate(svci);
break;
}
default:
warn("InSchedule: unhandled change type for " + ev.getOwnerHref() + " " + msg.getChange());
}
if (proc == null) {
return ProcessMessageResult.PROCESSED;
}
final SchedProcResult pr = proc.process(ei);
if (debug) {
trace("InSchedule " + pr.sr);
}
return ProcessMessageResult.PROCESSED;
} catch (final CalFacadeStaleStateException csse) {
if (debug) {
trace("Stale state exception");
}
rollback(getSvc());
return ProcessMessageResult.STALE_STATE;
} catch (final Throwable t) {
rollback(getSvc());
error(t);
}
return ProcessMessageResult.FAILED;
}
use of org.bedework.calsvci.CalSvcI in project bw-calendar-engine by Bedework.
the class PrincipalProcessor method process.
/* (non-Javadoc)
* @see org.bedework.indexer.crawler.Processor#process(java.lang.String)
*/
@Override
public void process() throws CalFacadeException {
try (BwSvc bw = getBw()) {
final CalSvcI svc = bw.getSvci();
indexCollection(svc, svc.getCalendarsHandler().getHomePath());
if (principal.equals(svc.getUsersHandler().getPublicUser().getPrincipalRef())) {
return;
}
final BwIndexer indexer = svc.getIndexer(principal, indexRootPath);
status.stats.inc(IndexedType.categories, svc.getCategoriesHandler().reindex(indexer));
status.stats.inc(IndexedType.contacts, svc.getContactsHandler().reindex(indexer));
status.stats.inc(IndexedType.locations, svc.getLocationsHandler().reindex(indexer));
}
}
use of org.bedework.calsvci.CalSvcI in project bw-calendar-engine by Bedework.
the class CmdUtilHelper method open.
protected void open() throws Throwable {
final CalSvcI svci = getSvci();
if (svci == null) {
return;
}
svci.open();
svci.beginTransaction();
}
Aggregations