FINERACT-1088: Fixing error message from SMS campaigns
This commit is contained in:
committed by
Awasum Yannick
parent
e6d09d6c3b
commit
9ef10c9838
+13
-5
@@ -43,6 +43,7 @@ import org.springframework.http.HttpMethod;
|
|||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.client.ResourceAccessException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -72,17 +73,24 @@ public class SmsCampaignDropdownReadPlatformServiceImpl implements SmsCampaignDr
|
|||||||
@Override
|
@Override
|
||||||
public Collection<SmsProviderData> retrieveSmsProviders() {
|
public Collection<SmsProviderData> retrieveSmsProviders() {
|
||||||
Collection<SmsProviderData> smsProviderOptions = new ArrayList<>();
|
Collection<SmsProviderData> smsProviderOptions = new ArrayList<>();
|
||||||
String hostName = "";
|
|
||||||
Map<String, Object> hostConfig = this.smsConfigUtils.getMessageGateWayRequestURI("smsbridges", null);
|
Map<String, Object> hostConfig = this.smsConfigUtils.getMessageGateWayRequestURI("smsbridges", null);
|
||||||
URI uri = (URI) hostConfig.get("uri");
|
URI uri = (URI) hostConfig.get("uri");
|
||||||
hostName = uri.getHost();
|
|
||||||
HttpEntity<?> entity = (HttpEntity<?>) hostConfig.get("entity");
|
HttpEntity<?> entity = (HttpEntity<?>) hostConfig.get("entity");
|
||||||
ResponseEntity<Collection<SmsProviderData>> responseOne = restTemplate.exchange(uri, HttpMethod.GET, entity,
|
|
||||||
new ParameterizedTypeReference<Collection<SmsProviderData>>() {});
|
ResponseEntity<Collection<SmsProviderData>> responseOne = null;
|
||||||
if (!responseOne.getStatusCode().equals(HttpStatus.OK)) {
|
|
||||||
|
try {
|
||||||
|
responseOne = restTemplate.exchange(uri, HttpMethod.GET, entity,
|
||||||
|
new ParameterizedTypeReference<Collection<SmsProviderData>>() {});
|
||||||
|
} catch (ResourceAccessException ex) {
|
||||||
|
LOG.debug("Mobile service provider {} not available", uri, ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (responseOne == null || !responseOne.getStatusCode().equals(HttpStatus.OK)) {
|
||||||
throw new PlatformDataIntegrityException("error.msg.mobile.service.provider.not.available",
|
throw new PlatformDataIntegrityException("error.msg.mobile.service.provider.not.available",
|
||||||
"Mobile service provider not available.");
|
"Mobile service provider not available.");
|
||||||
}
|
}
|
||||||
|
|
||||||
smsProviderOptions = responseOne.getBody();
|
smsProviderOptions = responseOne.getBody();
|
||||||
return smsProviderOptions;
|
return smsProviderOptions;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user