Skip to content

Commit

Permalink
renommage pour simplifier la lecture (rest,batch,web)
Browse files Browse the repository at this point in the history
  • Loading branch information
cordier committed Jan 9, 2020
1 parent f6e5b11 commit 0aaa56c
Show file tree
Hide file tree
Showing 93 changed files with 223 additions and 124 deletions.
51 changes: 18 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,49 @@
Projet Bibliothèque - projet 07
=

Technique
==
Référence
---
* https://openclassrooms.com/fr/courses/5684146-create-web-applications-efficiently-with-the-spring-boot-mvc-framework

Environnement
---
* Spring Boot, PostgreSql, httpClient, Git, Maven

Starters Spring Boot
---
* Web, Security, Data/Jpa, Hibernate, Mail
* Spring Boot ( Web, Security, Data/Jpa, Hibernate, Mail), PostgreSql, httpClient, Git, Maven

Jars executables
---
* Un service REST pour les méthodes de persistence - JPA/Hibernate et PostgreSql.
* Un service REST pour les méthodes de persistence - Spring Data/JPA et Hibernate.
* Un batch pour envoi de email - "@Scheduled"
* Une Web application MVC - template engine : ThymeLeaf

Communication entre services
---
* Httpclient (jdk 11) placée dans une lib déployeé dans un repo local

Build, gestion de source
Installation sous Windows
---
* Git version 2.24.0.windows.2
* Apache Maven 3.6.0
* Intellij IDEA 2019.3.1 Ultimate
* Oracle JDK 11.04
* PostgreSql 12
* Projet à Cloner depuis https://github.com/lco3004/ocr-projet07-v3.git

Installation sous Windows
==
Installation de l'environnement
Création de la base PostgreSql
---
* Installer Apache Maven V3 et Oracle JDK 11
* Modifier la policy pour autoriser l'exécution des scripts 'Set-ExecutionPolicy Unrestricted'
* Verifier avec mvn --version

Clone depuis GitHub
---
* Cloner depu is https://github.com/lco3004/ocr-projet07-v3.git

Création de la base PostgresSql
---
* Lancer le service windows PostgreSql (barre de recherche Windows, saisir services.msc)
* Créer le répertoire des tablespaces :'c:\bd_data'
* Sous pgsql, exécuter le script sql_uml/prep_projet07.sql
* Installer pgadmin v4
* Sous pgadmin, attribuer le password projet07 au role rl_projet07
* Choisir la base db_projet07 - mdp identique au role rl_projet07
* Enfin , exécuter sql_uml/create_tbl.sql

Lancement des applications
==
Application Web et Service Rest
--
Service Rest
---
* Ouvrir un terminal puis se placer dans le répertoire de l'application ( ex : service_crud)
* Lancer l'application avec mvn spring-boot:run'
* Ouvrir un terminal puis se placer dans le répertoire du service_crud
* Lancer l'application avec mvn spring-boot:run (c'est une démo...)

Application Web
---
* Ouvrir un terminal puis se placer dans le répertoire de l'application Web
* Lancer l'application avec mvn spring-boot:run (c'est une démo...)


Application Batch
---
Expand All @@ -67,7 +52,7 @@ Application Batch
* lancer le service avec mvn spring-boot:run -Dspring-boot.run.arguments="immediat"

Utilisation de l'application
==
--
Login
---
* connexion avec un des usagers du jeu de test (ex : juie / julie)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions service_batchmail/pom.xml → application_batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<artifactId>service_batchmail</artifactId>
<version>1.0-SNAPSHOT</version>
<name>service_batchmail</name>
<name>application_batch</name>
<description> projet 07 batch mail scheduleur</description>
<packaging>jar</packaging>

Expand Down Expand Up @@ -83,7 +83,7 @@
</dependencies>

