Skip to content

Commit

Permalink
Commit avec mvc
Browse files Browse the repository at this point in the history
  • Loading branch information
cordier committed Jan 9, 2020
0 parents commit 1f05a02
Show file tree
Hide file tree
Showing 104 changed files with 6,806 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

service_batchmail/target
lib_httpclient/target
service_crud/target
service_web/target

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr


# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out

# dependencies
/node_modules

# profiling files
chrome-profiler-events*.json
speed-measure-plugin*.json

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db
114 changes: 114 additions & 0 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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
https://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.
*/

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.Properties;

public class MavenWrapperDownloader {

/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL =
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";

/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";

public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());

// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: : " + url);

File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}

private static void downloadFileFromURL(String urlString, File destination) throws Exception {
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}

}
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
1 change: 1 addition & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
91 changes: 91 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
Refonte : spring mvc thymeleaf
==

Technique
==
Services Rest (Jar exécutables)
--
* Un service pour les méthodes CRUD sur base PostgreSql
* Un service type "Cron" pour envoi de email

WebApp Spring MVC/ThymeLeaf (Jar exécutable)
--
* Une application qui gère les pages html ainsi que le controle d'accès (login/password)

Spring Boot (OPENCLASSROOMS - cours en anglais)
--
* Web Spring MVC avec ThymeLeaf (OPENCLASSROOMS - cours en anglais)
* Security ( Login-Password, CORS)
* Data/jpa
* Hibernate (API Criteria)
* Embedded tomcat
* Note : utilisation de la librairie Lombok

Base de donnée
--
* PostgreSql v12

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


Build, gestion de source
--
* Git version 2.24.0.windows.2
* Apache Maven 3.6.0
* Intellij IDEA 2019.3.1 Ultimate

Mise en oeuvre sous Windows
==
* Note : Le compte local doit appartenir au groupe 'administrateurs'
#### 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
* Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T20:41:47+02:00)
* Java version: 11.0.4, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-11.0.4
* Default locale: fr_FR, platform encoding: Cp1252
* OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Clone et build des exécutables java
--
#### Créer un repertoire racine du projet - exemple c:\prj07
* Se placer dans le répertoire qui vient d'être créer
#### Cloner le projet : git clone https://github.com/lco3004/ocr-projet07-v3.git .
* Générer les Jar exécutables avec mvn clean install
* Puis aller dans le répertoire lib_httpclient pour déployer le repo local avec mvn deploy
#### installer PostgresSql
* Lancer le service windows PostgreSql (barre de recherche Windows, saisir services.msc)
* La version utilisée est la 12
* 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
#### pour les services CRUD et WEB
* Ouvrir un terminal puis se placer dans le répertoire du service ( ex : service_crud)
* Lancer le service avec mvn spring-boot:run'
#### pour le service Batch
#####dans le contexte de demo, il faut lancer le CRON immédiatement
* Se placer dans le répertoire du service
* Editer le fichier application.yml et valoriser les champs de la rubrique Mail
* lancer le service avec mvn spring-boot:run -Dspring-boot.run.arguments="immediat"
#### répertoires particuliers
* logs contient les traces applicatives
* projet07-repo est le repo maven local (cf configuration "deploy" dans le pom de 'lib_httpclient' )
* Note : Ces répertoires sont supprimés lors d'un mvn clean

Utilisation de l'application
==
#### connexion avec un des usagers du jeu de test (ex : juie / julie)
#### Recherche d'ouvrage :
* Insensible à la Casse
* Fonctionne avec début de mot (ex : chris renvoie Christophe)
#### Prêts :
* le bouton "update" en regard d'un prêt déja prolongé n'apparait plus
#### Parametrage durée du prêt
* Par défaut 4 semaines
* Paramètre dans properties.yml
#### Batch
* Déclenché tous les jours à 10 heures CET
Loading

0 comments on commit 1f05a02

Please sign in to comment.