Skip to content

Commit 854eb2e

Browse files
committed
Merge branch 'main' into devHabilitation
2 parents 6570eb9 + 4ec40de commit 854eb2e

File tree

15 files changed

+437
-194
lines changed

15 files changed

+437
-194
lines changed

.github/workflows/create-release.yaml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,40 @@ jobs:
4747
else
4848
echo "should_continue=true" >> $GITHUB_OUTPUT
4949
fi
50+
build-sources:
51+
needs: check-version
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Set up JDK 21
55+
uses: actions/setup-java@v4
56+
with:
57+
distribution: 'temurin'
58+
java-version: '21'
59+
60+
- name: Clone BPM
61+
uses: actions/checkout@master
62+
with:
63+
repository: InseeFr/BPM
64+
path: bpm
65+
66+
- name: Build BPM
67+
run: |
68+
cd bpm
69+
mvn clean install --no-transfer-progress
70+
cd ..
71+
72+
- uses: actions/checkout@v4
73+
- name: Build app
74+
run: mvn package --no-transfer-progress
75+
76+
- name: Upload app jar
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: app-jar
80+
path: target/*.jar
5081

5182
create-release:
52-
needs: [ check-version ]
83+
needs: [ check-version, build-sources ]
5384
if: needs.check-version.outputs.should_run_next_job == 'true'
5485
runs-on: ubuntu-latest
5586
steps:
@@ -80,3 +111,25 @@ jobs:
80111
body: ${{steps.changeLogContent.outputs.changes}}
81112
env:
82113
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
115+
publish-docker:
116+
needs: [ check-version, create-release ]
117+
runs-on: ubuntu-latest
118+
steps:
119+
- uses: actions/checkout@v4
120+
121+
- name: Download uploaded jar
122+
uses: actions/download-artifact@v4
123+
with:
124+
name: app-jar
125+
path: target/
126+
127+
- name: Publish to Docker Hub
128+
uses: elgohr/Publish-Docker-Github-Action@v5
129+
with:
130+
name: inseefr/genesis-api
131+
username: ${{ secrets.DOCKERHUB_USERNAME }}
132+
password: ${{ secrets.DOCKERHUB_TOKEN }}
133+
default_branch: ${{ github.ref }}
134+
tags: ${{ needs.check-version.outputs.release-tag }}
135+
workdir: .

.github/workflows/docker.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Build snapshot docker image
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
7+
8+
jobs:
9+
build-snapshot:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
branch: ${{ steps.extract_branch.outputs.branch }}
13+
steps:
14+
- name: Extract branch name
15+
shell: bash
16+
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >>$GITHUB_OUTPUT
17+
id: extract_branch
18+
19+
- uses: actions/checkout@v4
20+
with:
21+
ref: ${{ steps.extract_branch.outputs.branch }}
22+
23+
- name: Set up JDK 21
24+
uses: actions/setup-java@v4
25+
with:
26+
distribution: "temurin"
27+
java-version: "21"
28+
29+
- name: Clone BPM
30+
uses: actions/checkout@master
31+
with:
32+
repository: InseeFr/BPM
33+
path: bpm
34+
35+
- name: Build BPM
36+
run: |
37+
cd bpm
38+
mvn clean install --no-transfer-progress
39+
cd ..
40+
41+
- name: Build API
42+
run: mvn package --no-transfer-progress
43+
44+
- name: Upload API jar
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: app-jar
48+
path: target/*.jar
49+
50+
docker:
51+
needs:
52+
- build-snapshot
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- name: Download uploaded jar
58+
uses: actions/download-artifact@v4
59+
with:
60+
name: app-jar
61+
path: target/
62+
63+
- name: Create docker version tag
64+
id: docker-version
65+
run: |
66+
# replace '/' by '-' for docker tags
67+
docker_tag="${{ needs.build-snapshot.outputs.branch }}"
68+
docker_tag=$(echo "$docker_tag" | sed 's/[\/+]/-/g')
69+
echo "docker_tag=${docker_tag}" >> $GITHUB_ENV
70+
71+
- name: Publish to Docker Hub
72+
uses: elgohr/Publish-Docker-Github-Action@v5
73+
with:
74+
name: inseefr/genesis-api
75+
username: ${{ secrets.DOCKERHUB_USERNAME }}
76+
password: ${{ secrets.DOCKERHUB_TOKEN }}
77+
default_branch: ${{ github.ref }}
78+
tags: "snapshot-${{ env.docker_tag }}"
79+
workdir: .

CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Changelog
22

3+
## 1.4.1 [2025-02-24]
4+
5+
### Fixed
6+
- Bug on missing/filter_result variables in loops/tables incorrectly persisted in database
7+
8+
## 1.4.0 [2025-02-18]
9+
10+
### Changed
11+
- Rename all identifiers and refactor values
12+
### Fixed
13+
- Bug on export of data to Kraftwerk
14+
### Updated
15+
- pitest 1.18.2
16+
- springdoc 2.8.5
17+
- cucumber 7.21.1
18+
319
## 1.3.2 [2025-01-31]
420

521
### Added
@@ -213,4 +229,4 @@ First production version
213229
- Fix issue with variables that are collected but not present in DDI specifications
214230

215231
## 1.0.0 - [2024-01-17]
216-
- First release
232+
- First release

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM eclipse-temurin:21.0.6_7-jre-alpine
2+
3+
ENV PATH_TO_JAR=/opt/app/app.jar
4+
WORKDIR /opt/app/
5+
COPY ./target/*.jar $PATH_TO_JAR
6+
7+
ENV JAVA_TOOL_OPTIONS_DEFAULT \
8+
-XX:MaxRAMPercentage=75
9+
10+
# Setup a non-root user context (security)
11+
RUN addgroup -g 1000 tomcatgroup
12+
RUN adduser -D -s / -u 1000 tomcatuser -G tomcatgroup
13+
RUN mkdir /opt/app/temp-files
14+
RUN chown -R 1000:1000 /opt/app
15+
16+
USER 1000
17+
18+
ENTRYPOINT [ "/bin/sh", "-c", \
19+
"export JAVA_TOOL_OPTIONS=\"$JAVA_TOOL_OPTIONS_DEFAULT $JAVA_TOOL_OPTIONS\"; \
20+
exec java -jar $PATH_TO_JAR" ]

pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>fr.insee.genesis</groupId>
66
<artifactId>genesis-api</artifactId>
7-
<version>1.3.2</version>
7+
<version>1.4.1</version>
88
<packaging>jar</packaging>
99
<name>genesis-api</name>
1010

1111
<parent>
1212
<groupId>org.springframework.boot</groupId>
1313
<artifactId>spring-boot-starter-parent</artifactId>
14-
<version>3.4.2</version>
14+
<version>3.4.3</version>
1515
</parent>
1616

1717
<properties>
@@ -30,9 +30,9 @@
3030
<skipSurefireReport>true</skipSurefireReport>
3131
<!-- Pi Test-->
3232
<pitest.version>1.18.2</pitest.version>
33-
<pitest.junit.version>1.2.1</pitest.junit.version>
34-
<jackson.version>2.18.2</jackson.version>
35-
<bpm.version>1.0.5</bpm.version>
33+
<pitest.junit.version>1.2.2</pitest.junit.version>
34+
<jackson.version>2.18.3</jackson.version>
35+
<bpm.version>1.0.6</bpm.version>
3636
</properties>
3737
<dependencies>
3838
<dependency>
@@ -160,7 +160,7 @@
160160
<plugin>
161161
<groupId>org.apache.maven.plugins</groupId>
162162
<artifactId>maven-compiler-plugin</artifactId>
163-
<version>3.13.0</version>
163+
<version>3.14.0</version>
164164
</plugin>
165165
<plugin>
166166
<groupId>org.sonarsource.scanner.maven</groupId>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package fr.insee.genesis.configuration;
2+
3+
import jakarta.servlet.FilterChain;
4+
import jakarta.servlet.ServletException;
5+
import jakarta.servlet.annotation.WebFilter;
6+
import jakarta.servlet.http.HttpServletRequest;
7+
import jakarta.servlet.http.HttpServletResponse;
8+
import lombok.extern.slf4j.Slf4j;
9+
import org.springframework.core.annotation.Order;
10+
import org.springframework.stereotype.Component;
11+
import org.springframework.web.filter.OncePerRequestFilter;
12+
import org.springframework.web.util.ContentCachingRequestWrapper;
13+
import org.springframework.web.util.ContentCachingResponseWrapper;
14+
15+
import java.io.IOException;
16+
import java.nio.charset.StandardCharsets;
17+
18+
19+
@Component
20+
@WebFilter(urlPatterns = "/*")
21+
@Order(-999)
22+
@Slf4j
23+
public class LogRequestFilter extends OncePerRequestFilter {
24+
25+
private static final String REQUEST_MESSAGE_FORMAT =
26+
"CALL {} {} - "
27+
// + "Content-Type : {} \n "
28+
// + "Headers : {} \n "
29+
+ "Params : {} - "
30+
+ "Body : {} \n ";
31+
32+
private static final String RESPONSE_MESSAGE_FORMAT =
33+
"END {} {} - "
34+
+ "Status : {} - "
35+
// + "Content-Type : {} \n "
36+
// + "Headers : {} \n "
37+
+ "Body : {} \n";
38+
39+
@Override
40+
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
41+
throws ServletException, IOException {
42+
43+
//Cache request to avoid calling twice the same inputStream
44+
ContentCachingRequestWrapper req = new ContentCachingRequestWrapper(request);
45+
ContentCachingResponseWrapper resp = new ContentCachingResponseWrapper(response);
46+
47+
log.info(REQUEST_MESSAGE_FORMAT,
48+
req.getMethod(), req.getRequestURI(),
49+
// req.getContentType(),
50+
// new ServletServerHttpRequest(req).getHeaders(), //Headers
51+
request.getQueryString(),//Params
52+
new String(req.getContentAsByteArray(), StandardCharsets.UTF_8));//Body
53+
54+
55+
// Execution request chain
56+
filterChain.doFilter(req, resp);
57+
58+
59+
log.info(RESPONSE_MESSAGE_FORMAT,
60+
req.getMethod(), req.getRequestURI(),
61+
resp.getStatus(),
62+
getResponseBody(req, resp)); //Body
63+
64+
// Finally remember to respond to the client with the cached data.
65+
resp.copyBodyToResponse();
66+
}
67+
68+
private String getResponseBody(ContentCachingRequestWrapper req, ContentCachingResponseWrapper resp) {
69+
if (req.getRequestURI().contains("swagger-ui") ||req.getRequestURI().contains("api-docs")) return "Hidden Swagger response";
70+
return new String(resp.getContentAsByteArray(), StandardCharsets.UTF_8);
71+
}
72+
73+
}

src/main/java/fr/insee/genesis/controller/adapter/LunaticXmlAdapter.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import fr.insee.genesis.controller.sources.xml.LunaticXmlSurveyUnit;
77
import fr.insee.genesis.controller.sources.xml.ValueType;
88
import fr.insee.genesis.domain.model.surveyunit.SurveyUnitModel;
9-
import fr.insee.genesis.domain.utils.LoopIdentifier;
9+
import fr.insee.genesis.domain.utils.GroupUtils;
1010
import fr.insee.genesis.domain.model.surveyunit.DataState;
1111
import fr.insee.genesis.domain.model.surveyunit.Mode;
1212
import fr.insee.genesis.domain.model.surveyunit.VariableModel;
@@ -123,8 +123,8 @@ private static SurveyUnitModel getCollectedDataFromSurveyUnit(LunaticXmlSurveyUn
123123
variableModels.add(VariableModel.builder()
124124
.varId(lunaticXmlCollectedData.getVariableName())
125125
.value(valueTypeList.get(i-1).getValue())
126-
.scope(LoopIdentifier.getLoopIdentifier(lunaticXmlCollectedData.getVariableName(), variablesMap))
127-
.parentId(LoopIdentifier.getRelatedVariableName(lunaticXmlCollectedData.getVariableName(), variablesMap))
126+
.scope(GroupUtils.getGroupName(lunaticXmlCollectedData.getVariableName(), variablesMap))
127+
.parentId(GroupUtils.getParentGroupName(lunaticXmlCollectedData.getVariableName(), variablesMap))
128128
.iteration(i)
129129
.build());
130130
dataCount++;
@@ -160,9 +160,9 @@ private static void getExternalDataFromSurveyUnit(LunaticXmlSurveyUnit su, Surve
160160
variableModels.add(VariableModel.builder()
161161
.varId(lunaticXmlExternalData.getVariableName())
162162
.value(valueTypeList.get(i-1).getValue())
163-
.scope(LoopIdentifier.getLoopIdentifier(lunaticXmlExternalData.getVariableName(), variablesMap))
163+
.scope(GroupUtils.getGroupName(lunaticXmlExternalData.getVariableName(), variablesMap))
164164
.iteration(i)
165-
.parentId(LoopIdentifier.getRelatedVariableName(lunaticXmlExternalData.getVariableName(), variablesMap))
165+
.parentId(GroupUtils.getParentGroupName(lunaticXmlExternalData.getVariableName(), variablesMap))
166166
.build());
167167
}
168168
}

src/main/java/fr/insee/genesis/controller/rest/ScheduleController.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,13 @@ public ResponseEntity<Object> addSchedule(
8484
encryptionVaultPath,
8585
useSignature
8686
);
87-
log.info("New schedule request for survey {} with encryption", surveyName);
8887
scheduleApiPort.addSchedule(surveyName,
8988
serviceToCall == null ? ServiceToCall.MAIN : serviceToCall,
9089
frequency,
9190
scheduleBeginDate,
9291
scheduleEndDate,
9392
trustParameters);
9493
}else{
95-
log.info("New schedule request for survey {}", surveyName);
9694
scheduleApiPort.addSchedule(surveyName,
9795
serviceToCall == null ? ServiceToCall.MAIN : serviceToCall,
9896
frequency,
@@ -116,7 +114,6 @@ public ResponseEntity<Object> deleteSchedule(
116114
@Parameter(description = "Survey name of the schedule(s) to delete") @RequestParam("surveyName") String surveyName
117115
){
118116
try {
119-
log.info("Delete schedule request for survey {}", surveyName);
120117
scheduleApiPort.deleteSchedule(surveyName);
121118
}catch (NotFoundException e){
122119
log.warn("Survey {} not found for deletion !", surveyName);
@@ -135,7 +132,6 @@ public ResponseEntity<Object> setSurveyLastExecution(
135132
@Parameter(description = "Date to save as last execution date", example = "2024-01-01T12:00:00") @RequestParam("newDate") LocalDateTime newDate
136133
) {
137134
try {
138-
log.debug("Got update last execution on {} with data param {}", surveyName, newDate);
139135
scheduleApiPort.updateLastExecutionName(surveyName, newDate);
140136
log.info("{} last execution updated at {} !", surveyName, newDate);
141137
}catch (NotFoundException e){

src/main/java/fr/insee/genesis/controller/rest/UtilsController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public ResponseEntity<Object> saveResponsesFromXmlFile(@RequestParam("inputFolde
4242
@RequestParam("filename") String filename,
4343
@RequestParam("nbResponsesByFile") int nbSU)
4444
throws Exception {
45-
log.info("Split XML file : {} into {} SU by file", filename, nbSU);
4645
XMLSplitter.split(inputFolder, filename, outputFolder, "SurveyUnit", nbSU);
4746
return ResponseEntity.ok("File split");
4847
}

0 commit comments

Comments
 (0)