/** * Overridden to: * * <ul> * <li>Store {@code configuration} for later passing to {@link PentahoEntryCollector}. * <li>Add JCR_READ_ACCESS_CONTROL to root ACL. This is harmless and avoids more customization. * </ul> */ @Override public void init(final Session systemSession, final Map conf) throws RepositoryException { this.configuration = conf; ISystemConfig settings = PentahoSystem.get(ISystemConfig.class); if (settings != null) { useCachingEntryCollector = "true".equals(settings.getProperty("system.cachingEntryCollector")); } super.init(systemSession, conf); // original initRootACL should run during super.init call above updateRootAcl((SessionImpl) systemSession, new ACLEditor(session, this)); }
private String getServerParameter(String paramName, boolean suppressWarning) { String result = context.getInitParameter(paramName); if (result == null) { ISystemConfig config = PentahoSystem.get(ISystemConfig.class); result = config.getProperty("server." + paramName); } else { if (!suppressWarning) { logger.warn( Messages.getInstance() .getString( "SolutionContextListener.WARN_WEB_XML_PARAM_DEPRECATED", paramName, result)); //$NON-NLS-1$ } } return result; }
public void contextInitialized(final ServletContextEvent event) { context = event.getServletContext(); String encoding = getServerParameter("encoding"); // $NON-NLS-1$ if (encoding != null) { LocaleHelper.setSystemEncoding(encoding); } String textDirection = getServerParameter("text-direction"); // $NON-NLS-1$ if (textDirection != null) { LocaleHelper.setTextDirection(textDirection); } String localeLanguage = getServerParameter("locale-language"); // $NON-NLS-1$ String localeCountry = getServerParameter("locale-country"); // $NON-NLS-1$ boolean localeSet = false; if (!StringUtils.isEmpty(localeLanguage) && !StringUtils.isEmpty(localeCountry)) { Locale[] locales = Locale.getAvailableLocales(); if (locales != null) { for (Locale element : locales) { if (element.getLanguage().equals(localeLanguage) && element.getCountry().equals(localeCountry)) { LocaleHelper.setLocale(element); localeSet = true; break; } } } } if (!localeSet) { // do this thread in the default locale LocaleHelper.setLocale(Locale.getDefault()); } LocaleHelper.setDefaultLocale(LocaleHelper.getLocale()); // log everything that goes on here logger.info( Messages.getInstance() .getString("SolutionContextListener.INFO_INITIALIZING")); // $NON-NLS-1$ logger.info( Messages.getInstance() .getString("SolutionContextListener.INFO_SERVLET_CONTEXT", context)); // $NON-NLS-1$ SolutionContextListener.contextPath = context.getRealPath(""); // $NON-NLS-1$ logger.info( Messages.getInstance() .getString( "SolutionContextListener.INFO_CONTEXT_PATH", SolutionContextListener.contextPath)); // $NON-NLS-1$ SolutionContextListener.solutionPath = PentahoHttpSessionHelper.getSolutionPath(context); if (StringUtils.isEmpty(SolutionContextListener.solutionPath)) { String errorMsg = Messages.getInstance() .getErrorString("SolutionContextListener.ERROR_0001_NO_ROOT_PATH"); // $NON-NLS-1$ logger.error(errorMsg); /* * Since we couldn't find solution repository path there is no point in going forward and the user should know * that a major config setting was not found. So we are throwing in a RunTimeException with the requisite message. */ throw new RuntimeException(errorMsg); } logger.info( Messages.getInstance() .getString( "SolutionContextListener.INFO_ROOT_PATH", SolutionContextListener.solutionPath)); // $NON-NLS-1$ String fullyQualifiedServerUrl = getServerParameter("fully-qualified-server-url"); // $NON-NLS-1$ if (fullyQualifiedServerUrl == null) { // assume this is a demo installation // TODO: Create a servlet that's loaded on startup to set this value fullyQualifiedServerUrl = "http://localhost:8080/pentaho/"; // $NON-NLS-1$ } IApplicationContext applicationContext = new WebApplicationContext( SolutionContextListener.solutionPath, fullyQualifiedServerUrl, context.getRealPath(""), context); //$NON-NLS-1$ /* * Copy out all the Server.properties from to the application context */ Properties props = new Properties(); ISystemConfig systemConfig = PentahoSystem.get(ISystemConfig.class); if (systemConfig != null) { IConfiguration config = systemConfig.getConfiguration("server"); if (config != null) { try { props.putAll(config.getProperties()); } catch (IOException e) { logger.error("Could not find/read the server.properties file."); } } } /* * Copy out all the initParameter values from the servlet context and put them in the application context. */ Enumeration<?> initParmNames = context.getInitParameterNames(); String initParmName; while (initParmNames.hasMoreElements()) { initParmName = (String) initParmNames.nextElement(); props.setProperty(initParmName, getServerParameter(initParmName, true)); } ((WebApplicationContext) applicationContext).setProperties(props); setSystemCfgFile(context); setObjectFactory(context); PentahoSystem.init(applicationContext, true); final String fullyQualifiedServerUrlOut = fullyQualifiedServerUrl; ServerStatusProvider.getInstance() .registerServerStatusChangeListener( new IServerStatusChangeListener() { @Override public void onStatusChange() { if (ServerStatusProvider.getInstance().getStatus() != IServerStatusProvider.ServerStatus.STARTING) { showInitializationMessage( ServerStatusProvider.getInstance().getStatus() == IServerStatusProvider.ServerStatus.STARTED, fullyQualifiedServerUrlOut); } ServerStatusProvider.getInstance().removeServerStatusChangeListener(this); } }); }