Search in sources :

Example 1 with CalSvcI

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;
}
Also used : CalSvcFactoryDefault(org.bedework.calsvci.CalSvcFactoryDefault) CalSvcIPars(org.bedework.calsvci.CalSvcIPars) CalSvcI(org.bedework.calsvci.CalSvcI)

Example 2 with CalSvcI

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);
        }
    }
}
Also used : BwPrincipal(org.bedework.calfacade.BwPrincipal) CalSvcI(org.bedework.calsvci.CalSvcI)

Example 3 with CalSvcI

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;
}
Also used : SchedProcessor(org.bedework.inoutsched.processors.SchedProcessor) CalFacadeStaleStateException(org.bedework.calfacade.exc.CalFacadeStaleStateException) SchedProcResult(org.bedework.inoutsched.processors.SchedProcessor.SchedProcResult) EventInfo(org.bedework.calfacade.svc.EventInfo) CalSvcI(org.bedework.calsvci.CalSvcI) BwEvent(org.bedework.calfacade.BwEvent) SchedAttendeeUpdate(org.bedework.inoutsched.processors.SchedAttendeeUpdate)

Example 4 with CalSvcI

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));
    }
}
Also used : CalSvcI(org.bedework.calsvci.CalSvcI) BwIndexer(org.bedework.calfacade.indexing.BwIndexer)

Example 5 with CalSvcI

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();
}
Also used : CalSvcI(org.bedework.calsvci.CalSvcI)

Aggregations

CalSvcI (org.bedework.calsvci.CalSvcI)10 BwIndexer (org.bedework.calfacade.indexing.BwIndexer)3 EventInfo (org.bedework.calfacade.svc.EventInfo)3 BwEvent (org.bedework.calfacade.BwEvent)2 CalFacadeStaleStateException (org.bedework.calfacade.exc.CalFacadeStaleStateException)2 AccessType (org.bedework.caldav.util.sharing.AccessType)1 SetType (org.bedework.caldav.util.sharing.SetType)1 ShareType (org.bedework.caldav.util.sharing.ShareType)1 BwCalendar (org.bedework.calfacade.BwCalendar)1 BwPrincipal (org.bedework.calfacade.BwPrincipal)1 CalFacadeForbidden (org.bedework.calfacade.exc.CalFacadeForbidden)1 CalSvcFactoryDefault (org.bedework.calsvci.CalSvcFactoryDefault)1 CalSvcIPars (org.bedework.calsvci.CalSvcIPars)1 InCancel (org.bedework.inoutsched.processors.InCancel)1 InProcessor (org.bedework.inoutsched.processors.InProcessor)1 ProcessResult (org.bedework.inoutsched.processors.InProcessor.ProcessResult)1 InRefresh (org.bedework.inoutsched.processors.InRefresh)1 InReply (org.bedework.inoutsched.processors.InReply)1 InRequest (org.bedework.inoutsched.processors.InRequest)1 SchedAttendeeUpdate (org.bedework.inoutsched.processors.SchedAttendeeUpdate)1