use of org.hisp.dhis.sms.config.ClickatellGatewayConfig 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.ClickatellGatewayConfig in project dhis2-core by dhis2.
the class GetSmsConfigurationAction method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
smsConfig = smsConfigurationManager.getSmsConfiguration();
if (smsConfig != null) {
int index = 0;
for (SmsGatewayConfig gw : smsConfig.getGateways()) {
index = smsConfig.getGateways().indexOf(gw);
gatewayConfigMap.put(index, gw);
if (gw instanceof BulkSmsGatewayConfig) {
bulkIndex = index;
} else if (gw instanceof ClickatellGatewayConfig) {
clickatellIndex = index;
} else {
httpIndex = index;
}
}
} else {
smsConfig = new SmsConfiguration(true);
smsConfigurationManager.updateSmsConfiguration(smsConfig);
}
return SUCCESS;
}
use of org.hisp.dhis.sms.config.ClickatellGatewayConfig in project dhis2-core by dhis2.
the class RemoveGatewayConfigAction method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
SmsConfiguration smsConfig = smsConfigurationManager.getSmsConfiguration();
Iterator<SmsGatewayConfig> it = smsConfig.getGateways().iterator();
while (it.hasNext()) {
if (smsConfig.getGateways().indexOf(it.next()) == id) {
SmsGatewayConfig gatewayConfig = smsConfig.getGateways().get(id);
it.remove();
smsConfigurationManager.updateSmsConfiguration(smsConfig);
if (gatewayConfig instanceof BulkSmsGatewayConfig) {
gatewayAdminService.getGatewayConfigurationMap().remove(gatewayConfig.getName());
}
if (gatewayConfig instanceof ClickatellGatewayConfig) {
gatewayAdminService.getGatewayConfigurationMap().remove(gatewayConfig.getName());
}
if (gatewayConfig instanceof GenericHttpGatewayConfig) {
gatewayAdminService.getGatewayConfigurationMap().remove(gatewayConfig.getName());
}
log.info(gatewayConfig.getName() + " configuration has been removed");
break;
}
}
return SUCCESS;
}
Aggregations