Search in sources :

Example 1 with CalSvcFactoryDefault

use of org.bedework.calsvci.CalSvcFactoryDefault 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 CalSvcFactoryDefault

use of org.bedework.calsvci.CalSvcFactoryDefault in project bw-calendar-engine by Bedework.

the class CalSvc method init.

private void init(final CalSvcIPars parsParam, final boolean creating) throws CalFacadeException {
    pars = (CalSvcIPars) parsParam.clone();
    this.creating = creating;
    debug = getLogger().isDebugEnabled();
    final long start = System.currentTimeMillis();
    fixUsers();
    try {
        if (configs == null) {
            // Try again - failed at static init?
            configs = new CalSvcFactoryDefault().getSystemConfig();
        }
        open();
        beginTransaction();
        if (userGroups != null) {
            userGroups.init(getGroupsCallBack(), configs);
        }
        if (adminGroups != null) {
            adminGroups.init(getGroupsCallBack(), configs);
        }
        final SystemProperties sp = getSystemProperties();
        if (tzserverUri == null) {
            tzserverUri = sp.getTzServeruri();
            if (tzserverUri == null) {
                throw new CalFacadeException("No timezones server URI defined");
            }
            Timezones.initTimezones(tzserverUri);
            Timezones.setSystemDefaultTzid(sp.getTzid());
        }
        /* Some checks on parameter validity
       */
        // BwUser =
        tzstore = new TimeZonesStoreImpl(this);
        /* Nominate our timezone registry */
        System.setProperty("net.fortuna.ical4j.timezone.registry", "org.bedework.icalendar.TimeZoneRegistryFactoryImpl");
        if (!creating) {
            final String tzid = getPrefsHandler().get().getDefaultTzid();
            if (tzid != null) {
                Timezones.setThreadDefaultTzid(tzid);
            }
            // if (pars.getCaldav() && !pars.isGuest()) {
            if (!pars.isGuest()) {
            /* Ensure scheduling resources exist */
            // getCal().getSpecialCalendar(getPrincipal(), BwCalendar.calTypeInbox,
            // true, PrivilegeDefs.privAny);
            // getCal().getSpecialCalendar(getPrincipal(), BwCalendar.calTypeOutbox,
            // true, PrivilegeDefs.privAny);
            }
        }
        if ((pars.getPublicAdmin() || pars.getAllowSuperUser()) && (pars.getAuthUser() != null)) {
            ((SvciPrincipalInfo) principalInfo).setSuperUser(getSysparsHandler().isRootUser(principalInfo.getAuthPrincipal()));
        }
        postNotification(SysEvent.makePrincipalEvent(SysEvent.SysCode.USER_SVCINIT, getPrincipal(), System.currentTimeMillis() - start));
    } catch (final CalFacadeException cfe) {
        rollbackTransaction();
        cfe.printStackTrace();
        throw cfe;
    } catch (final Throwable t) {
        rollbackTransaction();
        t.printStackTrace();
        throw new CalFacadeException(t);
    } finally {
        try {
            endTransaction();
        } catch (final Throwable ignored) {
        }
        try {
            close();
        } catch (final Throwable ignored) {
        }
    }
}
Also used : CalSvcFactoryDefault(org.bedework.calsvci.CalSvcFactoryDefault) BasicSystemProperties(org.bedework.calfacade.configs.BasicSystemProperties) SystemProperties(org.bedework.calfacade.configs.SystemProperties) BwString(org.bedework.calfacade.BwString) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 3 with CalSvcFactoryDefault

use of org.bedework.calsvci.CalSvcFactoryDefault in project bw-calendar-engine by Bedework.

the class RestoreGlobals method init.

/**
 * @throws Throwable
 */
public void init() throws Throwable {
    Configurations conf = new CalSvcFactoryDefault().getSystemConfig();
    basicProps = conf.getBasicSystemProperties();
    syspars = conf.getSystemProperties();
}
Also used : CalSvcFactoryDefault(org.bedework.calsvci.CalSvcFactoryDefault) Configurations(org.bedework.calfacade.configs.Configurations)

Example 4 with CalSvcFactoryDefault

use of org.bedework.calsvci.CalSvcFactoryDefault in project bw-calendar-engine by Bedework.

the class BwDumpRestore method getSvci.

/**
 * Get an svci object and return it. Also embed it in this object.
 *
 * @return svci object
 * @throws CalFacadeException on fatal error
 */
private CalSvcI getSvci(final String owner, final boolean publick) throws CalFacadeException {
    if ((svci != null) && svci.isOpen()) {
        return svci;
    }
    boolean publicAdmin = false;
    if ((curSvciOwner == null) || !curSvciOwner.equals(owner)) {
        svci = null;
        curSvciOwner = owner;
        publicAdmin = publick;
    }
    if (svci == null) {
        final CalSvcIPars pars = CalSvcIPars.getIndexerPars(curSvciOwner, publicAdmin);
        // CalSvcIPars pars = CalSvcIPars.getServicePars(curSvciOwner,
        // publicAdmin,   // publicAdmin
        // true);   // Allow super user
        svci = new CalSvcFactoryDefault().getSvc(pars);
    }
    svci.open();
    svci.beginTransaction();
    return svci;
}
Also used : CalSvcFactoryDefault(org.bedework.calsvci.CalSvcFactoryDefault) CalSvcIPars(org.bedework.calsvci.CalSvcIPars)

Example 5 with CalSvcFactoryDefault

use of org.bedework.calsvci.CalSvcFactoryDefault in project bw-calendar-engine by Bedework.

the class BwSysIntfImpl method getSvci.

private CalSvcI getSvci(final String account, final String runAs, final boolean service, final boolean publicAdmin, final String clientId, final boolean allowCreateEprops) throws WebdavException {
    try {
        /* account is what we authenticated with.
       * user, if non-null, is the user calendar we want to access.
       */
        final boolean possibleSuperUser = // allow SuperUser
        "root".equals(account) || "admin".equals(account);
        String runAsUser = null;
        String clientIdent = null;
        if (possibleSuperUser) {
            runAsUser = runAs;
            clientIdent = clientId;
        }
        final CalSvcIPars pars = CalSvcIPars.getCaldavPars("bwcaldav", account, runAsUser, clientIdent, // allow SuperUser
        possibleSuperUser, service, publicAdmin, allowCreateEprops);
        svci = new CalSvcFactoryDefault().getSvc(pars);
        svci.open();
        svci.beginTransaction();
        trans = new IcalTranslator(svci.getIcalCallback());
    } catch (Throwable t) {
        throw new WebdavException(t);
    }
    return svci;
}
Also used : CalSvcFactoryDefault(org.bedework.calsvci.CalSvcFactoryDefault) CalSvcIPars(org.bedework.calsvci.CalSvcIPars) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) IcalTranslator(org.bedework.icalendar.IcalTranslator)

Aggregations

CalSvcFactoryDefault (org.bedework.calsvci.CalSvcFactoryDefault)7 CalSvcIPars (org.bedework.calsvci.CalSvcIPars)5 BwString (org.bedework.calfacade.BwString)1 BasicSystemProperties (org.bedework.calfacade.configs.BasicSystemProperties)1 Configurations (org.bedework.calfacade.configs.Configurations)1 SystemProperties (org.bedework.calfacade.configs.SystemProperties)1 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)1 CalSvcI (org.bedework.calsvci.CalSvcI)1 IcalTranslator (org.bedework.icalendar.IcalTranslator)1 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)1