public SettingsRecord getSettings() { SettingsRecord settingRecord = settingService.retrieve("id", 1); return (settingRecord == null ? new SettingsRecord() : settingRecord); }
private SettingsRecord loadSettingsFromStream(org.springframework.core.io.Resource motechSettings) { try { MessageDigest digest = MessageDigest.getInstance("MD5"); try (DigestInputStream dis = new DigestInputStream(motechSettings.getInputStream(), digest)) { //load configFileSettings and calculate MD5 hash SettingsRecord settingsRecord = new SettingsRecord(); settingsRecord.load(dis); settingsRecord.setConfigFileChecksum(new String(digest.digest())); return settingsRecord; // startup loaded } catch (IOException e) { throw new MotechException("Error loading configuration", e); } } catch (NoSuchAlgorithmException e) { throw new MotechException("MD5 algorithm not available", e); } }
private SettingsRecord loadSettingsFromStream(Resource motechSettings) { try { MessageDigest digest = MessageDigest.getInstance("MD5"); try (DigestInputStream dis = new DigestInputStream(motechSettings.getInputStream(), digest)) { //load configFileSettings and calculate MD5 hash SettingsRecord settingsRecord = new SettingsRecord(); settingsRecord.load(dis); settingsRecord.setConfigFileChecksum(new String(digest.digest())); return settingsRecord; // startup loaded } catch (IOException e) { throw new MotechException("Error loading configuration", e); } } catch (NoSuchAlgorithmException e) { throw new MotechException("MD5 algorithm not available", e); } }
@Override public Properties exportPlatformSettings() { MotechSettings currentSettings = configLoader.loadMotechSettings(); SettingsRecord settingsRecord = settingService.retrieve("id", 1); SettingsRecord dbSettings = (settingsRecord == null ? new SettingsRecord() : settingsRecord); Properties export = new Properties(); if (currentSettings != null) { export.putAll(currentSettings.asProperties()); } if (dbSettings != null) { export.putAll(dbSettings.getActivemqProperties()); export.put(ConfigurationConstants.LANGUAGE, dbSettings.getLanguage()); } return export; } }