Catch failing delivery server
This commit is contained in:
parent
e5332a3348
commit
8fdfe9cc69
|
@ -23,8 +23,7 @@ public class RestServiceForDelivery {
|
|||
private final String DELIVERY_IP_ADDRESS = "http://[::1]:8082";
|
||||
|
||||
|
||||
public String getDeliveryID(CustomerOrder customerOrder) throws ResourceAccessException
|
||||
{
|
||||
public String getDeliveryID(CustomerOrder customerOrder) throws ResourceAccessException {
|
||||
String url = DELIVERY_IP_ADDRESS + "/newDelivery";
|
||||
|
||||
RestTemplate restTemplate = restTemplateBuilder.build();
|
||||
|
@ -41,8 +40,7 @@ public class RestServiceForDelivery {
|
|||
|
||||
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
|
||||
|
||||
if (response.getStatusCode() == HttpStatus.OK)
|
||||
{
|
||||
if (response.getStatusCode() == HttpStatus.OK) {
|
||||
return response.getBody();
|
||||
} else {
|
||||
throw new ResourceAccessException("Http Status wrong");
|
||||
|
@ -64,19 +62,15 @@ public class RestServiceForDelivery {
|
|||
|
||||
ResponseEntity<DeliveryData> response;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, DeliveryData.class);
|
||||
if (response.getStatusCode() == HttpStatus.OK)
|
||||
{
|
||||
if (response.getStatusCode() == HttpStatus.OK) {
|
||||
return response.getBody();
|
||||
} else {
|
||||
|
||||
return new DeliveryData("", "", DeliveryDataEnum.NO_DATA);
|
||||
}
|
||||
}
|
||||
catch (ResourceAccessException e)
|
||||
{
|
||||
} catch (Exception e) {
|
||||
return new DeliveryData("", "", DeliveryDataEnum.NO_DATA);
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue