use of org.hisp.dhis.sms.config.SmsConfiguration in project dhis2-core by dhis2.
the class DefaultSmsConfigurationManager method gatewayExists.
@Override
public boolean gatewayExists(String gatewayId) {
SmsConfiguration config = getSmsConfiguration();
List<SmsGatewayConfig> gatewayList = config.getGateways();
for (SmsGatewayConfig gw : gatewayList) {
if (gw.getName().equals(gatewayId)) {
return true;
}
}
return false;
}
use of org.hisp.dhis.sms.config.SmsConfiguration in project dhis2-core by dhis2.
the class SaveSmsConfigurationAction method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
SmsConfiguration smsConfig = smsConfigurationManager.getSmsConfiguration();
if (smsConfig == null) {
smsConfig = new SmsConfiguration(true);
}
smsConfigurationManager.updateSmsConfiguration(smsConfig);
return SUCCESS;
}
use of org.hisp.dhis.sms.config.SmsConfiguration in project dhis2-core by dhis2.
the class UpdateBulkGateWayConfigAction method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
if (gatewayType != null && gatewayType.equals("bulksms")) {
SmsConfiguration smsConfig = smsConfigurationManager.getSmsConfiguration();
if (smsConfig != null) {
BulkSmsGatewayConfig bulkGatewayConfig = (BulkSmsGatewayConfig) smsConfigurationManager.checkInstanceOfGateway(BulkSmsGatewayConfig.class);
int index = -1;
if (bulkGatewayConfig == null) {
bulkGatewayConfig = new BulkSmsGatewayConfig();
} else {
index = smsConfig.getGateways().indexOf(bulkGatewayConfig);
}
bulkGatewayConfig.setName(name);
bulkGatewayConfig.setPassword(password);
bulkGatewayConfig.setUsername(username);
bulkGatewayConfig.setUid(CodeGenerator.generateCode(10));
if (smsConfig.getGateways() == null || smsConfig.getGateways().isEmpty()) {
bulkGatewayConfig.setDefault(true);
}
if (index >= 0) {
smsConfig.getGateways().set(index, bulkGatewayConfig);
} else {
smsConfig.getGateways().add(bulkGatewayConfig);
}
gatewayAdminService.getGatewayConfigurationMap().put(name, bulkGatewayConfig);
smsConfigurationManager.updateSmsConfiguration(smsConfig);
}
}
return SUCCESS;
}
use of org.hisp.dhis.sms.config.SmsConfiguration in project dhis2-core by dhis2.
the class UpdateClickatellGateWayConfigAction method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
if (gatewayType != null && gatewayType.equals("clickatell")) {
SmsConfiguration config = smsConfigurationManager.getSmsConfiguration();
if (config != null) {
ClickatellGatewayConfig gatewayConfig = (ClickatellGatewayConfig) smsConfigurationManager.checkInstanceOfGateway(ClickatellGatewayConfig.class);
int index = -1;
if (gatewayConfig == null) {
gatewayConfig = new ClickatellGatewayConfig();
} else {
index = config.getGateways().indexOf(gatewayConfig);
}
gatewayConfig.setName(name);
gatewayConfig.setPassword(password);
gatewayConfig.setUsername(username);
gatewayConfig.setUid(CodeGenerator.generateCode(10));
gatewayConfig.setAuthToken(authToken);
if (config.getGateways() == null || config.getGateways().isEmpty()) {
gatewayConfig.setDefault(true);
}
if (index >= 0) {
config.getGateways().set(index, gatewayConfig);
} else {
config.getGateways().add(gatewayConfig);
}
gatewayAdminService.getGatewayConfigurationMap().put(name, gatewayConfig);
smsConfigurationManager.updateSmsConfiguration(config);
}
}
return SUCCESS;
}
use of org.hisp.dhis.sms.config.SmsConfiguration in project dhis2-core by dhis2.
the class UpdateGenericHTTPGateWayConfigAction method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
if (gatewayType != null && gatewayType.equals("http")) {
SmsConfiguration config = smsConfigurationManager.getSmsConfiguration();
if (config != null) {
GenericHttpGatewayConfig gatewayConfig = (GenericHttpGatewayConfig) smsConfigurationManager.checkInstanceOfGateway(GenericHttpGatewayConfig.class);
int index = -1;
if (gatewayConfig == null) {
gatewayConfig = new GenericHttpGatewayConfig();
} else {
index = config.getGateways().indexOf(gatewayConfig);
}
gatewayConfig.setMessageParameter(messageParameter);
gatewayConfig.setRecipientParameter(recipientParameter);
gatewayConfig.setName(name);
gatewayConfig.setUrlTemplate(urlTemplate);
gatewayConfig.setUid(CodeGenerator.generateCode(10));
if (config.getGateways() == null || config.getGateways().isEmpty()) {
gatewayConfig.setDefault(true);
}
if (index >= 0) {
config.getGateways().set(index, gatewayConfig);
} else {
config.getGateways().add(gatewayConfig);
}
gatewayAdminService.getGatewayConfigurationMap().put(name, gatewayConfig);
smsConfigurationManager.updateSmsConfiguration(config);
}
}
return SUCCESS;
}
Aggregations