<build>
<finalName>service_batchmail</finalName>
<finalName>application_batch</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
@PropertySources( {
@PropertySource(value = "classpath:application.properties"),
@PropertySource(value = "classpath:application.yml")})
public class ServiceBatchmailApplication implements CommandLineRunner{
public class ApplicationBatch implements CommandLineRunner{

@Autowired
private ScheduledMailer scheduledMailer;

private static final Logger log = LoggerFactory.getLogger(ServiceBatchmailApplication.class);
private static final Logger log = LoggerFactory.getLogger(ApplicationBatch.class);

public static void main(String[] args) {

SpringApplication.run(ServiceBatchmailApplication.class, args);
SpringApplication.run(ApplicationBatch.class, args);

}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions service_frontmvc/pom.xml → application_web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

<artifactId>service_frontmvc</artifactId>
<version>1.0-SNAPSHOT</version>
<name>service_frontmvc</name>
<description>projet 07 - service web</description>
<name>application_web</name>
<description>projet 07 - application_web</description>
<packaging>jar</packaging>

<dependencies>
Expand Down Expand Up @@ -74,7 +74,7 @@
</dependencies>

<build>
<finalName>service_frontmvc</finalName>
<finalName>application_web</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
@PropertySource(value = "classpath:application.properties"),
@PropertySource(value = "classpath:application.yml")})
@EnableSwagger2
public class ServiceFrontMvcApplication {
public class ApplicationWeb {

public static void main(String[] args) {

SpringApplication.run(ServiceFrontMvcApplication.class, args);
SpringApplication.run(ApplicationWeb.class, args);
}
@Bean
public RestClient libHttpClient() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import fr.ocr.front_mvc.service.UserWebService;
import fr.ocr.front_mvc.userdetails.UserWebUserDetails;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
Expand Down Expand Up @@ -42,6 +44,8 @@ public class DispatchController {
private final UserWebService userWebService;

private final Map<String, Object> model;
private static final Logger log = LoggerFactory.getLogger(DispatchController.class);


public DispatchController(RestClient restClient, ObjectMapper objectMapper, UserWebService userWebService, Map<String, Object> model){
this.restClient = restClient;
Expand Down Expand Up @@ -194,8 +198,16 @@ public ModelAndView getListePrestCtrl() throws RuntimeException, IOException, In
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();

assert principal instanceof UserWebUserDetails;
UserWebUserDetails userWebUserDetails = (UserWebUserDetails)principal;
String username = ((UserWebUserDetails)principal).getUserWeb().getUsername();
UserWebUserDetails userWebUserDetails =null;
String username = "";
try {
userWebUserDetails = (UserWebUserDetails)principal;
username = ((UserWebUserDetails)principal).getUserWeb().getUsername();

}catch (RuntimeException e) {
log.warn("Accès aux prêts impossible car pas connecté");
throw new RuntimeException("Accès aux prêts impossible car pas connecté");
}

HttpRequest request = restClient.requestBuilder(URI.create(uriPretByNomUsager + username), null).GET().build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="d-flex justify-content-center align-items-center" id="main">
<h1 class="mr-3 pr-3 align-top border-right inline-block align-content-center">Oops!</h1>
<div class="inline-block align-middle">
<h2 class="font-weight-normal lead" id="desc">This is embarrassing!&#128532; Please contact our support! &#128591; </h2>
<h2 class="font-weight-normal lead" id="desc">Vous n'êtes pas identifié . </h2>
</div>
</div>

Expand Down
91 changes: 77 additions & 14 deletions logs/service_batch.log
Original file line number Diff line number Diff line change
@@ -1,14 +1,77 @@
[2020-01-09T08:14:59.059Z] [org.springframework.boot.StartupInfoLogger] [restartedMain] [55] [INFO ] Starting ServiceBatchmailApplication on DESKTOP-HE1TMKM with PID 5068 (D:\OpenClassRooms\OCR-Projet07\ocr-projet07-v4\service_batchmail\target\classes started by cordier in D:\OpenClassRooms\OCR-Projet07\ocr-projet07-v4)
[2020-01-09T08:14:59.059Z] [org.springframework.boot.StartupInfoLogger] [restartedMain] [56] [DEBUG] Running with Spring Boot v2.2.0.RELEASE, Spring v5.2.0.RELEASE
[2020-01-09T08:14:59.059Z] [org.springframework.boot.SpringApplication] [restartedMain] [651] [INFO ] No active profile set, falling back to default profiles: default
[2020-01-09T08:14:59.059Z] [org.springframework.boot.logging.DeferredLog] [restartedMain] [225] [INFO ] Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
[2020-01-09T08:14:59.059Z] [org.springframework.boot.logging.DeferredLog] [restartedMain] [225] [INFO ] For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
[2020-01-09T08:15:00.000Z] [org.springframework.boot.web.embedded.tomcat.TomcatWebServer] [restartedMain] [92] [INFO ] Tomcat initialized with port(s): 9092 (http)
[2020-01-09T08:15:00.000Z] [org.apache.juli.logging.DirectJDKLog] [restartedMain] [173] [INFO ] Starting service [Tomcat]
[2020-01-09T08:15:00.000Z] [org.apache.juli.logging.DirectJDKLog] [restartedMain] [173] [INFO ] Starting Servlet engine: [Apache Tomcat/9.0.27]
[2020-01-09T08:15:00.000Z] [org.apache.juli.logging.DirectJDKLog] [restartedMain] [173] [INFO ] Initializing Spring embedded WebApplicationContext
[2020-01-09T08:15:00.000Z] [org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext] [restartedMain] [284] [INFO ] Root WebApplicationContext: initialization completed in 743 ms
[2020-01-09T08:15:00.000Z] [org.springframework.scheduling.concurrent.ExecutorConfigurationSupport] [restartedMain] [171] [INFO ] Initializing ExecutorService 'applicationTaskExecutor'
[2020-01-09T08:15:00.000Z] [org.springframework.scheduling.concurrent.ExecutorConfigurationSupport] [restartedMain] [171] [INFO ] Initializing ExecutorService 'taskScheduler'
[2020-01-09T08:15:00.000Z] [org.springframework.boot.web.embedded.tomcat.TomcatWebServer] [restartedMain] [204] [INFO ] Tomcat started on port(s): 9092 (http) with context path ''
[2020-01-09T08:15:00.000Z] [org.springframework.boot.StartupInfoLogger] [restartedMain] [61] [INFO ] Started ServiceBatchmailApplication in 1.614 seconds (JVM running for 2.341)
[2020-01-09T11:00:38.038Z] [org.springframework.boot.StartupInfoLogger] [restartedMain] [55] [INFO ] Starting ApplicationBatch on DESKTOP-HE1TMKM with PID 12104 (D:\OpenClassRooms\OCR-Projet07\ocr-projet07-v4\application_batch\target\classes started by cordier in D:\OpenClassRooms\OCR-Projet07\ocr-projet07-v4)
[2020-01-09T11:00:38.038Z] [org.springframework.boot.StartupInfoLogger] [restartedMain] [56] [DEBUG] Running with Spring Boot v2.2.0.RELEASE, Spring v5.2.0.RELEASE
[2020-01-09T11:00:38.038Z] [org.springframework.boot.SpringApplication] [restartedMain] [651] [INFO ] No active profile set, falling back to default profiles: default
[2020-01-09T11:00:38.038Z] [org.springframework.boot.logging.DeferredLog] [restartedMain] [225] [INFO ] Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
[2020-01-09T11:00:38.038Z] [org.springframework.boot.logging.DeferredLog] [restartedMain] [225] [INFO ] For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
[2020-01-09T11:00:39.039Z] [org.springframework.boot.web.embedded.tomcat.TomcatWebServer] [restartedMain] [92] [INFO ] Tomcat initialized with port(s): 9092 (http)
[2020-01-09T11:00:39.039Z] [org.apache.juli.logging.DirectJDKLog] [restartedMain] [173] [INFO ] Starting service [Tomcat]
[2020-01-09T11:00:39.039Z] [org.apache.juli.logging.DirectJDKLog] [restartedMain] [173] [INFO ] Starting Servlet engine: [Apache Tomcat/9.0.27]
[2020-01-09T11:00:39.039Z] [org.apache.juli.logging.DirectJDKLog] [restartedMain] [173] [INFO ] Initializing Spring embedded WebApplicationContext
[2020-01-09T11:00:39.039Z] [org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext] [restartedMain] [284] [INFO ] Root WebApplicationContext: initialization completed in 733 ms
[2020-01-09T11:00:39.039Z] [org.springframework.scheduling.concurrent.ExecutorConfigurationSupport] [restartedMain] [171] [INFO ] Initializing ExecutorService 'applicationTaskExecutor'
[2020-01-09T11:00:39.039Z] [org.springframework.scheduling.concurrent.ExecutorConfigurationSupport] [restartedMain] [171] [INFO ] Initializing ExecutorService 'taskScheduler'
[2020-01-09T11:00:39.039Z] [org.springframework.boot.web.embedded.tomcat.TomcatWebServer] [restartedMain] [204] [INFO ] Tomcat started on port(s): 9092 (http) with context path ''
[2020-01-09T11:00:39.039Z] [org.springframework.boot.StartupInfoLogger] [restartedMain] [61] [INFO ] Started ApplicationBatch in 1.585 seconds (JVM running for 2.341)
[2020-01-09T11:01:09.009Z] [org.springframework.scheduling.concurrent.ExecutorConfigurationSupport] [SpringContextShutdownHook] [208] [INFO ] Shutting down ExecutorService 'taskScheduler'
[2020-01-09T11:01:09.009Z] [org.springframework.scheduling.concurrent.ExecutorConfigurationSupport] [SpringContextShutdownHook] [208] [INFO ] Shutting down ExecutorService 'applicationTaskExecutor'
[2020-01-09T11:01:17.017Z] [org.springframework.boot.StartupInfoLogger] [restartedMain] [55] [INFO ] Starting ApplicationBatch on DESKTOP-HE1TMKM with PID 10832 (D:\OpenClassRooms\OCR-Projet07\ocr-projet07-v4\application_batch\target\classes started by cordier in D:\OpenClassRooms\OCR-Projet07\ocr-projet07-v4)
[2020-01-09T11:01:17.017Z] [org.springframework.boot.StartupInfoLogger] [restartedMain] [56] [DEBUG] Running with Spring Boot v2.2.0.RELEASE, Spring v5.2.0.RELEASE
[2020-01-09T11:01:17.017Z] [org.springframework.boot.SpringApplication] [restartedMain] [651] [INFO ] No active profile set, falling back to default profiles: default
[2020-01-09T11:01:17.017Z] [org.springframework.boot.logging.DeferredLog] [restartedMain] [225] [INFO ] Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
[2020-01-09T11:01:17.017Z] [org.springframework.boot.logging.DeferredLog] [restartedMain] [225] [INFO ] For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
[2020-01-09T11:01:18.018Z] [org.springframework.boot.web.embedded.tomcat.TomcatWebServer] [restartedMain] [92] [INFO ] Tomcat initialized with port(s): 9092 (http)
[2020-01-09T11:01:18.018Z] [org.apache.juli.logging.DirectJDKLog] [restartedMain] [173] [INFO ] Starting service [Tomcat]
[2020-01-09T11:01:18.018Z] [org.apache.juli.logging.DirectJDKLog] [restartedMain] [173] [INFO ] Starting Servlet engine: [Apache Tomcat/9.0.27]
[2020-01-09T11:01:18.018Z] [org.apache.juli.logging.DirectJDKLog] [restartedMain] [173] [INFO ] Initializing Spring embedded WebApplicationContext
[2020-01-09T11:01:18.018Z] [org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext] [restartedMain] [284] [INFO ] Root WebApplicationContext: initialization completed in 779 ms
[2020-01-09T11:01:18.018Z] [org.springframework.scheduling.concurrent.ExecutorConfigurationSupport] [restartedMain] [171] [INFO ] Initializing ExecutorService 'applicationTaskExecutor'
[2020-01-09T11:01:18.018Z] [org.springframework.scheduling.concurrent.ExecutorConfigurationSupport] [restartedMain] [171] [INFO ] Initializing ExecutorService 'taskScheduler'
[2020-01-09T11:01:18.018Z] [org.springframework.boot.web.embedded.tomcat.TomcatWebServer] [restartedMain] [204] [INFO ] Tomcat started on port(s): 9092 (http) with context path ''
[2020-01-09T11:01:18.018Z] [org.springframework.boot.StartupInfoLogger] [restartedMain] [61] [INFO ] Started ApplicationBatch in 1.622 seconds (JVM running for 2.35)
[2020-01-09T11:01:18.018Z] [fr.ocr.task.ScheduledMailer] [restartedMain] [116] [INFO ] InfosBatchMailDtoBatch(username=julie, [email protected], titre=micro services with spring boot, auteur=Ranga rao karanam, dateEmprunt=Mon Nov 04 01:00:00 CET 2019)
[2020-01-09T11:01:18.018Z] [fr.ocr.task.ScheduledMailer] [restartedMain] [116] [INFO ] InfosBatchMailDtoBatch(username=lola, [email protected], titre=Java JEE developpez des applications Web en Java, auteur=Thierry richard, dateEmprunt=Thu Dec 05 01:00:00 CET 2019)
[2020-01-09T11:01:18.018Z] [fr.ocr.task.ScheduledMailer] [restartedMain] [116] [INFO ] InfosBatchMailDtoBatch(username=lola, [email protected], titre=JPA et Java Hibernate Apprenez le ORM avec Java, auteur=Martial Banon, dateEmprunt=Mon Dec 09 01:00:00 CET 2019)
[2020-01-09T11:01:18.018Z] [fr.ocr.task.ScheduledMailer] [restartedMain] [84] [INFO ]
*********************************************

Bonjour, vous avez emprunté l'ouvrage :
Titre..: micro services with spring boot
De.....: Ranga rao karanam
Le.....: Mon Nov 04 01:00:00 CET 2019

Le délai de 4 semaines est dépassé.
Merci de nous retourner cet ouvrage
L'equipe Municipale
*********************************************

[2020-01-09T11:01:18.018Z] [fr.ocr.task.ScheduledMailer] [restartedMain] [88] [WARN ] Erreur : javalMail to [Ljava.lang.String;@3bde1fd0 - cause :Authentication failed; nested exception is javax.mail.AuthenticationFailedException: failed to connect, no password specified?
[2020-01-09T11:01:18.018Z] [fr.ocr.task.ScheduledMailer] [restartedMain] [84] [INFO ]
*********************************************

Bonjour, vous avez emprunté l'ouvrage :
Titre..: Java JEE developpez des applications Web en Java
De.....: Thierry richard
Le.....: Thu Dec 05 01:00:00 CET 2019

Le délai de 4 semaines est dépassé.
Merci de nous retourner cet ouvrage
L'equipe Municipale
*********************************************

[2020-01-09T11:01:18.018Z] [fr.ocr.task.ScheduledMailer] [restartedMain] [88] [WARN ] Erreur : javalMail to [Ljava.lang.String;@1b9fd553 - cause :Authentication failed; nested exception is javax.mail.AuthenticationFailedException: failed to connect, no password specified?
[2020-01-09T11:01:18.018Z] [fr.ocr.task.ScheduledMailer] [restartedMain] [84] [INFO ]
*********************************************

Bonjour, vous avez emprunté l'ouvrage :
Titre..: JPA et Java Hibernate Apprenez le ORM avec Java
De.....: Martial Banon
Le.....: Mon Dec 09 01:00:00 CET 2019

Le délai de 4 semaines est dépassé.
Merci de nous retourner cet ouvrage
L'equipe Municipale
*********************************************

[2020-01-09T11:01:18.018Z] [fr.ocr.task.ScheduledMailer] [restartedMain] [88] [WARN ] Erreur : javalMail to [Ljava.lang.String;@3cf322de - cause :Authentication failed; nested exception is javax.mail.AuthenticationFailedException: failed to connect, no password specified?
[2020-01-09T11:05:20.020Z] [org.springframework.scheduling.concurrent.ExecutorConfigurationSupport] [SpringContextShutdownHook] [208] [INFO ] Shutting down ExecutorService 'taskScheduler'
[2020-01-09T11:05:20.020Z] [org.springframework.scheduling.concurrent.ExecutorConfigurationSupport] [SpringContextShutdownHook] [208] [INFO ] Shutting down ExecutorService 'applicationTaskExecutor'
Loading

0 comments on commit 0aaa56c

Please sign in to comment.