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;
}
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;
}
use of org.hisp.dhis.sms.config.SmsGatewayConfig in project dhis2-core by dhis2.
the class SmsGatewayController method removeGateway.
// -------------------------------------------------------------------------
// DELETE
// -------------------------------------------------------------------------
@PreAuthorize("hasRole('ALL') or hasRole('F_MOBILE_SENDSMS')")
@RequestMapping(value = "/{uid}", method = RequestMethod.DELETE)
public void removeGateway(@PathVariable String uid, HttpServletRequest request, HttpServletResponse response) throws WebMessageException {
SmsGatewayConfig gateway = gatewayAdminService.getGatewayConfigurationByUid(uid);
if (gateway == null) {
throw new WebMessageException(WebMessageUtils.notFound("No gateway found with id: " + uid));
}
gatewayAdminService.removeGatewayByUid(uid);
webMessageService.send(WebMessageUtils.ok("Gateway removed successfully"), response, request);
}
use of org.hisp.dhis.sms.config.SmsGatewayConfig in project dhis2-core by dhis2.
the class SmsGatewayController method setDefault.
@PreAuthorize("hasRole('ALL') or hasRole('F_MOBILE_SENDSMS')")
@RequestMapping(value = "/default/{uid}", method = RequestMethod.PUT)
public void setDefault(@PathVariable String uid, HttpServletRequest request, HttpServletResponse response) throws WebMessageException {
SmsGatewayConfig gateway = gatewayAdminService.getGatewayConfigurationByUid(uid);
if (gateway == null) {
throw new WebMessageException(WebMessageUtils.notFound("No gateway found"));
}
gatewayAdminService.setDefaultGateway(uid);
webMessageService.send(WebMessageUtils.ok(gateway.getName() + " is set to default"), response, request);
}
use of org.hisp.dhis.sms.config.SmsGatewayConfig in project dhis2-core by dhis2.
the class SmsGatewayController method getDefault.
@PreAuthorize("hasRole('ALL') or hasRole('F_MOBILE_SENDSMS')")
@RequestMapping(value = "/default", method = RequestMethod.GET)
public void getDefault(HttpServletRequest request, HttpServletResponse response) throws WebMessageException, IOException {
SmsGatewayConfig defaultGateway = gatewayAdminService.getDefaultGateway();
if (defaultGateway == null) {
throw new WebMessageException(WebMessageUtils.notFound("No default gateway found"));
}
renderService.toJson(response.getOutputStream(), defaultGateway);
}
Aggregations