diff --git a/backend/discovery-service/pom.xml b/backend/discovery-service/pom.xml
index e082834..e9f7a5b 100644
--- a/backend/discovery-service/pom.xml
+++ b/backend/discovery-service/pom.xml
@@ -43,6 +43,12 @@
spring-boot-starter-testtest
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 3.11.2
+
diff --git a/backend/discovery-service/src/main/java/com/swyth/discoveryservice/DiscoveryServiceApplication.java b/backend/discovery-service/src/main/java/com/swyth/discoveryservice/DiscoveryServiceApplication.java
index 841bfe4..f953ac3 100644
--- a/backend/discovery-service/src/main/java/com/swyth/discoveryservice/DiscoveryServiceApplication.java
+++ b/backend/discovery-service/src/main/java/com/swyth/discoveryservice/DiscoveryServiceApplication.java
@@ -19,6 +19,12 @@
@EnableEurekaServer
public class DiscoveryServiceApplication {
+ /**
+ * The entry point of the Discovery Service application.
+ * This method initializes and runs the Spring Boot application which acts as a Eureka Server for service discovery.
+ *
+ * @param args command-line arguments passed to the application.
+ */
public static void main(String[] args) {
SpringApplication.run(DiscoveryServiceApplication.class, args);
}
diff --git a/backend/emergency-service/src/main/java/com/swyth/emergencyservice/config/FeignConfig.java b/backend/emergency-service/src/main/java/com/swyth/emergencyservice/config/FeignConfig.java
index f127691..905c038 100644
--- a/backend/emergency-service/src/main/java/com/swyth/emergencyservice/config/FeignConfig.java
+++ b/backend/emergency-service/src/main/java/com/swyth/emergencyservice/config/FeignConfig.java
@@ -20,16 +20,48 @@
@Configuration
public class FeignConfig {
+ /**
+ * Configures and provides a custom Feign decoder bean.
+ *
+ * The decoder leverages the Spring framework's message converters
+ * to handle the deserialization of HTTP response bodies into Java
+ * objects. This allows Feign clients to seamlessly work with various
+ * data formats (e.g., JSON, XML) used in HTTP responses.
+ *
+ * @return a {@link Decoder} implementation that uses Spring's {@link HttpMessageConverters}
+ * for converting response data.
+ */
@Bean
public Decoder feignDecoder() {
return new SpringDecoder(HttpMessageConverters::new);
}
+ /**
+ * Configures and provides a custom Feign encoder bean.
+ *
+ * This encoder leverages the Spring framework's message converters
+ * to handle the serialization of Java objects into HTTP request body
+ * representations. This allows Feign clients to seamlessly send data
+ * in various formats (e.g., JSON, XML) required by the endpoint.
+ *
+ * @return an {@link Encoder} implementation that uses Spring's {@link HttpMessageConverters}
+ * for converting request data.
+ */
@Bean
public Encoder feignEncoder() {
return new SpringEncoder(HttpMessageConverters::new);
}
+ /**
+ * Registers a custom Feign {@link ErrorDecoder} bean to handle error responses.
+ *
+ * This method provides a custom error decoder implementation that parses
+ * HTTP error responses and maps specific status codes to appropriate exceptions.
+ * It enhances error handling for Feign clients by enabling the application to
+ * interpret and respond to errors in a controlled manner.
+ *
+ * @return an instance of {@link CustomErrorDecoder} for decoding Feign client errors
+ */
@Bean
public ErrorDecoder customErrorDecoder() {
return new CustomErrorDecoder();
diff --git a/backend/emergency-service/src/main/java/com/swyth/emergencyservice/config/FeignReactiveConfig.java b/backend/emergency-service/src/main/java/com/swyth/emergencyservice/config/FeignReactiveConfig.java
index 32e0cf2..498a2df 100644
--- a/backend/emergency-service/src/main/java/com/swyth/emergencyservice/config/FeignReactiveConfig.java
+++ b/backend/emergency-service/src/main/java/com/swyth/emergencyservice/config/FeignReactiveConfig.java
@@ -16,6 +16,15 @@
@Configuration
public class FeignReactiveConfig {
+ /**
+ * Defines a scheduler for managing Feign client operations in a non-blocking
+ * reactive context. The scheduler uses a fixed thread pool with a capacity of 10
+ * threads to handle blocking operations more efficiently, reducing the risk of
+ * thread starvation in reactive pipelines.
+ *
+ * @return a {@link Scheduler} instance backed by a fixed thread pool for executing
+ * blocking tasks within Feign clients.
+ */
@Bean
public Scheduler feignScheduler() {
// Créer un thread pool dédié aux opérations bloquantes
diff --git a/backend/emergency-service/src/main/java/com/swyth/emergencyservice/controller/BedReservationController.java b/backend/emergency-service/src/main/java/com/swyth/emergencyservice/controller/BedReservationController.java
index ecbc04b..aa9e1bd 100644
--- a/backend/emergency-service/src/main/java/com/swyth/emergencyservice/controller/BedReservationController.java
+++ b/backend/emergency-service/src/main/java/com/swyth/emergencyservice/controller/BedReservationController.java
@@ -48,13 +48,39 @@ public BedReservationController(BedReservationService bedReservationService) {
this.bedReservationService = bedReservationService;
}
- // TODO: Handle resource not Found
+
+ /**
+ * Retrieves a bed reservation by its unique ID.
+ *
+ * This method fetches the bed reservation details using the provided ID and
+ * returns a response encapsulating the reservation details.
+ *
+ * @param id the unique identifier of the bed reservation to be retrieved
+ * @return a ResponseEntity containing the bed reservation details in the form of {@link BedReservationResponseDTO}
+ */
+ // FIXME: Handle resource not Found
@GetMapping("{id}")
public ResponseEntity getBedReservationById(@PathVariable Long id) {
BedReservationResponseDTO bedReservation = bedReservationService.findById(id);
return ResponseEntity.ok(bedReservation);
}
+ /**
+ * Handles the creation of a new bed reservation.
+ *
+ * This method processes the bed reservation request by validating the input data,
+ * checking bed availability in the specified hospital and medical specialization,
+ * and ultimately creating a new reservation if possible. It delegates the business
+ * logic to the service layer and returns the result encapsulated in a response entity.
+ *
+ * @param bedReservationRequest the details of the bed reservation request, including
+ * hospital ID, medical specialization ID, and reservation
+ * personal/contact information
+ * @return a {@code Mono>} containing the bed
+ * reservation details if successfully created
+ * @throws BedUnavailableException if no beds are available for the specified hospital
+ * and medical specialization
+ */
@PostMapping("")
public Mono> createBedReservation(@Valid @RequestBody BedReservationDTO bedReservationRequest) {
try {
diff --git a/backend/emergency-service/src/main/java/com/swyth/emergencyservice/dto/BedReservationDTO.java b/backend/emergency-service/src/main/java/com/swyth/emergencyservice/dto/BedReservationDTO.java
index 6a57e62..93d3e12 100644
--- a/backend/emergency-service/src/main/java/com/swyth/emergencyservice/dto/BedReservationDTO.java
+++ b/backend/emergency-service/src/main/java/com/swyth/emergencyservice/dto/BedReservationDTO.java
@@ -3,7 +3,9 @@
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
+import lombok.AllArgsConstructor;
import lombok.Data;
+import lombok.NoArgsConstructor;
/**
* Data Transfer Object for handling bed reservation requests.
@@ -16,6 +18,8 @@
* of the data provided in the request.
*/
@Data
+@NoArgsConstructor
+@AllArgsConstructor
public class BedReservationDTO {
@NotNull(message = "Hospital ID must not be null")
diff --git a/backend/emergency-service/src/main/java/com/swyth/emergencyservice/dto/BedReservationResponseDTO.java b/backend/emergency-service/src/main/java/com/swyth/emergencyservice/dto/BedReservationResponseDTO.java
index c2149b8..5c6e644 100644
--- a/backend/emergency-service/src/main/java/com/swyth/emergencyservice/dto/BedReservationResponseDTO.java
+++ b/backend/emergency-service/src/main/java/com/swyth/emergencyservice/dto/BedReservationResponseDTO.java
@@ -5,6 +5,7 @@
import jakarta.validation.constraints.Pattern;
import lombok.AllArgsConstructor;
import lombok.Data;
+import lombok.NoArgsConstructor;
/**
* Data Transfer Object representing a response for a bed reservation.
@@ -25,6 +26,7 @@
* - reservationPhoneNumber: The phone number of the person for whom the reservation is made.
*/
@Data
+@NoArgsConstructor
@AllArgsConstructor
public class BedReservationResponseDTO {
private Long id;
diff --git a/backend/emergency-service/src/main/java/com/swyth/emergencyservice/dto/BedReservationResponseDtoMapper.java b/backend/emergency-service/src/main/java/com/swyth/emergencyservice/dto/BedReservationResponseDtoMapper.java
index 3159663..b08e489 100644
--- a/backend/emergency-service/src/main/java/com/swyth/emergencyservice/dto/BedReservationResponseDtoMapper.java
+++ b/backend/emergency-service/src/main/java/com/swyth/emergencyservice/dto/BedReservationResponseDtoMapper.java
@@ -17,6 +17,16 @@
*/
public class BedReservationResponseDtoMapper {
+ /**
+ * Converts a {@code BedReservation} entity into a {@code BedReservationResponseDTO}.
+ *
+ * This method extracts the relevant fields from the {@code BedReservation} entity
+ * and constructs a corresponding {@code BedReservationResponseDTO} to provide
+ * a simplified data transfer representation of the reservation.
+ *
+ * @param reservation the {@code BedReservation} entity to be converted
+ * @return a {@code BedReservationResponseDTO} containing the reservation details
+ */
public static BedReservationResponseDTO convertToDTO(BedReservation reservation) {
return new BedReservationResponseDTO(
reservation.getId(),
diff --git a/backend/emergency-service/src/main/java/com/swyth/emergencyservice/exception/BedUnavailableException.java b/backend/emergency-service/src/main/java/com/swyth/emergencyservice/exception/BedUnavailableException.java
index c18fd8d..f972798 100644
--- a/backend/emergency-service/src/main/java/com/swyth/emergencyservice/exception/BedUnavailableException.java
+++ b/backend/emergency-service/src/main/java/com/swyth/emergencyservice/exception/BedUnavailableException.java
@@ -17,6 +17,15 @@
* specific detail message about the unavailability of resources.
*/
public class BedUnavailableException extends RuntimeException {
+ /**
+ * Constructs a new BedUnavailableException with a specific detail message.
+ *
+ * This exception is thrown when no beds are available in the specified hospital
+ * for the requested medical specialization. The message provides additional context
+ * about the unavailability of resources.
+ *
+ * @param message the detailed message explaining the reason for the exception
+ */
public BedUnavailableException(String message) {
super(message);
}
diff --git a/backend/emergency-service/src/main/java/com/swyth/emergencyservice/exception/GlobalExceptionHandler.java b/backend/emergency-service/src/main/java/com/swyth/emergencyservice/exception/GlobalExceptionHandler.java
index 85ad57f..c5a94f7 100644
--- a/backend/emergency-service/src/main/java/com/swyth/emergencyservice/exception/GlobalExceptionHandler.java
+++ b/backend/emergency-service/src/main/java/com/swyth/emergencyservice/exception/GlobalExceptionHandler.java
@@ -27,6 +27,17 @@
public class GlobalExceptionHandler {
+ /**
+ * Handles WebExchangeBindException to provide detailed error responses for bad formatted requests.
+ *
+ * This method constructs a standardized error response containing a timestamp, HTTP status code,
+ * error type, request path, and validation errors. The validation errors include details about
+ * fields that failed validation along with their corresponding error messages.
+ *
+ * @param ex the WebExchangeBindException that occurred, containing details of the validation errors
+ * @param exchange the ServerWebExchange object representing the current web exchange, used to retrieve the request path
+ * @return a ResponseEntity containing the error response with validation error details and an HTTP status code of 400 (Bad Request)
+ */
// Handle bad formatted requests
@ExceptionHandler(WebExchangeBindException.class)
public ResponseEntity
+