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";
|
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";
|
String url = DELIVERY_IP_ADDRESS + "/newDelivery";
|
||||||
|
|
||||||
RestTemplate restTemplate = restTemplateBuilder.build();
|
RestTemplate restTemplate = restTemplateBuilder.build();
|
||||||
@ -41,8 +40,7 @@ public class RestServiceForDelivery {
|
|||||||
|
|
||||||
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
|
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
|
||||||
|
|
||||||
if (response.getStatusCode() == HttpStatus.OK)
|
if (response.getStatusCode() == HttpStatus.OK) {
|
||||||
{
|
|
||||||
return response.getBody();
|
return response.getBody();
|
||||||
} else {
|
} else {
|
||||||
throw new ResourceAccessException("Http Status wrong");
|
throw new ResourceAccessException("Http Status wrong");
|
||||||
@ -64,19 +62,15 @@ public class RestServiceForDelivery {
|
|||||||
|
|
||||||
ResponseEntity<DeliveryData> response;
|
ResponseEntity<DeliveryData> response;
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, DeliveryData.class);
|
response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, DeliveryData.class);
|
||||||
if (response.getStatusCode() == HttpStatus.OK)
|
if (response.getStatusCode() == HttpStatus.OK) {
|
||||||
{
|
|
||||||
return response.getBody();
|
return response.getBody();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return new DeliveryData("", "", DeliveryDataEnum.NO_DATA);
|
return new DeliveryData("", "", DeliveryDataEnum.NO_DATA);
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (ResourceAccessException e)
|
|
||||||
{
|
|
||||||
return new DeliveryData("", "", DeliveryDataEnum.NO_DATA);
|
return new DeliveryData("", "", DeliveryDataEnum.NO_DATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user