diff --git a/helpapp/README.md b/helpapp/README.md index 57185fb..8a1bf77 100644 --- a/helpapp/README.md +++ b/helpapp/README.md @@ -22,3 +22,79 @@ mvn spring-boot:run -pl soap-service ``` Vérifier le bon fonctionnement en accédant à `localhost:8080/hello` pour REST et `localhost:8081/ws` pour SOAP. + + + +# Specifications + +### **1. Objectifs de l'application** +- **Aider les personnes en besoin** : Faciliter la publication de demandes d’aide par des personnes en situation de vulnérabilité. +- **Mobiliser des volontaires** : Permettre aux volontaires de répondre à des demandes d’aide ou de proposer une aide spontanée. +- **Gérer l’administration** : Faciliter l’administration et le suivi des demandes. + +### **2. REST Microservices** + +#### **2.1 User Service** +- **Features:** + - Account creation for requesters, volunteers, and administrators. + - User profile management (modification and deletion). + - Authentication and role management (requester, volunteer, administrator). +- **Main Endpoints:** + - `POST /users`: Create a user. + - `GET /users/{id}`: View a user's profile. + - `PUT /users/{id}`: Update a user. + - `DELETE /users/{id}`: Delete a user. + +#### **2.2 Request Service** +- **Features:** + - Creation, validation, and management of help requests. + - Management of request statuses: Pending, validated, rejected, completed. + - Viewing and filtering requests by status. +- **Main Endpoints:** + - `POST /requests`: Create a request. + - `GET /requests`: List of requests (with possible filters). + - `GET /requests/{id}`: View a specific request. + - `PUT /requests/{id}`: Update the status or details of a request. + - `DELETE /requests/{id}`: Delete a request. + +#### **2.3 Volunteer Service** +- **Features:** + - Viewing available requests. + - Offering help for a specific request. + - Posting spontaneous help offers. +- **Main Endpoints:** + - `GET /volunteers/requests`: List of available requests. + - `POST /volunteers/{id}/help`: Respond to a specific request. + - `POST /volunteers/spontaneous`: Post a spontaneous help offer. + +#### **2.4 Feedback Service** +- **Features:** + - Recording and managing feedback after a request is completed. + - Viewing feedback associated with a request or user. +- **Main Endpoints:** + - `POST /feedbacks`: Add feedback. + - `GET /feedbacks`: View feedback (with possible filters). + +#### **2.5 Administration Service** +- **Features:** + - Validation or rejection of help requests. + - Management of rejection reasons. + - Viewing global statistics (e.g., number of completed requests). +- **Main Endpoints:** + - `GET /admin/requests`: List of requests to be validated. + - `PUT /admin/requests/{id}/validate`: Validate a request. + - `PUT /admin/requests/{id}/reject`: Reject a request with justification. + +### **3. Architecture technique** +- **Communication :** Chaque microservice expose une API REST avec des endpoints bien définis. +- **Base de données :** Chaque microservice possède sa propre base de données pour favoriser la décentralisation (database-per-service). +- **Authentification :** Utilisation de JWT pour sécuriser les communications. +- **Load Balancing et Gateway :** Utilisation d’un API Gateway pour la gestion des requêtes et la sécurité. +- **Monitoring :** Intégration de services comme Prometheus et Grafana pour le suivi des performances. + + + +### **4. Avantages de cette architecture** +- **Scalabilité** : Les microservices peuvent être déployés et mis à l'échelle individuellement. +- **Flexibilité** : Possibilité d’utiliser différentes technologies pour chaque service. +- **Maintenance** : Une meilleure isolation des fonctionnalités simplifie le débogage et les mises à jour. diff --git a/helpapp/administration-service/pom.xml b/helpapp/administration-service/pom.xml new file mode 100644 index 0000000..963e9af --- /dev/null +++ b/helpapp/administration-service/pom.xml @@ -0,0 +1,40 @@ + + + insa.application.helpapp + helpapp + 1.0-SNAPSHOT + + 4.0.0 + administration-service + + + + + org.springframework.boot + spring-boot-starter-web + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 3.1.4 + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 21 + 21 + + + + + + diff --git a/helpapp/rest-service/src/main/java/insa/application/helpapp/rest/RestApplication.java b/helpapp/administration-service/src/main/java/insa/application/helpapp/rest/RestApplication.java similarity index 100% rename from helpapp/rest-service/src/main/java/insa/application/helpapp/rest/RestApplication.java rename to helpapp/administration-service/src/main/java/insa/application/helpapp/rest/RestApplication.java diff --git a/helpapp/rest-service/src/main/resources/application.properties b/helpapp/administration-service/src/main/resources/application.properties similarity index 100% rename from helpapp/rest-service/src/main/resources/application.properties rename to helpapp/administration-service/src/main/resources/application.properties diff --git a/helpapp/feedback-service/pom.xml b/helpapp/feedback-service/pom.xml new file mode 100644 index 0000000..9d440c1 --- /dev/null +++ b/helpapp/feedback-service/pom.xml @@ -0,0 +1,40 @@ + + + insa.application.helpapp + helpapp + 1.0-SNAPSHOT + + 4.0.0 + feedback-service + + + + + org.springframework.boot + spring-boot-starter-web + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 3.1.4 + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 21 + 21 + + + + + + diff --git a/helpapp/feedback-service/src/main/java/insa/application/helpapp/rest/RestApplication.java b/helpapp/feedback-service/src/main/java/insa/application/helpapp/rest/RestApplication.java new file mode 100644 index 0000000..2e82618 --- /dev/null +++ b/helpapp/feedback-service/src/main/java/insa/application/helpapp/rest/RestApplication.java @@ -0,0 +1,20 @@ +package insa.application.helpapp.rest; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@SpringBootApplication +@RestController +public class RestApplication { + + public static void main(String[] args) { + SpringApplication.run(RestApplication.class, args); + } + + @GetMapping("/hello") + public String hello() { + return "Hello from REST!"; + } +} diff --git a/helpapp/feedback-service/src/main/resources/application.properties b/helpapp/feedback-service/src/main/resources/application.properties new file mode 100644 index 0000000..4c00e40 --- /dev/null +++ b/helpapp/feedback-service/src/main/resources/application.properties @@ -0,0 +1 @@ +server.port=8080 diff --git a/helpapp/pom.xml b/helpapp/pom.xml index 3698f71..6bfa614 100644 --- a/helpapp/pom.xml +++ b/helpapp/pom.xml @@ -7,9 +7,11 @@ pom - rest-service - soap-service - user-service + user-service + request-service + volunteer-service + feedback-service + administration-service diff --git a/helpapp/rest-service/pom.xml b/helpapp/request-service/pom.xml similarity index 96% rename from helpapp/rest-service/pom.xml rename to helpapp/request-service/pom.xml index c85e368..6c195a1 100644 --- a/helpapp/rest-service/pom.xml +++ b/helpapp/request-service/pom.xml @@ -5,7 +5,7 @@ 1.0-SNAPSHOT 4.0.0 - rest-service + request-service diff --git a/helpapp/request-service/src/main/java/insa/application/helpapp/rest/RestApplication.java b/helpapp/request-service/src/main/java/insa/application/helpapp/rest/RestApplication.java new file mode 100644 index 0000000..2e82618 --- /dev/null +++ b/helpapp/request-service/src/main/java/insa/application/helpapp/rest/RestApplication.java @@ -0,0 +1,20 @@ +package insa.application.helpapp.rest; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@SpringBootApplication +@RestController +public class RestApplication { + + public static void main(String[] args) { + SpringApplication.run(RestApplication.class, args); + } + + @GetMapping("/hello") + public String hello() { + return "Hello from REST!"; + } +} diff --git a/helpapp/request-service/src/main/resources/application.properties b/helpapp/request-service/src/main/resources/application.properties new file mode 100644 index 0000000..4c00e40 --- /dev/null +++ b/helpapp/request-service/src/main/resources/application.properties @@ -0,0 +1 @@ +server.port=8080 diff --git a/helpapp/soap-service/pom.xml b/helpapp/soap-service/pom.xml deleted file mode 100644 index d122e95..0000000 --- a/helpapp/soap-service/pom.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.3.0 - - - com.example - producing-web-service-complete - 0.0.1-SNAPSHOT - producing-web-service-complete - Demo project for Spring Boot - - - 17 - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-web-services - - - - wsdl4j - wsdl4j - - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - org.codehaus.mojo - jaxb2-maven-plugin - 3.1.0 - - - xjc - - xjc - - - - - - ${project.basedir}/src/main/resources/countries.xsd - - - - - - - - diff --git a/helpapp/soap-service/src/main/java/.gitignore b/helpapp/soap-service/src/main/java/.gitignore deleted file mode 100644 index 5de3989..0000000 --- a/helpapp/soap-service/src/main/java/.gitignore +++ /dev/null @@ -1 +0,0 @@ -io diff --git a/helpapp/soap-service/src/main/java/com/example/producingwebservice/CountryEndpoint.java b/helpapp/soap-service/src/main/java/com/example/producingwebservice/CountryEndpoint.java deleted file mode 100644 index f14655f..0000000 --- a/helpapp/soap-service/src/main/java/com/example/producingwebservice/CountryEndpoint.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.example.producingwebservice; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.ws.server.endpoint.annotation.Endpoint; -import org.springframework.ws.server.endpoint.annotation.PayloadRoot; -import org.springframework.ws.server.endpoint.annotation.RequestPayload; -import org.springframework.ws.server.endpoint.annotation.ResponsePayload; - -import io.spring.guides.gs_producing_web_service.GetCountryRequest; -import io.spring.guides.gs_producing_web_service.GetCountryResponse; - -@Endpoint -public class CountryEndpoint { - private static final String NAMESPACE_URI = "http://spring.io/guides/gs-producing-web-service"; - - private CountryRepository countryRepository; - - @Autowired - public CountryEndpoint(CountryRepository countryRepository) { - this.countryRepository = countryRepository; - } - - @PayloadRoot(namespace = NAMESPACE_URI, localPart = "getCountryRequest") - @ResponsePayload - public GetCountryResponse getCountry(@RequestPayload GetCountryRequest request) { - GetCountryResponse response = new GetCountryResponse(); - response.setCountry(countryRepository.findCountry(request.getName())); - - return response; - } -} diff --git a/helpapp/soap-service/src/main/java/com/example/producingwebservice/CountryRepository.java b/helpapp/soap-service/src/main/java/com/example/producingwebservice/CountryRepository.java deleted file mode 100644 index d9e5a89..0000000 --- a/helpapp/soap-service/src/main/java/com/example/producingwebservice/CountryRepository.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.example.producingwebservice; - -import jakarta.annotation.PostConstruct; -import java.util.HashMap; -import java.util.Map; - -import io.spring.guides.gs_producing_web_service.Country; -import io.spring.guides.gs_producing_web_service.Currency; -import org.springframework.stereotype.Component; -import org.springframework.util.Assert; - -@Component -public class CountryRepository { - private static final Map countries = new HashMap<>(); - - @PostConstruct - public void initData() { - Country spain = new Country(); - spain.setName("Spain"); - spain.setCapital("Madrid"); - spain.setCurrency(Currency.EUR); - spain.setPopulation(46704314); - - countries.put(spain.getName(), spain); - - Country poland = new Country(); - poland.setName("Poland"); - poland.setCapital("Warsaw"); - poland.setCurrency(Currency.PLN); - poland.setPopulation(38186860); - - countries.put(poland.getName(), poland); - - Country uk = new Country(); - uk.setName("United Kingdom"); - uk.setCapital("London"); - uk.setCurrency(Currency.GBP); - uk.setPopulation(63705000); - - countries.put(uk.getName(), uk); - } - - public Country findCountry(String name) { - Assert.notNull(name, "The country's name must not be null"); - return countries.get(name); - } -} diff --git a/helpapp/soap-service/src/main/java/com/example/producingwebservice/ProducingWebServiceApplication.java b/helpapp/soap-service/src/main/java/com/example/producingwebservice/ProducingWebServiceApplication.java deleted file mode 100644 index e9308b1..0000000 --- a/helpapp/soap-service/src/main/java/com/example/producingwebservice/ProducingWebServiceApplication.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.example.producingwebservice; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class ProducingWebServiceApplication { - - public static void main(String[] args) { - SpringApplication.run(ProducingWebServiceApplication.class, args); - } -} diff --git a/helpapp/soap-service/src/main/java/com/example/producingwebservice/WebServiceConfig.java b/helpapp/soap-service/src/main/java/com/example/producingwebservice/WebServiceConfig.java deleted file mode 100644 index 3379538..0000000 --- a/helpapp/soap-service/src/main/java/com/example/producingwebservice/WebServiceConfig.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.example.producingwebservice; - -import org.springframework.boot.web.servlet.ServletRegistrationBean; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.ClassPathResource; -import org.springframework.ws.config.annotation.EnableWs; -import org.springframework.ws.config.annotation.WsConfigurerAdapter; -import org.springframework.ws.transport.http.MessageDispatcherServlet; -import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition; -import org.springframework.xml.xsd.SimpleXsdSchema; -import org.springframework.xml.xsd.XsdSchema; - -@EnableWs -@Configuration -public class WebServiceConfig extends WsConfigurerAdapter { - @Bean - public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) { - MessageDispatcherServlet servlet = new MessageDispatcherServlet(); - servlet.setApplicationContext(applicationContext); - servlet.setTransformWsdlLocations(true); - return new ServletRegistrationBean<>(servlet, "/ws/*"); - } - - @Bean(name = "countries") - public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) { - DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition(); - wsdl11Definition.setPortTypeName("CountriesPort"); - wsdl11Definition.setLocationUri("/ws"); - wsdl11Definition.setTargetNamespace("http://spring.io/guides/gs-producing-web-service"); - wsdl11Definition.setSchema(countriesSchema); - return wsdl11Definition; - } - - @Bean - public XsdSchema countriesSchema() { - return new SimpleXsdSchema(new ClassPathResource("countries.xsd")); - } -} diff --git a/helpapp/soap-service/src/main/resources/application.properties b/helpapp/soap-service/src/main/resources/application.properties deleted file mode 100644 index e69de29..0000000 diff --git a/helpapp/soap-service/src/main/resources/countries.xsd b/helpapp/soap-service/src/main/resources/countries.xsd deleted file mode 100644 index a893956..0000000 --- a/helpapp/soap-service/src/main/resources/countries.xsd +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/helpapp/soap-service/src/test/java/com/example/producingwebservice/ProducingWebServiceApplicationIntegrationTests.java b/helpapp/soap-service/src/test/java/com/example/producingwebservice/ProducingWebServiceApplicationIntegrationTests.java deleted file mode 100644 index cc030be..0000000 --- a/helpapp/soap-service/src/test/java/com/example/producingwebservice/ProducingWebServiceApplicationIntegrationTests.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2014-2015 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.producingwebservice; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import io.spring.guides.gs_producing_web_service.GetCountryRequest; - -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.server.LocalServerPort; -import org.springframework.oxm.jaxb.Jaxb2Marshaller; -import org.springframework.util.ClassUtils; -import org.springframework.ws.client.core.WebServiceTemplate; - -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -public class ProducingWebServiceApplicationIntegrationTests { - - private Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); - - @LocalServerPort - private int port = 0; - - @BeforeEach - public void init() throws Exception { - marshaller.setPackagesToScan(ClassUtils.getPackageName(GetCountryRequest.class)); - marshaller.afterPropertiesSet(); - } - - @Test - public void testSendAndReceive() { - WebServiceTemplate ws = new WebServiceTemplate(marshaller); - GetCountryRequest request = new GetCountryRequest(); - request.setName("Spain"); - - assertThat(ws.marshalSendAndReceive("http://localhost:" - + port + "/ws", request) != null); - } -} diff --git a/helpapp/volunteer-service/pom.xml b/helpapp/volunteer-service/pom.xml new file mode 100644 index 0000000..298515b --- /dev/null +++ b/helpapp/volunteer-service/pom.xml @@ -0,0 +1,40 @@ + + + insa.application.helpapp + helpapp + 1.0-SNAPSHOT + + 4.0.0 + volunteer-service + + + + + org.springframework.boot + spring-boot-starter-web + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 3.1.4 + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 21 + 21 + + + + + + diff --git a/helpapp/volunteer-service/src/main/java/insa/application/helpapp/rest/RestApplication.java b/helpapp/volunteer-service/src/main/java/insa/application/helpapp/rest/RestApplication.java new file mode 100644 index 0000000..2e82618 --- /dev/null +++ b/helpapp/volunteer-service/src/main/java/insa/application/helpapp/rest/RestApplication.java @@ -0,0 +1,20 @@ +package insa.application.helpapp.rest; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@SpringBootApplication +@RestController +public class RestApplication { + + public static void main(String[] args) { + SpringApplication.run(RestApplication.class, args); + } + + @GetMapping("/hello") + public String hello() { + return "Hello from REST!"; + } +} diff --git a/helpapp/volunteer-service/src/main/resources/application.properties b/helpapp/volunteer-service/src/main/resources/application.properties new file mode 100644 index 0000000..4c00e40 --- /dev/null +++ b/helpapp/volunteer-service/src/main/resources/application.properties @@ -0,0 +1 @@ +server.port=8080