Search in sources :

Example 11 with SmsGatewayConfig

use of org.hisp.dhis.sms.config.SmsGatewayConfig 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);
}
Also used : SmsConfiguration(org.hisp.dhis.sms.config.SmsConfiguration) SmsGatewayConfig(org.hisp.dhis.sms.config.SmsGatewayConfig)

Example 12 with SmsGatewayConfig

use of org.hisp.dhis.sms.config.SmsGatewayConfig 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;
}
Also used : SmsConfiguration(org.hisp.dhis.sms.config.SmsConfiguration) SmsGatewayConfig(org.hisp.dhis.sms.config.SmsGatewayConfig)

Example 13 with SmsGatewayConfig

use of org.hisp.dhis.sms.config.SmsGatewayConfig 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;
}
Also used : SmsConfiguration(org.hisp.dhis.sms.config.SmsConfiguration) SmsGatewayConfig(org.hisp.dhis.sms.config.SmsGatewayConfig)

Aggregations

SmsGatewayConfig (org.hisp.dhis.sms.config.SmsGatewayConfig)13 SmsConfiguration (org.hisp.dhis.sms.config.SmsConfiguration)8 BulkSmsGatewayConfig (org.hisp.dhis.sms.config.BulkSmsGatewayConfig)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 ClickatellGatewayConfig (org.hisp.dhis.sms.config.ClickatellGatewayConfig)2 GenericHttpGatewayConfig (org.hisp.dhis.sms.config.GenericHttpGatewayConfig)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1 TaskId (org.hisp.dhis.scheduling.TaskId)1 User (org.hisp.dhis.user.User)1 UserGroup (org.hisp.dhis.user.UserGroup)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1