Search in sources :

Example 76 with Configuration

use of org.apache.commons.configuration.Configuration in project midpoint by Evolveum.

the class ClusterManager method checkSystemConfigurationChanged.

/**
     * Check whether system configuration has not changed in repository (e.g. by another node in cluster).
     * Applies new configuration if so.
     *
     * @param parentResult
     */
public void checkSystemConfigurationChanged(OperationResult parentResult) {
    OperationResult result = parentResult.createSubresult(CHECK_SYSTEM_CONFIGURATION_CHANGED);
    PrismObject<SystemConfigurationType> systemConfiguration;
    try {
        PrismObject<SystemConfigurationType> config = getRepositoryService().getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, result);
        String versionInRepo = config.getVersion();
        String versionApplied = LoggingConfigurationManager.getCurrentlyUsedVersion();
        // we do not try to determine which one is "newer" - we simply use the one from repo
        if (!versionInRepo.equals(versionApplied)) {
            Configuration systemConfigFromFile = taskManager.getMidpointConfiguration().getConfiguration(MidpointConfiguration.SYSTEM_CONFIGURATION_SECTION);
            if (systemConfigFromFile != null && versionApplied == null && systemConfigFromFile.getBoolean(LoggingConfigurationManager.SYSTEM_CONFIGURATION_SKIP_REPOSITORY_LOGGING_SETTINGS, false)) {
                LOGGER.warn("Skipping application of repository logging configuration because {}=true (version={})", LoggingConfigurationManager.SYSTEM_CONFIGURATION_SKIP_REPOSITORY_LOGGING_SETTINGS, versionInRepo);
                // But pretend that this was applied so the next update works normally
                LoggingConfigurationManager.setCurrentlyUsedVersion(versionInRepo);
            } else {
                LoggingConfigurationType loggingConfig = ProfilingConfigurationManager.checkSystemProfilingConfiguration(config);
                LoggingConfigurationManager.configure(loggingConfig, versionInRepo, result);
            }
            SystemConfigurationHolder.setCurrentConfiguration(// we rely on LoggingConfigurationManager to correctly record the current version
            config.asObjectable());
            SecurityUtil.setRemoteHostAddressHeaders(config.asObjectable());
            getRepositoryService().applyFullTextSearchConfiguration(config.asObjectable().getFullTextSearch());
        } else {
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("System configuration change check: version in repo = version currently applied = {}", versionApplied);
            }
        }
        if (result.isUnknown()) {
            result.computeStatus();
        }
    } catch (ObjectNotFoundException e) {
        // because the new config (if any) will have version number probably starting at 1 - so to be sure to read it when it comes [hope this never occurs :)]
        LoggingConfigurationManager.resetCurrentlyUsedVersion();
        String message = "No system configuration found, skipping application of system settings";
        LOGGER.error(message + ": " + e.getMessage(), e);
        result.recordWarning(message, e);
    } catch (SchemaException e) {
        String message = "Schema error in system configuration, skipping application of system settings";
        LOGGER.error(message + ": " + e.getMessage(), e);
        result.recordWarning(message, e);
    } catch (RuntimeException e) {
        String message = "Runtime exception in system configuration processing, skipping application of system settings";
        LOGGER.error(message + ": " + e.getMessage(), e);
        result.recordWarning(message, e);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) MidpointConfiguration(com.evolveum.midpoint.common.configuration.api.MidpointConfiguration) Configuration(org.apache.commons.configuration.Configuration) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) LoggingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)

Example 77 with Configuration

use of org.apache.commons.configuration.Configuration in project midpoint by Evolveum.

the class ConfigurationLoadTest method t03complexConfigTest.

@Test(enabled = false)
public void t03complexConfigTest() {
    LOGGER.info("---------------- complexConfigTest -----------------");
    System.setProperty("midpoint.home", "target/midPointHome/");
    StartupConfiguration sc = new StartupConfiguration();
    assertNotNull(sc);
    sc.init();
    Configuration c = sc.getConfiguration("midpoint");
    assertEquals(c.getString("repository.repositoryServiceFactoryClass"), "com.evolveum.midpoint.repo.xml.XmlRepositoryServiceFactory");
    @SuppressWarnings("unchecked") Iterator<String> i = c.getKeys();
    while (i.hasNext()) {
        String key = i.next();
        LOGGER.info("  " + key + " = " + c.getString(key));
    }
    assertEquals(c.getString("repository.serverPath"), "target/midPointHome/");
    //cleanup
    System.clearProperty("midpoint.home");
}
Also used : Configuration(org.apache.commons.configuration.Configuration) Test(org.testng.annotations.Test)

Example 78 with Configuration

use of org.apache.commons.configuration.Configuration in project midpoint by Evolveum.

the class ConfigurablePrismContextFactory method registerExtensionSchemas.

