private String getConfigDir() { if (coreConfigurationService == null) { return System.getProperty("user.home") + "/config"; } return coreConfigurationService.getConfigLocation().getLocation(); }
private File getDefaultBootstrapFile(ConfigLocation.FileAccessType accessType) { Iterable<ConfigLocation> configLocations = configLocationFileStore.getAll(); StringBuilder sb = new StringBuilder(""); for (ConfigLocation configLocation : configLocations) { sb.append(configLocation.getLocation()).append(' '); try { return configLocation.getFile(BOOTSTRAP_PROPERTIES, accessType); } catch (MotechConfigurationException e) { LOG.warn(e.getMessage()); } } throw new MotechConfigurationException(String.format("%s file is not %s from any of the default locations. Searched directories: %s.", BOOTSTRAP_PROPERTIES, accessType.toString(), sb)); }
@Override public ConfigLocation getConfigLocation() { Iterable<ConfigLocation> configLocations = configLocationFileStore.getAll(); StringBuilder sb = new StringBuilder(""); for (ConfigLocation configLocation : configLocations) { sb.append(configLocation.getLocation()).append(' '); Resource configLocationResource = configLocation.toResource(); try { Resource motechSettings = configLocationResource.createRelative(ConfigurationConstants.SETTINGS_FILE_NAME); if (motechSettings.isReadable()) { return configLocation; } logger.warn("Could not read motech-settings.properties from: " + configLocationResource.toString()); } catch (IOException e) { logger.warn("Problem reading motech-settings.properties from location: " + configLocationResource.toString(), e); } } throw new MotechConfigurationException(String.format("Could not read settings from any of the config locations. Searched directories: %s.", sb)); }
private void setupLocation() throws FileSystemException { ConfigLocation configLocation = coreConfigurationService.getConfigLocation(); monitoredDir = VFS.getManager().resolveFile(configLocation.getLocation()); fileMonitor.addFile(monitoredDir); LOGGER.info(String.format("Setting up monitoring for location: %s", monitoredDir)); }