try {
configurationFile = getConfigurationXmlFile(CONFIGURATION_FILE_NAME);
if(configurationFile == null){
configurationFile = getConfigurationXmlFile(OLD_CONFIGURATION_FILE_NAME);
if(configurationFile == null){
throw new ConfigurationException("Unable to find configuration file");
}
}
configurationFilePath = configurationFile.getAbsolutePath();
Document document = XmlUtility.parseXmlFile(configurationFile);
if (document != null) {
// setting up strategy
XmlConfigStrategy strategy = null;
Node node = document.selectSingleNode(VERSION_XPATH);
if (node != null && "2".equals(node.getText().trim())) {
strategy = new DefaultXmlStrategy(document);
} else {
strategy = new BackwardCompatibilityXmlStrategy(document);
}
initializeLocale(strategy);
initializeLookAndFeel(strategy);
initializeLoggingLevel(strategy);
initializePoolSize(strategy);
defaultWorkingDirectory = strategy.getDefaultWorkingDirectoryValue();
defaultEnvironment = strategy.getDefaultEnvironmentValue();
thumbnailsCreatorIdentifier = strategy.getThumbnailsCreatorIdentifierValue();
checkForUpdates = isValidTrueValue(strategy.getCheckForUpdatesValue());
playSounds = isValidTrueValue(strategy.getPlaySoundsValue());
pluginAbsolutePath = strategy.getPluginAbsolutePath();
askOverwriteConfirmation = isValidTrueValue(strategy.getAskOverwriteConfirmation());
consoleServicesFacade = new ConsoleServicesFacade();
strategy.close();
} else {
throw new ConfigurationException("Unable to parse xml configuration file.");
}
} catch (DocumentException e) {
throw new ConfigurationException(e);
} catch (UnsupportedEncodingException ue) {
throw new ConfigurationException(ue);
}
}