@Override
protected void registerExtensionSchemas(SchemaRegistryImpl schemaRegistry) throws SchemaException {
    Configuration config = configuration.getConfiguration(CONFIGURATION_GLOBAL);
    if (config == null) {
        LOGGER.warn("Global part 'midpoint.global' is not defined in configuration file.");
        return;
    }
    String extensionDir = config.getString(EXTENSION_DIR);
    if (StringUtils.isEmpty(extensionDir)) {
        if (StringUtils.isNotEmpty(configuration.getMidpointHome())) {
            extensionDir = configuration.getMidpointHome() + "/schema";
        }
    }
    if (StringUtils.isNotEmpty(extensionDir)) {
        LOGGER.info("Loading extension schemas from folder '{}'.", new Object[] { extensionDir });
    } else {
        LOGGER.warn("Not loading extension schemas, extensionDir or even midpoint.home is not defined.");
        return;
    }
    try {
        File file = new File(extensionDir);
        if (!file.exists() || !file.isDirectory()) {
            LOGGER.warn("Extension dir '{}' does not exist, or is not a directory, skipping extension loading.", new Object[] { extensionDir });
            return;
        }
        schemaRegistry.registerPrismSchemasFromDirectory(file);
    } catch (Exception ex) {
        throw new SchemaException(ex.getMessage(), ex);
    }
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) MidpointConfiguration(com.evolveum.midpoint.common.configuration.api.MidpointConfiguration) Configuration(org.apache.commons.configuration.Configuration) File(java.io.File) SchemaException(com.evolveum.midpoint.util.exception.SchemaException)

Example 79 with Configuration

use of org.apache.commons.configuration.Configuration in project midpoint by Evolveum.

the class RepositoryFactory method init.

public void init() {
    Configuration config = midpointConfiguration.getConfiguration(REPOSITORY_CONFIGURATION);
    try {
        String className = getFactoryClassName(config);
        LOGGER.info("Repository factory class name from configuration '{}'.", new Object[] { className });
        Class<RepositoryServiceFactory> clazz = (Class<RepositoryServiceFactory>) Class.forName(className);
        factory = getFactoryBean(clazz);
        factory.init(config);
    } catch (Exception ex) {
        LoggingUtils.logException(LOGGER, "RepositoryServiceFactory implementation class {} failed to " + "initialize.", ex, config.getString(REPOSITORY_FACTORY_CLASS));
        throw new SystemException("RepositoryServiceFactory implementation class " + config.getString(REPOSITORY_FACTORY_CLASS) + " failed to initialize: " + ex.getMessage(), ex);
    }
}
Also used : MidpointConfiguration(com.evolveum.midpoint.common.configuration.api.MidpointConfiguration) Configuration(org.apache.commons.configuration.Configuration) RuntimeConfiguration(com.evolveum.midpoint.common.configuration.api.RuntimeConfiguration) SystemException(com.evolveum.midpoint.util.exception.SystemException) RepositoryServiceFactory(com.evolveum.midpoint.repo.api.RepositoryServiceFactory) BeansException(org.springframework.beans.BeansException) SystemException(com.evolveum.midpoint.util.exception.SystemException) RepositoryServiceFactoryException(com.evolveum.midpoint.repo.api.RepositoryServiceFactoryException)

Example 80 with Configuration

use of org.apache.commons.configuration.Configuration in project midpoint by Evolveum.

the class ConnectorFactoryConnIdImpl method initialize.

/**
	 * Initialize the ICF implementation. Look for all connector bundles, get
	 * basic information about them and keep that in memory.
	 */
@PostConstruct
public void initialize() {
    // OLD
    // bundleURLs = listBundleJars();
    bundleURLs = new HashSet<URL>();
    Configuration config = midpointConfiguration.getConfiguration("midpoint.icf");
    // Is classpath scan enabled
    if (config.getBoolean("scanClasspath")) {
        // Scan class path
        bundleURLs.addAll(scanClassPathForBundles());
    }
    // Scan all provided directories
    @SuppressWarnings("unchecked") List<String> dirs = config.getList("scanDirectory");
    for (String dir : dirs) {
        bundleURLs.addAll(scanDirectory(dir));
    }
    for (URL u : bundleURLs) {
        LOGGER.debug("ICF bundle URL : {}", u);
    }
    connectorInfoManagerFactory = ConnectorInfoManagerFactory.getInstance();
}
Also used : MidpointConfiguration(com.evolveum.midpoint.common.configuration.api.MidpointConfiguration) APIConfiguration(org.identityconnectors.framework.api.APIConfiguration) Configuration(org.apache.commons.configuration.Configuration) GuardedString(org.identityconnectors.common.security.GuardedString) URL(java.net.URL) PostConstruct(javax.annotation.PostConstruct)

Aggregations

Configuration (org.apache.commons.configuration.Configuration)185 Test (org.junit.Test)51 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)44 ZapXmlConfiguration (org.zaproxy.zap.utils.ZapXmlConfiguration)23 Test (org.testng.annotations.Test)22 File (java.io.File)14 AbstractConfiguration (org.apache.commons.configuration.AbstractConfiguration)13 MidpointConfiguration (com.evolveum.midpoint.common.configuration.api.MidpointConfiguration)11 Properties (java.util.Properties)10 HashMap (java.util.HashMap)9 AtlasException (org.apache.atlas.AtlasException)9 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)9 ArrayList (java.util.ArrayList)8 ZkUtils (kafka.utils.ZkUtils)8 ConfigurationException (org.apache.commons.configuration.ConfigurationException)8 IndexLoadingConfigMetadata (com.linkedin.pinot.common.metadata.segment.IndexLoadingConfigMetadata)7 AtlasClient (org.apache.atlas.AtlasClient)6 BeforeClass (org.testng.annotations.BeforeClass)6 MockResponse (com.github.bordertech.wcomponents.util.mock.MockResponse)5 IOException (java.io.IOException)5