diff --git a/prototype/src/main/java/org/hso/ecommerce/api/RestServiceForDelivery.java b/prototype/src/main/java/org/hso/ecommerce/api/RestServiceForDelivery.java index 6dcadcc..e259cd3 100644 --- a/prototype/src/main/java/org/hso/ecommerce/api/RestServiceForDelivery.java +++ b/prototype/src/main/java/org/hso/ecommerce/api/RestServiceForDelivery.java @@ -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(); @@ -34,15 +33,14 @@ public class RestServiceForDelivery { Map requestBody = new HashMap<>(); - requestBody.put("name",customerOrder.destination.name); - requestBody.put("address",customerOrder.destination.addressString); + requestBody.put("name", customerOrder.destination.name); + requestBody.put("address", customerOrder.destination.addressString); - HttpEntity> entity = new HttpEntity<>(requestBody,headers); + HttpEntity> entity = new HttpEntity<>(requestBody, headers); - ResponseEntity response = restTemplate.exchange(url, HttpMethod.POST,entity, String.class); + ResponseEntity 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,20 +62,16 @@ public class RestServiceForDelivery { ResponseEntity 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); + return new DeliveryData("", "", DeliveryDataEnum.NO_DATA); } - } - catch (ResourceAccessException e) - { - return new DeliveryData("","",DeliveryDataEnum.NO_DATA); + } catch (Exception e) { + return new DeliveryData("", "", DeliveryDataEnum.NO_DATA); } } }