use of org.hisp.dhis.sms.config.SmsConfiguration in project dhis2-core by dhis2.
the class SmsConfigurationController method getTest.
@GetMapping("test")
@ResponseBody
public SmsConfiguration getTest() {
SmsConfiguration smsConfiguration = new SmsConfiguration();
SmsGatewayConfig gatewayConfig = new GenericHttpGatewayConfig();
gatewayConfig.setUrlTemplate("http://storset.org/");
smsConfiguration.setGateways(Collections.singletonList(gatewayConfig));
return smsConfiguration;
}
use of org.hisp.dhis.sms.config.SmsConfiguration in project dhis2-core by dhis2.
the class V2_34_6__Convert_systemsetting_value_column_from_bytea_to_string method fetchExistingSystemSettings.
private Set<SystemSetting> fetchExistingSystemSettings(final Context context) throws SQLException {
Set<SystemSetting> systemSettingsToConvert = new HashSet<>();
try (Statement stmt = context.getConnection().createStatement();
ResultSet rs = stmt.executeQuery("select * from systemsetting")) {
while (rs.next()) {
String name = rs.getString("name");
SystemSetting systemSetting = new SystemSetting();
systemSetting.setId(rs.getLong("systemsettingid"));
systemSetting.setName(name);
if (SMS_CONFIGURATION_SETTING_NAME.equals(name)) {
SmsConfiguration smsConfiguration = (SmsConfiguration) SerializationUtils.deserialize(rs.getBytes("value"));
updateSmsConfiguration(smsConfiguration);
systemSetting.setValue(smsConfiguration);
} else {
systemSetting.setValue((Serializable) SerializationUtils.deserialize(rs.getBytes("value")));
}
systemSettingsToConvert.add(systemSetting);
}
}
return systemSettingsToConvert;
}
use of org.hisp.dhis.sms.config.SmsConfiguration in project dhis2-core by dhis2.
the class DefaultSmsConfigurationManager method initializeSmsConfig.
private void initializeSmsConfig() {
SmsConfiguration smsConfiguration = getSmsConfiguration();
if (smsConfiguration == null) {
log.info("SMS configuration not found");
return;
}
List<SmsGatewayConfig> gatewayList = smsConfiguration.getGateways();
if (gatewayList == null || gatewayList.isEmpty()) {
log.info("Gateway configuration not found");
return;
}
log.info("Gateway configurations found: " + gatewayList);
gatewayAdminService.loadGatewayConfigurationMap(smsConfiguration);
}
use of org.hisp.dhis.sms.config.SmsConfiguration in project dhis2-core by dhis2.
the class DefaultSmsConfigurationManager method setDefaultSMSGateway.
@Override
public boolean setDefaultSMSGateway(String gatewayId) {
boolean result = false;
SmsConfiguration config = getSmsConfiguration();
if (config == null) {
return result;
}
List<SmsGatewayConfig> smsGatewayList = config.getGateways();
for (SmsGatewayConfig gw : smsGatewayList) {
if (gw.getName().equals(gatewayId)) {
gw.setDefault(true);
result = true;
} else {
gw.setDefault(false);
}
}
updateSmsConfiguration(config);
return result;
}
use of org.hisp.dhis.sms.config.SmsConfiguration in project dhis2-core by dhis2.
the class DefaultSmsConfigurationManager method checkInstanceOfGateway.
@Override
public SmsGatewayConfig checkInstanceOfGateway(Class<?> clazz) {
if (getSmsConfiguration() == null) {
SmsConfiguration smsConfig = new SmsConfiguration(true);
updateSmsConfiguration(smsConfig);
}
for (SmsGatewayConfig gateway : getSmsConfiguration().getGateways()) {
if (gateway.getClass().equals(clazz)) {
return gateway;
}
}
return null;
}
Aggregations