Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 2c51fdc2 authored by Jujube Orange's avatar Jujube Orange
Browse files

refactor: remove legacy implementation

parent 7dab02ff
No related branches found
No related tags found
2 merge requests!105Release 2.3.2,!102refactor: remove legacy implementation
Pipeline #682822 canceled
Showing
with 0 additions and 2567 deletions
......@@ -3,20 +3,6 @@ include:
ref: master
file: gitlab/gitlab-ci-java-template.yml
build-v1:
image: maven:3.8.3-adoptopenjdk-11
stage: build
before_script:
- cd legacy-submission-code-server
script:
- mvn -B -s .mvn/settings-ci.xml $CI_MAVEN_OPTS deploy
artifacts:
paths:
- "**/target/"
reports:
junit:
- "**/target/*-reports/TEST-*.xml"
build-docker:
image: maven:3.8.3-adoptopenjdk-11
stage: build
......
This diff is collapsed.
#Organize Import Order
#Tue Jun 08 16:57:09 CEST 2021
0=
1=javax
2=java
3=\#
#!/usr/bin/env bash
# check prettier is installed
if ! command -v prettier &> /dev/null ; then
echo '🙏 Please, install prettier so we can check yaml/xml/md/json files'
echo '📝 `npm install -g prettier @prettier/plugin-xml`'
echo ''
echo 'Have you read this? ☝'
echo ''
fi
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
[ -z "$FILES" ] && exit 0
# Prettify all selected files
echo "$FILES" | xargs prettier --ignore-unknown --write
# Spotlessify java source files
mvn spotless:apply
# Add back the modified/prettified files to staging
echo "$FILES" | xargs git add
exit 0
#!/usr/bin/env bash
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local oid> <remote ref> <remote oid>
# This hook prevent push of commits where the author or commiter isn't pseudonymised
ALLOW_LIST="
Ananas Orange <12847-x-AOrang@users.noreply.gitlab.inria.fr>
Bergamote Orange <13178-x-BOrang@users.noreply.gitlab.inria.fr>
Combava Orange <13340-x-CoOrang@users.noreply.gitlab.inria.fr>
Framboise Orange <12541-x-FrOrang@users.noreply.gitlab.inria.fr>
Jujube Orange <13631-x-JOrang@users.noreply.gitlab.inria.fr>
Kiwi Orange <13476-x-KOrang@users.noreply.gitlab.inria.fr>
Cacaoyer Tac <99999-Cacaoyer.tac@users.noreply.gitlab.inria.fr>
Cafeier Tac <99999-Cafeier.tac@users.noreply.gitlab.inria.fr>
Caladium Tac <99999-Caladium.tac@users.noreply.gitlab.inria.fr>
Calamagrostis Tac <99999-Calamagrostis.tac@users.noreply.gitlab.inria.fr>
Calament Tac <99999-Calament.tac@users.noreply.gitlab.inria.fr>
Calamondin Tac <99999-Calamondin.tac@users.noreply.gitlab.inria.fr>
Calanthe Tac <99999-Calanthe.tac@users.noreply.gitlab.inria.fr>
Calibrachoa Tac <99999-Calibrachoa.tac@users.noreply.gitlab.inria.fr>
Jenkins Tac <99999-Jenkins.tac@users.noreply.gitlab.inria.fr>
Figue Orange <12540-x-FOrang@users.noreply.gitlab.inria.fr>
Jamalac Orange <14492-x-JaOrang@users.noreply.gitlab.inria.fr>
Renovate Bot <tac-renovate-bot-request@inria.fr>
Sapotille Orange <15519-x-SaOrang@users.noreply.gitlab.inria.fr>
"
remote="$1"
url="$2"
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
while read local_ref local_oid remote_ref remote_oid
do
if test "$local_oid" = "$zero"
then
# Nothing to to on branch deletion
:
else
if test "$remote_oid" = "$zero"
then
# New branch, examine all commits
range="5bb417c3..$local_oid"
else
# Update to existing branch, examine new commits
range="$remote_oid..$local_oid"
fi
echo -n "Checking the author/commiter is in the allowed list ($0) "
for format in '%an <%ae>' '%cn <%ce>'
do
while read -r user
do
allowed_user=$(grep "^$user$" <<<$ALLOW_LIST)
if test ! -n "$allowed_user"
then
echo "❌"
echo >&2 "'$user' is not allowed in $local_ref, not pushing"
exit 1
fi
done <<<$(git log --format="format:$format" $range | sort | uniq)
done
echo "✅"
fi
done
exit 0
<extensions
xmlns="http://maven.apache.org/EXTENSIONS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd"
>
<extension>
<groupId>me.qoomon</groupId>
<artifactId>maven-git-versioning-extension</artifactId>
<version>6.4.4</version>
</extension>
</extensions>
-Xms128m -Xmx256m -Djava.awt.headless=true
<configuration
xmlns="https://github.com/qoomon/maven-git-versioning-extension"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://github.com/qoomon/maven-git-versioning-extension https://qoomon.github.io/maven-git-versioning-extension/configuration-6.4.0.xsd"
>
<disable>true</disable>
<preferTags>true</preferTags>
<tag>
<pattern>(.+)</pattern>
<versionFormat>${tag}</versionFormat>
</tag>
<branch>
<pattern>(develop|master)</pattern>
<versionFormat>${1}-SNAPSHOT</versionFormat>
</branch>
<branch>
<pattern>(feature|hotfix)/(.+)</pattern>
<versionFormat>${2.slug}-SNAPSHOT</versionFormat>
</branch>
<branch>
<pattern>(.+)</pattern>
<versionFormat>${version}</versionFormat>
</branch>
</configuration>
<settings>
<servers>
<server>
<id>gitlab-maven</id>
<configuration>
<httpHeaders>
<property>
<name>Job-Token</name>
<value>${env.CI_JOB_TOKEN}</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
</settings>
Ce composant à été écrit par
- Groupe Capgemini (Capgemini, Idean, Sogeti)
Les personnes suivantes ont contribué
- Pour Groupe Capgemini (Capgemini, Idean, Sogeti)
- redford.stopcovid@idean.com
- palmer.stopcovid@capgemini.com
- marley.stopcovid@capgemini.com
- stanley.stopcovid@capgemini.com
- begnini.stopcovid@capgemini.com
- deniro.stopcovid@capgemini.com
# Unreleased Changelog
Les changements ne faisant pas encore partie d'une release doivent être
consignés dans ce fichier.
## [Unreleased]
# Changelog
Toute modification liée au code exécuté en production sera documenté dans ce fichier.
Le présent format s'appuie sur [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
Ce fichier ne doit pas être mis à jour directement, il faut utiliser le fichier
`CHANGELOG-UNRELEASED.md`.
Par la suite les changements de `CHANGELOG-UNRELEASED.md` sont reversé dans ce
fichier lors de la création d'une nouvelle release.
##
# Mozilla Public License
# Version 2.0
# 1. Definitions
### 1.1. “Contributor”
means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software.
### 1.2. “Contributor Version”
means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor’s Contribution.
### 1.3. “Contribution”
means Covered Software of a particular Contributor.
### 1.4. “Covered Software”
means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof.
### 1.5. “Incompatible With Secondary Licenses”
means
a. that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or
b. that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License.
### 1.6. “Executable Form”
means any form of the work other than Source Code Form.
### 1.7. “Larger Work”
means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software.
### 1.8. “License”
means this document.
### 1.9. “Licensable”
means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License.
### 1.10. “Modifications”
means any of the following:
a. any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or
b. any new file in Source Code Form that contains any Covered Software.
### 1.11. “Patent Claims” of a Contributor
means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version.
### 1.12. “Secondary License”
means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses.
### 1.13. “Source Code Form”
means the form of the work preferred for making modifications.
### 1.14. “You” (or “Your”)
means an individual or a legal entity exercising rights under this License. For legal entities, “You” includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
# 2. License Grants and Conditions
## 2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
a. under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and
b. under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version.
## 2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution.
## 2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor:
a. for any code that a Contributor has removed from Covered Software; or
b. for infringements caused by: (i) Your and any other third party’s modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or
c. under Patent Claims infringed by Covered Software in the absence of its Contributions.
This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4).
## 2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3).
## 2.5. Representation
Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License.
## 2.6. Fair Use
This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents.
## 2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1.
# 3. Responsibilities
## 3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients’ rights in the Source Code Form.
## 3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
a. such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and
b. You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients’ rights in the Source Code Form under this License.
### 3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s).
## 3.4. Notices
You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies.
## 3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction.
# 4. Inability to Comply Due to Statute or Regulation
If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.
# 5. Termination
5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination.
# 6. Disclaimer of Warranty
_Covered Software is provided under this License on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the Covered Software is with You. Should any Covered Software prove defective in any respect, You (not any Contributor) assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty constitutes an essential part of this License. No use of any Covered Software is authorized under this License except under this disclaimer._
# 7. Limitation of Liability
_Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such party’s negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You._
# 8. Litigation
Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party’s ability to bring cross-claims or counter-claims.
# 9. Miscellaneous
This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor.
# 10. Versions of the License
## 10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number.
## 10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward.
## 10.3. Modified Versions
If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License).
## 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached.
# Exhibit A - Source Code Form License Notice
> This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice.
You may add additional accurate notices of copyright ownership.
# Exhibit B - “Incompatible With Secondary Licenses” Notice
> This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.
# Submission Code Server
Ce projet gitlab.inria.fr est un des composants de la solution plus globale [StopCovid](https://gitlab.inria.fr/stopcovid19/accueil/-/blob/master/README.md).
Ce composant propose les services suivants :
- génération de codes courts et longs : pour les professionnels de santé (laboratoires, médecins...)
- vérification et consommation de codes par la partie de la plateforme StopCovid
## Quickstart
Démarrer une base postgres en local :
docker run -d --name db-scs -p 5432:5432 -e POSTGRES_PASSWORD=1234 -e POSTGRES_DB=dev-submission-code-server-schema postgres:13
L'application peut être démarrée depuis l'IDE.
# Description du fonctionnement de l'outil de génération des codes longs
## Cinématique
Pour générer 300 000 codes un opérateur réalisera l'opération suivante :
Il ne peut générer plus de 40 000 codes d'un coup (limitation due au code).
Il va donc découper ces appels et réaliser (7 _ 40 000) + (1 _ 20 000) = 300 000.
Les appels se font via une requête POST sur la route `/api/v1/back-office/codes/generate/request`.
En passant en paramètre les informations suivantes dans le Body :
```
{
"from":"2021-07-01T00:00:00.000Z",
"to":"2021-07-09T23:59:59.000Z",
"dailyAmount":40000
}
```
from : correspond à la date du début de validité des codes.
to : correspond à la fin de validité des codes et doit être postérieure à la date from.
L'opérateur effectuera donc 7 appels avec le paramètre dailyAmount à 40000 et un appel avec le paramètre dailyAmount à 20000.
Tous les appels auront les mêmes paramères from et to qui correspondent au début et à la fin de validité des codes.
Chaque appel donne lieu à la création de deux fichiers (voir § ci-dessous).
Une exécution du script est finie quand ce message s'affiche dans les logs.
```
INFO fr.gouv.stopc.submission.code.server.ws.service.impl.FileServiceImpl [task-{}] It took {} seconds to generate {} codes
```
## Fichiers de sortie
### Fichiers
Deux fichiers par appels sont générés :
- Un fichier `.tgz` contenant la liste des codes
- Un fichier de contrôle `.sha256` (somme de contrôle) permettant de contrôler l'intégrité du fichier .tgz
### Nomenclature
Les noms des fichiers sont générés de la manière suivante :
Pour le premier fichier, le nom est composé de la date de génération au format `yyyyMMddHHmmss` (en zone "Europe/Paris") concaténé avec `%s_stopcovid_qrcode_batch.tgz` ce qui donne pour mon exemple
`20210819092922_stopcovid_qrcode_batch.tgz`
La nomenclature est la même pour le second fichier seule l'extention diffère `.sha256`.
`20210819092922_stopcovid_qrcode_batch.sha256`
### Contenu
#### Premier fichier (yyyyMMddHHmmss_stopcovid_qrcode_batch.tgz)
Le fichier contenant la liste des codes est une archive `tgz` contenant une seconde archive `tar` contenant un `csv` qui est la liste des codes.
La nomenclature du nom du fichier csv est la suivante `(séquence) + AAMMdd.csv ==> 25210825.csv`
La séquence correspond à un incrément lié à un triptyque temporel (AAMMdd) pour éviter de générer deux fichiers de même nom.
Voici un exemple avec un seul code généré
| code_pour_qr | code_brut | validite_debut | validite_fin |
| ------------- | :-----------: | -----------------------: | -----------------------: |
| ...41 char... | ...36 char... | 2021-08-25T22:00:00.000Z | 2021-09-02T21:59:00.000Z |
Le séparateur de ce csv est une virgule `,` et il y a un retour chariot à la fin du fichier (LF).
#### Second fichier (yyyyMMddHHmmss_stopcovid_qrcode_batch.sha256)
Ce fichier est un fichier plat contenant une empreinte de 65 caractères du fichier tgz.
Ce fichier ne contient pas de retour chariot à la fin du fichier.
## Gestion des différents cas fonctionnels (changement du nb de code, reprise/rejeux …)
### Changement du nombre de codes
S'il faut générer plus ou moins de codes, il faut réaliser plus ou moins de requêtes en réalisant le calcul suivant.
Exemple :
Je veux générer `500 000` codes :
`500 000` / 40 000 = 12,5 ==> 12 appels de 40 000 codes
`500 000` mod 40 000 = 20 000 ==> 1 appel de 20 000 codes
### Reprise / Rejeux
Dans le cas où un problème serait survenu, il faut invalider les codes générés ou lister les codes non sauvegardés en base.
Pour ce faire, il faut réaliser des requêtes en base de données ou sur le serveur sftp.
```
# Utile pour repérer s'il n'y a pas de désynchro entre l'indice connu et le dernier fichier envoyé
select * from seq_fichier where jour = '10' and mois = '08' and annee = '2021';
# Compter le nombre de codes ajoutés (en tenant compte de l'UTC)
select count(*) from submission_code where date_available between '2021-08-09 22:00:00' and '2021-08-17 22:00:00';
# Lancer le script python de vérification des codes dans la base de données
python verify-codes.py [dbName] [dbHost] [dbPort] [dbUser] [qrcodes-file-path]
```
S'il manque des codes, il faut regénérer le nombre de code souhaité.
<?xml version="1.0" encoding="UTF-8" ?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.4</version>
<relativePath />
</parent>
<groupId>fr.gouv.stopc</groupId>
<artifactId>legacy-submission-code-server</artifactId>
<name>legacy-submission-code-server</name>
<packaging>jar</packaging>
<version>0-SNAPSHOT</version>
<description>Submission Server</description>
<properties>
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<org.testcontainers>1.16.0</org.testcontainers>
<cucumber.version>6.11.0</cucumber.version>
<cucumber-reporting.version>5.6.0</cucumber-reporting.version>
<log4j2.version>2.17.0</log4j2.version>
<spring-framework.version>5.3.18</spring-framework.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-to-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>2.4.4</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.5.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.21</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.55</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${org.testcontainers}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>${org.testcontainers}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>${cucumber-reporting.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.24</version>
</dependency>
<!--Dependencies required for openapi generated sources -->
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.1</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.prometheus</groupId>
<artifactId>simpleclient_pushgateway</artifactId>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.version}</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.4</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>7.0.4</version>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.9.0.2155</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.1.0</version>
<configuration>
<inputSpec>
${project.basedir}/src/main/resources/submission-code-server-api.yml
</inputSpec>
<generatorName>spring</generatorName>
<apiPackage>
fr.gouv.stopc.submission.code.server.api
</apiPackage>
<modelPackage>
fr.gouv.stopc.submission.code.server.business.model
</modelPackage>
<configOptions>
<dateLibrary>java8-localdatetime</dateLibrary>
<interfaceOnly>true</interfaceOnly>
<useTags>true</useTags>
<additionalModelTypeAnnotations>
@lombok.Builder
@lombok.AllArgsConstructor
@lombok.NoArgsConstructor
</additionalModelTypeAnnotations>
<unhandledException>true</unhandledException>
</configOptions>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.rudikershaw.gitbuildhook</groupId>
<artifactId>git-build-hook-maven-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<gitConfig>
<core.hooksPath>.etc/git-hooks</core.hooksPath>
</gitConfig>
</configuration>
<executions>
<execution>
<inherited>false</inherited>
<goals>
<goal>configure</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.11.1</version>
<configuration>
<java>
<importOrder>
<file>.etc/eclipse.importorder</file>
</importOrder>
<removeUnusedImports />
<eclipse>
<file>.etc/eclipse-formatter-java.xml</file>
</eclipse>
</java>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<configuration>
<rules>
<requireReleaseDeps>
<message>No Snapshots Allowed!</message>
</requireReleaseDeps>
</rules>
<fail>false</fail>
</configuration>
<executions>
<execution>
<id>enforce-no-snapshots</id>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>release</id>
<activation>
<property>
<name>git.tag</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<configuration>
<fail>true</fail>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<distributionManagement>
<repository>
<id>gitlab-maven</id>
<url>
https://gitlab.inria.fr/api/v4/projects/stopcovid19%2Fsubmission-code-server/packages/maven
</url>
</repository>
<snapshotRepository>
<id>gitlab-maven</id>
<url>
https://gitlab.inria.fr/api/v4/projects/stopcovid19%2Fsubmission-code-server/packages/maven
</url>
</snapshotRepository>
</distributionManagement>
<scm>
<connection>
scm:git:git@gitlab.inria.fr:stopcovid19/submission-code-server.git
</connection>
<developerConnection>
scm:git:git@gitlab.inria.fr:stopcovid19/submission-code-server.git
</developerConnection>
<url>https://gitlab.inria.fr/stopcovid19/submission-code-server</url>
<tag>HEAD</tag>
</scm>
</project>
# This Dockerfile is useful to quickly setup a test/dev environment.
# It should not be used in production.
# mvn package -Dmaven.test.skip=true
# docker build -f src/main/docker/Dockerfile -t tac/submission-code-server-ws-rest .
FROM registry.gitlab.inria.fr/stemcovid19/tac-server/docker-image/oracle-serverjre:1.8.0_241-b07
ADD ./target/submission-code-server-*.jar /app.jar
ADD ./src/main/resources/application.properties /work/config/application.properties
CMD ["java","-jar", "/app.jar", "--spring.config.location=file:/work/config/application.properties"]
package fr.gouv.stopc.submission.code.server;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import javax.annotation.PostConstruct;
import java.util.TimeZone;
@ComponentScan(basePackages = "fr.gouv.stopc")
@EnableAsync
@SpringBootApplication
public class SubmissionCodeServerApplication {
public static void main(String[] args) {
SpringApplication.run(SubmissionCodeServerApplication.class, args);
}
@PostConstruct
void started() {
// set JVM timezone as UTC
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
}
}
package fr.gouv.stopc.submission.code.server.business.controller;
import fr.gouv.stopc.submission.code.server.api.GenerateCodeApi;
import fr.gouv.stopc.submission.code.server.business.model.CodeSimpleDto;
import fr.gouv.stopc.submission.code.server.business.service.GenerateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.inject.Inject;
/**
* VPN Control is made to access to this end-point. JWT or ApiKey is checked in
* API Gateway.
*/
@Slf4j
@RestController
@RequestMapping(value = "/api/v1")
public class GenerateController implements GenerateCodeApi {
private final GenerateService generateService;
@Inject
public GenerateController(GenerateService generateService) {
this.generateService = generateService;
}
/**
* Generate a new submission code. Codes are one-time use and have a validity
* date
*
* @return ResponseEntity<CodeSimpleDto>
*/
@Override
public ResponseEntity<CodeSimpleDto> generate() throws Exception {
log.info("Trying to generate code with sequential method");
return ResponseEntity.ok(this.generateService.generateShortCode());
}
@Override
public ResponseEntity<CodeSimpleDto> generateTest() {
log.info("Try to generate a test code that is 12 characters long.");
return ResponseEntity.ok(this.generateService.generateTestCode());
}
}
package fr.gouv.stopc.submission.code.server.business.controller;
import fr.gouv.stopc.submission.code.server.api.KpiApi;
import fr.gouv.stopc.submission.code.server.business.model.Kpi;
import fr.gouv.stopc.submission.code.server.business.service.KpiService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate;
import java.util.List;
/**
* Kpi generation REST controller definition
*
* @author plant-stopcovid
*/
@RestController
@RequestMapping(value = "/internal/api/v1")
public class KpiController implements KpiApi {
/**
* The Kpi generation service
*/
private KpiService kpiService;
/**
* Spring Injection constructor
*
* @param kpiService the <code>IKpiService</code> bean instance to inject
*/
public KpiController(KpiService kpiService) {
this.kpiService = kpiService;
}
/**
* Computes the Kpi on a period
*
* @param fromDate beginning date of the period
* @param toDate ending date of the period
* @return the list of Kpi computed on this period (one per day)
*/
@Override
public ResponseEntity<List<Kpi>> kpi(LocalDate fromDate, LocalDate toDate) throws Exception {
return ResponseEntity.ok(this.kpiService.generateKPI(fromDate, toDate));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment