Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump supported Java version and several libraries #153

Merged
merged 90 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
282232b
Bump spring-boot-starter-parent from 1.4.4 -> 3.2.0 and from Java 8 t…
Dec 14, 2023
7a7db51
Bump Java 8 -> Java 11
Dec 14, 2023
cfd95a1
Bump Java 8 -> Java 11
Dec 14, 2023
39f77e9
Keep Java 8 for klass-forvaltning
Dec 14, 2023
fd4f424
Fix test
Dec 14, 2023
ca40be6
Fix test
Dec 14, 2023
b7891fe
Fix test
Dec 14, 2023
e1aa67b
Fix test
Dec 14, 2023
574589c
Fix test
Dec 14, 2023
6576c81
Fix test
Dec 14, 2023
f73a707
Fix test
Dec 14, 2023
23aff36
Fix tests
Dec 14, 2023
f6311e8
Fix tests
Dec 14, 2023
865b131
Fix incorrect sql syntax
Dec 15, 2023
da20bb7
Upgrade jaxb2-maven-plugin
mmwinther Dec 15, 2023
5028b3a
Removed solr-dataimporthandler as it conflicted with ANTLR version (a…
Dec 15, 2023
a8238bf
Fix boolean comparison operator in JPA queries
mmwinther Dec 15, 2023
2254ce6
Fix comparison operator in JPA queries
mmwinther Dec 15, 2023
2d7e501
Removed solr-dataimporthandler as it conflicted with ANTLR version (a…
Dec 15, 2023
859efce
Fix comparison operator in JPA queries
mmwinther Dec 15, 2023
d7d9a98
Fix issues with H2 and reserved keywords
mmwinther Dec 15, 2023
b320975
Fix JPQL boolean comparison
mmwinther Dec 15, 2023
8b5fcfc
Fixed antlr conflicts
Dec 15, 2023
a9e12c5
Specify Converter for fields of type Translatable
mmwinther Dec 15, 2023
ca7e08d
Implement no-args constructor for Subscription
mmwinther Dec 15, 2023
b938d89
Implement no-args constructor for ClassificationFamily
mmwinther Dec 15, 2023
1e7abd6
Fixed native sqls for the user table and fixed an improper test.
Dec 18, 2023
3644cf6
Bump rest-assured version
Dec 18, 2023
76de7f7
Tables should be nullable
Dec 18, 2023
219d001
Fix changes in Spring HATEOAS
Dec 18, 2023
687a819
Fix tests due to changes in Spring HATEOAS
Dec 19, 2023
32ee9c0
Slight improvement. The antrl runtime error is gone. But still fails …
Dec 21, 2023
b6e34a9
Fixed ApiDocumentation tests. Downgraded to Spring Boot 2.7.8, Spring…
Jan 2, 2024
539185f
Fix CodeQL Analysis
Jan 2, 2024
2cd0c2b
Share maven cache
Jan 2, 2024
de1f397
Fix build
Jan 2, 2024
b54402c
Make all classes Java 1.8 compatible in order to build klass-forvaltn…
Jan 2, 2024
cf7a3dd
Downgrade maven for vaadin-maven-plugin
Jan 2, 2024
ad982f9
Fix vaadin-maven-plugin
Jan 2, 2024
c5f2d82
Since klass-forvaltning uses Vaadin7 we must remove dependency to kla…
Jan 2, 2024
d58068a
Use spring-data-solr 2.1.0.RELEASE
Jan 2, 2024
606664f
Rewrite classes to be Java8 compatible
Jan 2, 2024
7319089
Fix that almost had the spring boot application up and running
Jan 3, 2024
a62aecd
Use Java8/Spring Boot 1.4.4 compatible versions of klass-shared and k…
Jan 3, 2024
c077c75
Fix runtime dependency
Jan 3, 2024
2656bfa
Fixed bug in UserServiceImpl
Jan 4, 2024
a7562c9
Turn off hibernate ddl validation since it appears buggy
Jan 4, 2024
958fc14
Add http examples
Jan 4, 2024
79e2da7
Use older mariadb connector
Jan 8, 2024
0618760
Add missing flyway-mysql library
Jan 9, 2024
48d6f81
Downgrade mariadb version
Jan 9, 2024
8083194
Bump flyway version
Jan 9, 2024
23cfd91
Core name must be part of the baseURL for some reason
Jan 9, 2024
2098d6a
Fix search links to include the base path
Jan 10, 2024
a7f9023
Fix search links to include the base path
Jan 10, 2024
afe4268
Add test
Jan 10, 2024
7483eff
Fixed invalid hardcoded value
Jan 10, 2024
e8b2f34
Fixed monitor page
Jan 10, 2024
d9f0d44
Merge from master
Jan 11, 2024
358d1c6
Merge from master
Jan 11, 2024
95658c3
Add separate profiles for nexus and github
Jan 12, 2024
2217c8a
Add github packages repo
Jan 12, 2024
c27044e
Add auth to github packages repo
Jan 12, 2024
cb88dc8
Fixed CodeQL
Jan 12, 2024
419c60d
Fixed CodeQL
Jan 12, 2024
2b65e5d
Bump Java17 compatible libs to 3.0.0-SNAPSHOT
Jan 12, 2024
633172a
Fix monitoring and ping paths to be less strict. Also fix links where…
Jan 12, 2024
66c8580
Fix monitoring and ping paths
Jan 12, 2024
15d1b96
Fix monitoring paths
Jan 12, 2024
d8ce91f
Fix monitoring paths
Jan 12, 2024
129be76
Fix paths
Jan 15, 2024
196537c
Fix basepath links
Jan 15, 2024
59d67ec
Fix basepath links
Jan 15, 2024
75c9e6e
Fix ordering of json structure
Jan 15, 2024
bd880ec
Fix ordering of json structure
Jan 15, 2024
66a7ca1
Use application/hal+json by default
Jan 16, 2024
4deb5df
Fix ordering of json structure
Jan 16, 2024
56f18e9
Add more version properties
Jan 16, 2024
7fe3d85
Add more version properties
Jan 16, 2024
6f4ce4f
Re-emabøe suffix pattern matching
Jan 17, 2024
32f8ec7
Re-emabøe suffix pattern matching
Jan 17, 2024
d02ee21
Added more rest examples
Jan 18, 2024
15bdb6c
Fix logging
Jan 18, 2024
fc26e71
Fix logging
Jan 18, 2024
e6dd3a1
Bump apacheds-server-jndi-version and set CORS header for klass-web
Jan 19, 2024
07f1409
Expand self links so that klass-web can use the links directly
Jan 22, 2024
40d8e45
Fixed tests
Jan 22, 2024
483d1b3
Ensure that links inherit https when running behind a LB/reverse proxy
Jan 22, 2024
c321ab7
Enforce https in API docs
Jan 22, 2024
2d3a022
Enforce https in API docs
Jan 22, 2024
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
30 changes: 27 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 1.8
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
java-version: '17'
cache: maven

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand All @@ -68,8 +69,31 @@ jobs:
#- run: |
# make bootstrap
# make release
# Build all modules except klass-forvaltning since it is not compatible with JDK 17
- name: Build with Maven
run: mvn -B clean install --settings=.maven.settings.xml --file pom.xml
run: mvn -B clean install --settings=.maven.settings.xml -pl '!:klass-forvaltning'

- name: Set up JDK 1.8
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
cache: maven

# Need to downgrade Maven in order to allow HTTP (not HTTPS) packages to be downloaded.
# This is necessary as HTTP repositories were blocked in Maven 3.8.1
# HTTP repositories are used in some outdated dependenciesns
# This step can be removed once KLASS packages have been updated to more recent versions
- name: Set up Maven
uses: stCarolas/[email protected]
with:
maven-version: 3.6.3

# Build only klass-forvaltning with JDK 1.8
- name: Build, test and package with Maven
run: mvn --batch-mode --update-snapshots package -Djava.version=1.8 -pl :klass-forvaltning -am -P github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
23 changes: 19 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
cache: maven

# Build all modules except klass-forvaltning since it is not compatible with JDK 17
- name: Build, test and package with Maven
run: mvn --batch-mode --update-snapshots package -pl '!:klass-forvaltning' -P nexus

- uses: actions/checkout@v3
- name: Set up JDK 1.8
uses: actions/setup-java@v3
Expand All @@ -34,8 +46,11 @@ jobs:
with:
maven-version: 3.6.3

# Build only klass-forvaltning with JDK 1.8
- name: Build, test and package with Maven
run: mvn --batch-mode --update-snapshots package -P nexus
run: mvn --batch-mode --update-snapshots package -Djava.version=1.8 -pl :klass-forvaltning -am -P github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

deploy:
runs-on: ubuntu-latest
Expand All @@ -46,14 +61,14 @@ jobs:
packages: write
steps:
- uses: actions/checkout@v3
- name: Set up JDK 1.8
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
java-version: '17'
cache: maven

- name: Publish to GitHub Packages
run: mvn --batch-mode deploy -P github -DskipTests
run: mvn --batch-mode deploy -pl '!:klass-forvaltning' -P github -DskipTests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ build-all:

.PHONY: run-klass-forvaltning-local
run-klass-forvaltning-local:
pushd klass-forvaltning && mvn spring-boot\:run -P nexus && popd
pushd klass-forvaltning && mvn spring-boot\:run --settings=../.maven.settings.xml -P nexus && popd

.PHONY: run-klass-forvaltning-local-mariadb
# Requires that a MariaDB instance is already running with a database called klass and a user called klass.
Expand Down
21 changes: 21 additions & 0 deletions klass-api/doc/requests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# HTTP Client tests

This folder contains files for Jetbrains'
[HTTP Client plugin](https://www.jetbrains.com/help/idea/2023.1/http-client-in-product-code-editor.html). With these
you can create, edit, and execute HTTP requests directly in the IntelliJ IDEA code editor.

To be able to run these requests you should have an environment file called `http-client.env.json`
inside this folder. The file should have
the following structure:

```
{
"local": {
"base_url": "http://localhost:8080/api/klass/v1",
"other": "..."
},
"prod": {
"base_url": "https://data.ssb.no/api/klass/v1",
"other": "..."
}
```
54 changes: 54 additions & 0 deletions klass-api/doc/requests/examples-classifications.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
### Get all classificationfamilies
GET {{base_url}}/classificationfamilies
Accept: application/json

### Get single classificationfamily
GET {{base_url}}/classificationfamilies/15
Accept: application/json

### Get all classifications
GET {{base_url}}/classifications
Accept: application/json

### Get a single classification
GET {{base_url}}/classifications/1
Accept: application/json

### Get classification codes
GET {{base_url}}/classifications/1/codes?from=2020-01-01&to=2021-01-01&includeFuture=true
Accept: application/json

### Get classification codes
GET {{base_url}}/classifications/1/codes?from=2020-01-01&includeFuture=true
Accept: application/json

### Get classification codes
GET {{base_url}}/classifications/1/codesAt?date=2020-06-01
Accept: application/json

### Get classification changes
GET {{base_url}}/classifications/1/changes
Accept: application/json

### Search for classifications
GET {{base_url}}/classifications/search?query=kommune
Accept: application/json

### Search for classifications within a ssb section
GET {{base_url}}/classifications/search?query=kommune&includeCodelists=true&ssbSection=320
Accept: application/json

### Get all classifications with size
GET {{base_url}}/classifications?size=2
Accept: application/json

### Get all classifications with size and page
GET {{base_url}}/classifications?size=2&page=2
Accept: application/json

### Get a single correspondencetable
GET {{base_url}}/correspondencetables/1
Accept: application/json

### Get a single correspondencetable with suffix pattern matching
GET {{base_url}}/correspondencetables/1.csv
8 changes: 8 additions & 0 deletions klass-api/doc/requests/http-client.env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"local": {
"base_url": "http://localhost:8080/api/klass/v1"
},
"prod": {
"base_url": "https://data.ssb.no/api/klass/v1"
}
}
59 changes: 52 additions & 7 deletions klass-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
<parent>
<groupId>no.ssb.klass</groupId>
<artifactId>klass-root</artifactId>
<version>2.1.8-SNAPSHOT</version>
<!-- <relativePath>../</relativePath>-->
<version>3.0.0-SNAPSHOT</version>
</parent>

<properties>
Expand All @@ -30,8 +29,19 @@
<groupId>no.ssb.klass</groupId>
<artifactId>klass-solr</artifactId>
<version>${project.parent.version}</version>
<exclusions>
<exclusion>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>

<!--Spring-->
<dependency>
<groupId>org.springframework.boot</groupId>
Expand All @@ -58,7 +68,12 @@
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-solr</artifactId>
</dependency>

<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb-api-version}</version>
<scope>provided</scope>
</dependency>

<!--TOMCAT-->
<dependency>
Expand All @@ -79,7 +94,6 @@
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>

<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
Expand Down Expand Up @@ -107,6 +121,11 @@
<scope>test</scope>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>${jakarta-rs-api-version}</version>
</dependency>

<!--Spring TEST-->
<dependency>
Expand All @@ -122,17 +141,43 @@
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<version>${spring-restdocs-version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-core</artifactId>
<version>${spring-restdocs-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.restassured</groupId>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
<exclusions>
<!-- remove conflicting dependency because declared in 2 differents versions (3 & 4)
See: https://github.com/rest-assured/rest-assured/issues/1612 -->
<exclusion>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-xml</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<!-- add this dep which bring back the groovy-xml in a single and last version (4) -->
<groupId>io.rest-assured</groupId>
<artifactId>xml-path</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
Expand Down
2 changes: 1 addition & 1 deletion klass-api/src/main/asciidoc/api-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ include::{snippets}/error-example/http-response.adoc[]

=== Output formats
Default output format is XML. JSON is optional, and in many cases CSV. It is possible to get output in the supported output formats without using Curl `-H` (`--header`). Add the dot-prefix `.json`, `.csv` or `.xml` in the URL before the request parameters,
e.g. json: http://data.ssb.no/api/klass/v1/classifications/104/codesAt.json?date=2020-01-01[http://data.ssb.no/api/klass/v1/classifications/104/codesAt.json?date=2020-01-01]. When adding this in the URL you only get the default character sets.
e.g. json: https://data.ssb.no/api/klass/v1/classifications/104/codesAt.json?date=2020-01-01[https://data.ssb.no/api/klass/v1/classifications/104/codesAt.json?date=2020-01-01]. When adding this in the URL you only get the default character sets.

=== Character sets
Charset for the formats XML and JSON are UTF-8. Default charset for CSV is ISO 8859-1. This can be changed in Accept header to UTF-8.
Expand Down
8 changes: 3 additions & 5 deletions klass-api/src/main/java/no/ssb/klass/KlassApiApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.TomcatServletWebServerFactoryCustomizer;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Import;

// CHECKSTYLE:OFF
@SpringBootApplication
@Import(EmbeddedServletContainerAutoConfiguration.EmbeddedTomcat.class)
@Import(TomcatServletWebServerFactoryCustomizer.class)
public class KlassApiApplication extends SpringBootServletInitializer {
// TODO kmgv if using embedded container (e.g. Tomcat) remove below method and extends SpringBootServletInitializer
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@
import no.ssb.klass.api.controllers.MonitorController;
import no.ssb.klass.api.controllers.PingController;
import no.ssb.klass.api.util.RestConstants;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.SecurityFilterChain;

/**
* @author Mads Lundemo, SSB.
*/
@Configuration
@Profile(value = { ConfigurationProfiles.API_ONLY }) // makes config disabled for tests
public class KlassApiConfiguration extends WebSecurityConfigurerAdapter {
public class KlassApiConfiguration {

@Override
protected void configure(HttpSecurity http) throws Exception {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.authorizeRequests()
// block sensitive endpoints (actuator)
.antMatchers("/manage**").denyAll() // alt. hasIpAddress("127.0.0.1")
Expand All @@ -35,7 +36,7 @@ protected void configure(HttpSecurity http) throws Exception {
.csrf().disable()
.headers()
.addHeaderWriter((request, response) -> {
if (request.getServletPath().startsWith(RestConstants.API_VERSION_V1)) {
if (request.getServletPath().startsWith(RestConstants.PREFIX_AND_API_VERSION_V1)) {
// Workaround to Force CORS header all the time for API
response.addHeader("Access-Control-Allow-Origin", "*");
// Header telling cache server what is varying in our responses
Expand All @@ -44,6 +45,6 @@ protected void configure(HttpSecurity http) throws Exception {
}
})
.frameOptions().disable();

return http.build();
}
}
Loading