diff --git a/core/src/main/java/cz/muni/pa165/service/CarComponentService.java b/core/src/main/java/cz/muni/pa165/service/CarComponentService.java index 206402e0d515cc556d96c8f191dcecd8150a1bbe..821934f3fd8baa15448d1af460c0f17b9fe759c5 100644 --- a/core/src/main/java/cz/muni/pa165/service/CarComponentService.java +++ b/core/src/main/java/cz/muni/pa165/service/CarComponentService.java @@ -8,11 +8,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.ParameterizedTypeReference; +import org.springframework.core.io.Resource; import org.springframework.http.MediaType; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.client.*; import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.reactive.function.client.WebClientException; import java.util.*; @@ -39,7 +41,7 @@ public class CarComponentService extends DomainService<CarComponent> { CarComponent savedComponent = repository.save(component); try { sendPostRequest(savedComponent); - } catch (RestClientException | IllegalArgumentException e) { + } catch (WebClientException e) { log.debug(String.format("The notification module is not reachable on the URL: %s, exception %s", NOTIFICATION_MODULE_URL + NOTIFICATION_MODULE_URI, e)); } return savedComponent; @@ -79,10 +81,7 @@ public class CarComponentService extends DomainService<CarComponent> { .contentType(MediaType.APPLICATION_JSON) .bodyValue(notification) .retrieve() - .bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {}) - .doOnError(error -> { - throw new RestClientException("Failed to send POST request", error); - }) + .bodyToMono(Resource.class) .block(); } } diff --git a/core/src/main/java/cz/muni/pa165/service/CarService.java b/core/src/main/java/cz/muni/pa165/service/CarService.java index 085b1160c3a238bf2305c531549aa6870e950071..b13123381f850d8d1c06a4a9da7e15dac036d5e9 100644 --- a/core/src/main/java/cz/muni/pa165/service/CarService.java +++ b/core/src/main/java/cz/muni/pa165/service/CarService.java @@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.core.io.Resource; import org.springframework.web.client.RestClientException; import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.reactive.function.client.WebClientException; import java.io.IOException; import java.util.HashMap; @@ -113,7 +114,7 @@ public class CarService extends DomainService<Car> { try { sendPostRequest(savedCar); - } catch (Exception e) { + } catch (WebClientException e) { log.debug(String.format("The visualization module is not reachable on the URL: %s, exception %s", VISUALIZATION_MODULE_URL + VISUALIZATION_MODULE_URI, e)); }