Skip to content
Snippets Groups Projects
Commit 4d4d52ee authored by Andrej Zabka's avatar Andrej Zabka
Browse files

Merge remote-tracking branch 'origin/security' into security

parents e76844cf 5e8ff6ac
No related branches found
No related tags found
3 merge requests!54Merge develop into main,!48Scenario,!44Security
Pipeline #
This commit is part of merge request !44. Comments created here will be created in the context of that merge request.
...@@ -8,11 +8,13 @@ import org.slf4j.Logger; ...@@ -8,11 +8,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.io.Resource;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestClientException;
import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.function.client.WebClientException;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.HashMap; import java.util.HashMap;
...@@ -62,7 +64,7 @@ public class ApplicationService { ...@@ -62,7 +64,7 @@ public class ApplicationService {
try { try {
sendPostRequest(savedApplication, NOTIFICATION_MODULE_URI_NEW, List.of(savedApplication.getEmail())); sendPostRequest(savedApplication, NOTIFICATION_MODULE_URI_NEW, List.of(savedApplication.getEmail()));
} 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_NEW, e)); log.debug(String.format("The notification module is not reachable on the URL: %s, exception %s", NOTIFICATION_MODULE_URL + NOTIFICATION_MODULE_URI_NEW, e));
} }
...@@ -89,7 +91,7 @@ public class ApplicationService { ...@@ -89,7 +91,7 @@ public class ApplicationService {
if (savedApplication.getStatus() != ApplicationStatusEnum.PENDING) { if (savedApplication.getStatus() != ApplicationStatusEnum.PENDING) {
try { try {
sendPostRequest(savedApplication, NOTIFICATION_MODULE_URI_STATUS, NOTIFICATION_RECEIVERS); sendPostRequest(savedApplication, NOTIFICATION_MODULE_URI_STATUS, NOTIFICATION_RECEIVERS);
} 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_STATUS, e)); log.debug(String.format("The notification module is not reachable on the URL: %s, exception %s", NOTIFICATION_MODULE_URL + NOTIFICATION_MODULE_URI_STATUS, e));
} }
} }
...@@ -107,10 +109,7 @@ public class ApplicationService { ...@@ -107,10 +109,7 @@ public class ApplicationService {
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.bodyValue(notification) .bodyValue(notification)
.retrieve() .retrieve()
.bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {}) .bodyToMono(Resource.class)
.doOnError(error -> {
throw new RestClientException("Failed to send POST request", error);
})
.block(); .block();
} }
} }
...@@ -8,11 +8,13 @@ import org.slf4j.Logger; ...@@ -8,11 +8,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.io.Resource;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.*; import org.springframework.web.client.*;
import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.function.client.WebClientException;
import java.util.*; import java.util.*;
...@@ -48,7 +50,7 @@ public class CarComponentService extends DomainService<CarComponent> { ...@@ -48,7 +50,7 @@ public class CarComponentService extends DomainService<CarComponent> {
CarComponent savedComponent = repository.save(component); CarComponent savedComponent = repository.save(component);
try { try {
sendPostRequest(savedComponent); 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)); 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; return savedComponent;
...@@ -88,10 +90,7 @@ public class CarComponentService extends DomainService<CarComponent> { ...@@ -88,10 +90,7 @@ public class CarComponentService extends DomainService<CarComponent> {
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.bodyValue(notification) .bodyValue(notification)
.retrieve() .retrieve()
.bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {}) .bodyToMono(Resource.class)
.doOnError(error -> {
throw new RestClientException("Failed to send POST request", error);
})
.block(); .block();
} }
} }
...@@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestClientException;
import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.function.client.WebClientException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -122,7 +123,7 @@ public class CarService extends DomainService<Car> { ...@@ -122,7 +123,7 @@ public class CarService extends DomainService<Car> {
try { try {
sendPostRequest(savedCar); 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)); log.debug(String.format("The visualization module is not reachable on the URL: %s, exception %s", VISUALIZATION_MODULE_URL + VISUALIZATION_MODULE_URI, e));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment