Search in sources :

Example 1 with SmsProviderConfiguration

use of org.thingsboard.server.common.data.sms.config.SmsProviderConfiguration in project thingsboard by thingsboard.

the class DefaultSmsService method updateSmsConfiguration.

@Override
public void updateSmsConfiguration() {
    AdminSettings settings = adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID, "sms");
    if (settings != null) {
        try {
            JsonNode jsonConfig = settings.getJsonValue();
            SmsProviderConfiguration configuration = JacksonUtil.convertValue(jsonConfig, SmsProviderConfiguration.class);
            SmsSender newSmsSender = this.smsSenderFactory.createSmsSender(configuration);
            if (this.smsSender != null) {
                this.smsSender.destroy();
            }
            this.smsSender = newSmsSender;
        } catch (Exception e) {
            log.error("Failed to create SMS sender", e);
        }
    }
}
Also used : SmsProviderConfiguration(org.thingsboard.server.common.data.sms.config.SmsProviderConfiguration) JsonNode(com.fasterxml.jackson.databind.JsonNode) NestedRuntimeException(org.springframework.core.NestedRuntimeException) ThingsboardException(org.thingsboard.server.common.data.exception.ThingsboardException) AdminSettings(org.thingsboard.server.common.data.AdminSettings) SmsSender(org.thingsboard.rule.engine.api.sms.SmsSender)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 NestedRuntimeException (org.springframework.core.NestedRuntimeException)1 SmsSender (org.thingsboard.rule.engine.api.sms.SmsSender)1 AdminSettings (org.thingsboard.server.common.data.AdminSettings)1 ThingsboardException (org.thingsboard.server.common.data.exception.ThingsboardException)1 SmsProviderConfiguration (org.thingsboard.server.common.data.sms.config.SmsProviderConfiguration)1