Search in sources :

Example 1 with ConfigurationFile

use of com.helger.photon.core.configfile.ConfigurationFile in project phoss-directory by phax.

the class AppWebAppListener method initGlobalSettings.

@Override
protected void initGlobalSettings() {
    // Internal stuff:
    VendorInfo.setVendorName("Philip Helger");
    VendorInfo.setVendorURL("http://www.helger.com");
    VendorInfo.setVendorEmail("pd@helger.com");
    VendorInfo.setVendorLocation("Vienna, Austria");
    VendorInfo.setInceptionYear(2015);
    if (PDServerConfiguration.isForceRoot()) {
        // Enforce an empty context path according to the specs!
        ServletContextPathHolder.setCustomContextPath("");
    }
    if (GlobalDebug.isProductionMode())
        ValueEnforcer.setEnabled(false);
    // By disabling these settings, less audits are created hence less calls are
    // blocking
    RequestTrackerSettings.setLongRunningRequestsCheckEnabled(false);
    RequestTrackerSettings.setParallelRunningRequestsCheckEnabled(false);
    RequestParameterManager.getInstance().setParameterHandler(new RequestParameterHandlerURLPathNamed());
    AppInternalErrorHandler.doSetup();
    final ConfigurationFileManager aCfgMgr = ConfigurationFileManager.getInstance();
    aCfgMgr.registerConfigurationFile(new ConfigurationFile(new ClassPathResource("log4j2.xml")).setDescription("log4j configuration file").setSyntaxHighlightLanguage(EConfigurationFileSyntax.XML));
    aCfgMgr.registerAll(PDServerConfiguration.getConfig());
    // Job scheduling etc
    if (GlobalDebug.isDebugMode())
        GlobalQuartzScheduler.getInstance().addJobListener(new LoggingJobListener());
}
Also used : ConfigurationFileManager(com.helger.photon.core.configfile.ConfigurationFileManager) RequestParameterHandlerURLPathNamed(com.helger.photon.core.requestparam.RequestParameterHandlerURLPathNamed) ConfigurationFile(com.helger.photon.core.configfile.ConfigurationFile) LoggingJobListener(com.helger.schedule.quartz.listener.LoggingJobListener) ClassPathResource(com.helger.commons.io.resource.ClassPathResource)

Example 2 with ConfigurationFile

use of com.helger.photon.core.configfile.ConfigurationFile in project phoss-smp by phax.

the class SMPWebAppListener method initManagers.

@Override
protected void initManagers() {
    {
        LOGGER.info("Init of ConfigurationFileManager");
        final ConfigurationFileManager aCFM = ConfigurationFileManager.getInstance();
        aCFM.registerConfigurationFile(new ConfigurationFile(new ClassPathResource("log4j2.xml")).setDescription("Log4J2 configuration").setSyntaxHighlightLanguage(EConfigurationFileSyntax.XML));
        aCFM.registerConfigurationFile(new ConfigurationFile(SMPWebAppConfiguration.getSettingsResource()).setDescription("SMP web application configuration").setSyntaxHighlightLanguage(EConfigurationFileSyntax.PROPERTIES));
        final IReadableResource aConfigRes = SMPServerConfiguration.getConfigFile().getReadResource();
        if (aConfigRes != null) {
            aCFM.registerConfigurationFile(new ConfigurationFile(aConfigRes).setDescription("SMP server configuration").setSyntaxHighlightLanguage(EConfigurationFileSyntax.PROPERTIES));
        }
        aCFM.registerAll(PDClientConfiguration.getConfig());
    }
    {
        LOGGER.info("Init of Directory client stuff");
        // If the SMP settings change, the PD client must be re-created
        SMPMetaManager.getSettingsMgr().callbacks().add(x -> PDClientProvider.getInstance().resetPDClient());
        // Callback on BusinessCard manager - if something happens, notify PD
        // server
        final ISMPBusinessCardManager aBusinessCardMgr = SMPMetaManager.getBusinessCardMgr();
        if (aBusinessCardMgr != null) {
            aBusinessCardMgr.bcCallbacks().add(new ISMPBusinessCardCallback() {

                public void onSMPBusinessCardCreatedOrUpdated(@Nonnull final ISMPBusinessCard aBusinessCard) {
                    final ISMPSettings aSettings = SMPMetaManager.getSettings();
                    if (aSettings.isDirectoryIntegrationEnabled() && aSettings.isDirectoryIntegrationAutoUpdate()) {
                        // Notify PD server: add
                        PDClientProvider.getInstance().getPDClient().addServiceGroupToIndex(aBusinessCard.getParticipantIdentifier());
                    }
                }

                public void onSMPBusinessCardDeleted(@Nonnull final ISMPBusinessCard aBusinessCard) {
                    final ISMPSettings aSettings = SMPMetaManager.getSettings();
                    if (aSettings.isDirectoryIntegrationEnabled() && aSettings.isDirectoryIntegrationAutoUpdate()) {
                        // Notify PD server: delete
                        PDClientProvider.getInstance().getPDClient().deleteServiceGroupFromIndex(aBusinessCard.getParticipantIdentifier());
                    }
                }
            });
            // If a service information is create, updated or deleted, also update
            // Business Card at PD
            SMPMetaManager.getServiceInformationMgr().serviceInformationCallbacks().add(new ISMPServiceInformationCallback() {

                @Override
                public void onSMPServiceInformationCreated(@Nonnull final ISMPServiceInformation aServiceInformation) {
                    final ISMPSettings aSettings = SMPMetaManager.getSettings();
                    if (aSettings.isDirectoryIntegrationEnabled() && aSettings.isDirectoryIntegrationAutoUpdate()) {
                        // Only if a business card is present
                        if (aBusinessCardMgr.containsSMPBusinessCardOfServiceGroup(aServiceInformation.getServiceGroup())) {
                            // Notify PD server: update
                            PDClientProvider.getInstance().getPDClient().addServiceGroupToIndex(aServiceInformation.getServiceGroup().getParticipantIdentifier());
                        }
                    }
                }

                @Override
                public void onSMPServiceInformationUpdated(@Nonnull final ISMPServiceInformation aServiceInformation) {
                    onSMPServiceInformationCreated(aServiceInformation);
                }

                @Override
                public void onSMPServiceInformationDeleted(@Nonnull final ISMPServiceInformation aServiceInformation) {
                    onSMPServiceInformationCreated(aServiceInformation);
                }
            });
        }
    }
    {
        LOGGER.info("Init of HTTP and Proxy settings");
        // Register global proxy servers
        ProxySelectorProxySettingsManager.setAsDefault(true);
        final IProxySettings aProxyHttp = SMPServerConfiguration.getAsHttpProxySettings();
        if (aProxyHttp != null) {
            // Register a handler that returns the "http" proxy, if an "http" URL is
            // requested
            ProxySettingsManager.registerProvider((sProtocol, sHost, nPort) -> "http".equals(sProtocol) ? new CommonsArrayList<>(aProxyHttp) : null);
        }
        final IProxySettings aProxyHttps = SMPServerConfiguration.getAsHttpsProxySettings();
        if (aProxyHttps != null) {
            // Register a handler that returns the "https" proxy, if an "https" URL
            // is
            // requested
            ProxySettingsManager.registerProvider((sProtocol, sHost, nPort) -> "https".equals(sProtocol) ? new CommonsArrayList<>(aProxyHttps) : null);
        }
    }
    // Special http client config
    BasePageUtilsHttpClient.HttpClientConfigRegistry.register(new HttpClientConfig("directoryclient", "Directory client settings", PDHttpClientSettings::new));
    LOGGER.info("Finished init of managers");
}
Also used : CSMPServer(com.helger.phoss.smp.CSMPServer) PDClientProvider(com.helger.phoss.smp.app.PDClientProvider) PDTConfig(com.helger.commons.datetime.PDTConfig) ILocaleManager(com.helger.photon.core.locale.ILocaleManager) ProxySelectorProxySettingsManager(com.helger.network.proxy.ProxySelectorProxySettingsManager) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) LoggerFactory(org.slf4j.LoggerFactory) PDClientConfiguration(com.helger.pd.client.PDClientConfiguration) SLF4JBridgeHandler(org.slf4j.bridge.SLF4JBridgeHandler) CApplicationID(com.helger.photon.core.appid.CApplicationID) PDTFactory(com.helger.commons.datetime.PDTFactory) SMPCommonUI(com.helger.phoss.smp.ui.SMPCommonUI) UnifiedResponseDefaultSettings(com.helger.servlet.response.UnifiedResponseDefaultSettings) TimeZone(java.util.TimeZone) ConfigurationFile(com.helger.photon.core.configfile.ConfigurationFile) IReadableResource(com.helger.commons.io.resource.IReadableResource) OffsetDateTime(java.time.OffsetDateTime) IProxySettings(com.helger.network.proxy.settings.IProxySettings) InitializationException(com.helger.commons.exception.InitializationException) IAjaxRegistry(com.helger.photon.ajax.IAjaxRegistry) RegExHelper(com.helger.commons.regex.RegExHelper) RequestTrackerSettings(com.helger.xservlet.requesttrack.RequestTrackerSettings) SMPWebAppConfiguration(com.helger.phoss.smp.app.SMPWebAppConfiguration) WSHelper(com.helger.wsclient.WSHelper) ProxySettingsManager(com.helger.network.proxy.settings.ProxySettingsManager) ServletContextPathHolder(com.helger.servlet.ServletContextPathHolder) ISMPBusinessCard(com.helger.phoss.smp.domain.businesscard.ISMPBusinessCard) ISMPBusinessCardManager(com.helger.phoss.smp.domain.businesscard.ISMPBusinessCardManager) MenuPublic(com.helger.phoss.smp.ui.pub.MenuPublic) PhotonGlobalState(com.helger.photon.core.appid.PhotonGlobalState) SMPSecurity(com.helger.phoss.smp.app.SMPSecurity) RequestParameterManager(com.helger.photon.core.requestparam.RequestParameterManager) WebAppListenerBootstrap(com.helger.photon.bootstrap4.servlet.WebAppListenerBootstrap) IPrivilegedAction(com.helger.commons.lang.priviledged.IPrivilegedAction) ISMPServiceInformationCallback(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationCallback) GlobalDebug(com.helger.commons.debug.GlobalDebug) Nonnull(javax.annotation.Nonnull) ConfigurationFileManager(com.helger.photon.core.configfile.ConfigurationFileManager) Nullable(javax.annotation.Nullable) ArrayHelper(com.helger.commons.collection.ArrayHelper) Logger(org.slf4j.Logger) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) BasePageUtilsHttpClient(com.helger.photon.bootstrap4.pages.utils.BasePageUtilsHttpClient) StringHelper(com.helger.commons.string.StringHelper) SMPMetaManager(com.helger.phoss.smp.domain.SMPMetaManager) MenuSecure(com.helger.phoss.smp.ui.secure.MenuSecure) RequestParameterHandlerURLPathNamed(com.helger.photon.core.requestparam.RequestParameterHandlerURLPathNamed) CAjax(com.helger.phoss.smp.ui.ajax.CAjax) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) PDHttpClientSettings(com.helger.pd.client.PDHttpClientSettings) ISMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation) SMPServerConfiguration(com.helger.phoss.smp.SMPServerConfiguration) ISMPBusinessCardCallback(com.helger.phoss.smp.domain.businesscard.ISMPBusinessCardCallback) HttpClientConfig(com.helger.photon.bootstrap4.pages.utils.BasePageUtilsHttpClient.HttpClientConfig) ServletContext(javax.servlet.ServletContext) EConfigurationFileSyntax(com.helger.photon.core.configfile.EConfigurationFileSyntax) MenuTree(com.helger.photon.core.menu.MenuTree) ISMPBusinessCardCallback(com.helger.phoss.smp.domain.businesscard.ISMPBusinessCardCallback) HttpClientConfig(com.helger.photon.bootstrap4.pages.utils.BasePageUtilsHttpClient.HttpClientConfig) ConfigurationFileManager(com.helger.photon.core.configfile.ConfigurationFileManager) Nonnull(javax.annotation.Nonnull) IReadableResource(com.helger.commons.io.resource.IReadableResource) ISMPServiceInformationCallback(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationCallback) ISMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) ISMPBusinessCard(com.helger.phoss.smp.domain.businesscard.ISMPBusinessCard) IProxySettings(com.helger.network.proxy.settings.IProxySettings) ISMPBusinessCardManager(com.helger.phoss.smp.domain.businesscard.ISMPBusinessCardManager) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) ConfigurationFile(com.helger.photon.core.configfile.ConfigurationFile)

