Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM eclipse-temurin:17.0.16_8-jre

ENV PATH_TO_JAR=/opt/eno-ws/eno-ws.jar
WORKDIR /opt/eno-ws/
ADD ./eno-ws/target/*.jar $PATH_TO_JAR

ENV JAVA_TOOL_OPTIONS_DEFAULT \
-XX:MaxRAMPercentage=75 \
-XX:+UseZGC

ENV JAVA_USER_ID=10001
ENV JAVA_USER=java
RUN groupadd -g "$JAVA_USER_ID" "$JAVA_USER" && \
useradd -r -u "$JAVA_USER_ID" -g "$JAVA_USER" "$JAVA_USER"

USER $JAVA_USER_ID

ENTRYPOINT [ "/bin/sh", "-c", \
"export JAVA_TOOL_OPTIONS=\"$JAVA_TOOL_OPTIONS_DEFAULT $JAVA_TOOL_OPTIONS\"; \
exec java -jar $PATH_TO_JAR" ]
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Eno XML Web-Service

_This project contains the legacy REST API for Eno ("XML" version)._

It is based on two modules:

- [Eno-Core](./eno-core/): logic of transformations based on XSLT
- [Eno-WS](/eno-ws/): the rest api that used eno-core

---

## Summary

[Eno](https://github.com/InseeFr/Eno) is a tool that generates survey questionnaires starting from their formal description in [DDI](https://ddialliance.org/Specification/DDI-Lifecycle/3.3/).

Eno can create questionnaires in different formats from the same DDI description.

Eno generates:

- [Lunatic](https://github.com/InseeFr/Lunatic) questionnaires.
- XForms web questionnaires that can be executed on [Orbeon Forms Runner](http://www.orbeon.com/).
- XSL-FO questionnaires that can be converted to PDF files.

## Docker image

Docker images of the application are published in [Docker Hub](https://hub.docker.com/r/inseefr/eno-ws/tags).

You can pull it, run it on port `8080`, and you're all set!

## Usage example

You can find DDI example files in the test resources of the project.

## Developer requirements

- JDK 17+
- Maven 3
- Tomcat 9

## Swagger UI

The swagger-ui API documentation is mapped on the root url.

Locally, you can get it at `http://localhost:8080`

Note if you have trouble starting the application on IntelliJ with the error:

```
Field buildProperties in fr.insee.eno.ws.config.OpenApiConfiguration required a bean of type
'org.springframework.boot.info.BuildProperties' that could not be found.
```

you can configure the spring-boot:build-info plugin to "Execute After Rebuild"
(https://stackoverflow.com/a/77218232/13425151).
10 changes: 4 additions & 6 deletions eno-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<!-- Source encoding -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.sourceEncoding>${project.encoding}</project.build.sourceEncoding>

<!-- Main dependencies -->
<saxon.version>12.9</saxon.version>
Expand All @@ -115,7 +115,6 @@
<!-- Logging API -->
<slf4j.version>2.0.17</slf4j.version>
<!-- Test dependencies -->
<junit.version>5.13.4</junit.version>
<xmlunit.version>2.10.4</xmlunit.version>
<apache-commons.version>3.18.0</apache-commons.version>
<log4j-slf4j2.version>2.25.1</log4j-slf4j2.version>
Expand Down Expand Up @@ -198,7 +197,6 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -239,7 +237,7 @@
</goals>
<configuration>
<packageName>fr.insee.eno.parameters</packageName>
<encoding>UTF-8</encoding>
<encoding>${project.encoding}</encoding>
<xjbSources>
<xjbSource>src/main/resources/params/schemas/jaxb/bindings.xjb</xjbSource>
</xjbSources>
Expand All @@ -256,7 +254,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
<configuration>
<encoding>UTF-8</encoding>
<encoding>${project.encoding}</encoding>
<argLine>-Dfile.encoding=UTF-8
-Djavax.xml.bind.JAXBContextFactory=org.eclipse.persistence.jaxb.JAXBContextFactory</argLine>
</configuration>
Expand All @@ -265,7 +263,7 @@
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<encoding>UTF-8</encoding>
<encoding>${project.encoding}</encoding>
</configuration>
<executions>
<execution>
Expand Down
190 changes: 181 additions & 9 deletions eno-ws/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,185 @@
</parent>
<artifactId>eno-ws</artifactId>
<name>Eno - Web-Service</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<properties>
<!-- Project -->
<final.jar.name>eno-ws</final.jar.name>
<project.build.sourceEncoding>${project.encoding}</project.build.sourceEncoding>
<project.reporting.outputEncoding>${project.encoding}</project.reporting.outputEncoding>

<!-- Java -->
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>

<lunatic-model.version>2.7.3</lunatic-model.version>
<javax.activation.version>1.2.0</javax.activation.version>
<jaxb-api.version>2.3.1</jaxb-api.version>
<jaxb-impl.version>2.3.9</jaxb-impl.version>
<jaxb-core.version>4.0.5</jaxb-core.version>
<springdoc-openapi-ui.version>2.8.13</springdoc-openapi-ui.version>

<!-- Sonar -->
<jacoco.version>0.8.13</jacoco.version>
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.projectName>Eno-WS</sonar.projectName>
<sonar.language>java</sonar.language>
<argLine>-Xms256m -Xmx512m -XX:MaxMetaspaceSize=128m -ea -Dfile.encoding=UTF-8</argLine>
</properties>
<repositories>
<!-- Maven central snapshot repository (especially for Lunatic-Model snapshots) -->
<repository>
<id>oss.sonatype.org-snapshot</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<dependencies>
<!-- Spring main dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>${springdoc-openapi-ui.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<!-- Eno -->
<dependency>
<groupId>fr.insee.eno</groupId>
<artifactId>eno-core</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Lunatic-Model -->
<dependency>
<groupId>fr.insee.lunatic</groupId>
<artifactId>lunatic-model</artifactId>
<version>${lunatic-model.version}</version>
</dependency>

<!-- XML -->
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>${javax.activation.version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb-api.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${jaxb-impl.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>${jaxb-core.version}</version>
</dependency>

<!-- Testing -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test-autoconfigure</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<finalName>${final.jar.name}</finalName>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
<configuration>
<formats>
<format>XML</format>
</formats>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>4.0.0.4121</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>build-info</goal>
</goals>
<configuration>
<additionalProperties>
<description>${project.description}</description>
</additionalProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
13 changes: 0 additions & 13 deletions eno-ws/src/main/java/fr/insee/eno/App.java

This file was deleted.

19 changes: 19 additions & 0 deletions eno-ws/src/main/java/fr/insee/eno/ws/EnoWS.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package fr.insee.eno.ws;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication(scanBasePackages = "fr.insee.eno.ws")
@ConfigurationPropertiesScan
public class EnoWS extends SpringBootServletInitializer{

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(EnoWS.class);
}

public static void main(String[] args) { SpringApplication.run(EnoWS.class, args); }
}
29 changes: 29 additions & 0 deletions eno-ws/src/main/java/fr/insee/eno/ws/config/CorsConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package fr.insee.eno.ws.config;

import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;

import java.util.List;

@Configuration
@AllArgsConstructor
public class CorsConfig {

@Bean
protected CorsConfigurationSource corsWebFilter () {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOriginPatterns(List.of("*"));
configuration.setAllowedMethods(List.of("GET", "PUT", "POST", "DELETE", "OPTIONS"));
configuration.setAllowedHeaders(List.of("Authorization", "Content-Type"));
configuration.addExposedHeader("Content-Disposition");
configuration.setMaxAge(3600L);
configuration.setAllowCredentials(true);
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}
}
Loading