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);
}
}
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");
}
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);
}
}
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);
}
}
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();
}
Aggregations