Aggregations

ClassPathResource (com.helger.commons.io.resource.ClassPathResource)2 ConfigurationFile (com.helger.photon.core.configfile.ConfigurationFile)2 ConfigurationFileManager (com.helger.photon.core.configfile.ConfigurationFileManager)2 RequestParameterHandlerURLPathNamed (com.helger.photon.core.requestparam.RequestParameterHandlerURLPathNamed)2 ArrayHelper (com.helger.commons.collection.ArrayHelper)1 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)1 PDTConfig (com.helger.commons.datetime.PDTConfig)1 PDTFactory (com.helger.commons.datetime.PDTFactory)1 GlobalDebug (com.helger.commons.debug.GlobalDebug)1 InitializationException (com.helger.commons.exception.InitializationException)1 IReadableResource (com.helger.commons.io.resource.IReadableResource)1 IPrivilegedAction (com.helger.commons.lang.priviledged.IPrivilegedAction)1 RegExHelper (com.helger.commons.regex.RegExHelper)1 StringHelper (com.helger.commons.string.StringHelper)1 ProxySelectorProxySettingsManager (com.helger.network.proxy.ProxySelectorProxySettingsManager)1 IProxySettings (com.helger.network.proxy.settings.IProxySettings)1 ProxySettingsManager (com.helger.network.proxy.settings.ProxySettingsManager)1 PDClientConfiguration (com.helger.pd.client.PDClientConfiguration)1 PDHttpClientSettings (com.helger.pd.client.PDHttpClientSettings)1 CSMPServer (com.helger.phoss.smp.CSMPServer)1