Search in sources :

Example 1 with SystemProperties

use of org.bedework.calfacade.configs.SystemProperties 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 2 with SystemProperties

use of org.bedework.calfacade.configs.SystemProperties in project bw-calendar-engine by Bedework.

the class CalSvcFactoryDefault method getPr.

public static Properties getPr() throws CalFacadeException {
    final InputStream is = null;
    try {
        final SystemProperties sysProps = CalSvcFactoryDefault.getSystemProperties();
        /* Load properties file */
        final Properties pr = new Properties();
        if (Util.isEmpty(sysProps.getSyseventsProperties())) {
            throw new CalFacadeException("No sysevent properties defined");
        }
        final StringBuilder sb = new StringBuilder();
        @SuppressWarnings("unchecked") final List<String> ps = sysProps.getSyseventsProperties();
        for (final String p : ps) {
            sb.append(p);
            sb.append("\n");
        }
        pr.load(new StringReader(sb.toString()));
        return pr;
    } catch (final CalFacadeException cfe) {
        throw cfe;
    } catch (final Throwable t) {
        // Logger.getLogger(CalSvcFactoryDefault.class.getName()).throwing(CalSvcFactory.class, t);
        throw new CalFacadeException(t.getMessage());
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (final Throwable ignored) {
            }
        }
    }
}
Also used : SystemProperties(org.bedework.calfacade.configs.SystemProperties) InputStream(java.io.InputStream) StringReader(java.io.StringReader) Properties(java.util.Properties) SystemProperties(org.bedework.calfacade.configs.SystemProperties) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 3 with SystemProperties

use of org.bedework.calfacade.configs.SystemProperties in project bw-calendar-engine by Bedework.

the class JmsConnectionHandler method getPr.

/* ====================================================================
   *                   Protected methods
   * ==================================================================== */
private static Properties getPr() throws NotificationException {
    synchronized (lockit) {
        if (pr != null) {
            return pr;
        }
        InputStream is = null;
        try {
            final SystemProperties sysProps = CalSvcFactoryDefault.getSystemProperties();
            /* Load properties file */
            pr = new Properties();
            if (!Util.isEmpty(sysProps.getSyseventsProperties())) {
                final StringBuilder sb = new StringBuilder();
                @SuppressWarnings("unchecked") final List<String> ps = sysProps.getSyseventsProperties();
                for (final String p : ps) {
                    sb.append(p);
                    sb.append("\n");
                }
                pr.load(new StringReader(sb.toString()));
                return pr;
            }
            /* Do it using the file */
            try {
                // The jboss?? way - should work for others as well.
                final ClassLoader cl = Thread.currentThread().getContextClassLoader();
                is = cl.getResourceAsStream(propertiesFile);
            } catch (final Throwable ignored) {
            }
            if (is == null) {
                // Try another way
                is = JmsConnectionHandler.class.getResourceAsStream(propertiesFile);
            }
            if (is == null) {
                throw new NotificationException("Unable to load properties file \"" + propertiesFile + "\"");
            }
            pr.load(is);
            return pr;
        } catch (final NotificationException cee) {
            throw cee;
        } catch (final Throwable t) {
            Logger.getLogger(JmsConnectionHandler.class).error("getEnv error", t);
            throw new NotificationException(t.getMessage());
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (final Throwable ignored) {
                }
            }
        }
    }
}
Also used : SystemProperties(org.bedework.calfacade.configs.SystemProperties) InputStream(java.io.InputStream) StringReader(java.io.StringReader) Properties(java.util.Properties) SystemProperties(org.bedework.calfacade.configs.SystemProperties)

Aggregations

SystemProperties (org.bedework.calfacade.configs.SystemProperties)3 InputStream (java.io.InputStream)2 StringReader (java.io.StringReader)2 Properties (java.util.Properties)2 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)2 BwString (org.bedework.calfacade.BwString)1 BasicSystemProperties (org.bedework.calfacade.configs.BasicSystemProperties)1 CalSvcFactoryDefault (org.bedework.calsvci.CalSvcFactoryDefault)1