use of org.motechproject.config.core.exception.MotechConfigurationException in project motech by motech.
the class BootstrapManagerImpl method readBootstrapConfigFromFile.
private BootstrapConfig readBootstrapConfigFromFile(File configFile, String errorMessage) {
try {
LOGGER.debug("Trying to load bootstrap configuration from " + configFile.getAbsolutePath());
Properties properties = ConfigPropertiesUtils.getPropertiesFromFile(configFile);
return BootstrapConfigPropertyMapper.fromProperties(properties);
} catch (IOException e) {
throw new MotechConfigurationException("Error loading bootstrap properties from config file " + configFile + " " + errorMessage, e);
}
}
use of org.motechproject.config.core.exception.MotechConfigurationException in project motech by motech.
the class QueueURLValidator method validateUriContainSpecificScheme.
private void validateUriContainSpecificScheme(String queueUrl, URI uri) {
String scheme = uri.getScheme();
if (scheme != null && ("static".equals(scheme) || "broker".equals(scheme))) {
if (isCompositeURI(uri)) {
try {
URISupport.CompositeData data = parseComposite(uri);
validateCompositeDataUri(queueUrl, data);
} catch (URISyntaxException e) {
throw new MotechConfigurationException(URL_INVALID, e);
}
} else {
isValidUri(queueUrl, uri.toString());
}
} else {
isValidUri(queueUrl, uri.toString());
}
}
use of org.motechproject.config.core.exception.MotechConfigurationException in project motech by motech.
the class DbConfigManagerImpl method getProperties.
private Properties getProperties(String fileName, String varName, String descForLogs) {
String configLocation = environment.getConfigDir();
Properties properties;
if (StringUtils.isNotBlank(configLocation)) {
return readPropertiesFromFile(new File(configLocation, fileName), descForLogs);
}
properties = environment.getProperties(varName);
if (properties != null && !properties.isEmpty()) {
return properties;
}
LOGGER.debug("Could not find all {} configuration values from environment variables. So, trying to load from classpath", descForLogs);
try {
LOGGER.debug("Loading {} properties from default configuration directory", descForLogs);
properties = loadPropertiesFromDefaultLocation(fileName, descForLogs);
} catch (MotechConfigurationException e) {
LOGGER.warn(e.getMessage());
}
LOGGER.debug("Loading {} properties from classpath", descForLogs);
if (properties == null || properties.isEmpty()) {
properties = loadPropertiesFromClasspath(fileName, descForLogs);
}
return properties;
}
use of org.motechproject.config.core.exception.MotechConfigurationException in project motech by motech.
the class ConfigLoader method loadMotechSettings.
/**
* Loads MOTECH settings containing core platform settings.
*
* @return the {SettingsRecord} object
*/
public SettingsRecord loadMotechSettings() {
SettingsRecord settingsRecord;
ConfigLocation configLocation = coreConfigurationService.getConfigLocation();
Resource configLocationResource = configLocation.toResource();
try {
Resource motechSettings = configLocationResource.createRelative(ConfigurationConstants.SETTINGS_FILE_NAME);
settingsRecord = loadSettingsFromStream(motechSettings);
settingsRecord.setFilePath(configLocationResource.getURL().getPath());
checkSettingsRecord(settingsRecord);
} catch (IOException e) {
throw new MotechConfigurationException(String.format("Could not read settings from file at location %s", configLocation), e);
}
return settingsRecord;
}
Aggregations