Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

Commit 13b5e76

Browse files
Merge pull request #52 from Breeding-Insight/java-21-uuid
[BI-2497][BI-2498] Migrate to java 21 and UUID
2 parents 399da44 + 4f9023b commit 13b5e76

File tree

569 files changed

+10278
-9973
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

569 files changed

+10278
-9973
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# run container (dev): `docker run --name=brapi-test-server --network=bridge -p 8081:8081 -d brapicoordinatorselby/brapi-java-server`
33
# run container (prod): `docker run --name=brapi-test-server --restart always --network=brapi_net -d brapicoordinatorselby/brapi-java-server`
44

5-
FROM adoptopenjdk/openjdk8
5+
FROM amazoncorretto:21
66

77
EXPOSE 8080
88

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,36 @@ This server implements all BrAPI calls. It is backed by a custom database with d
88

99
Use [/calls](https://test-server.brapi.org/brapi/v1/call) (V1) or [/serverinfo](https://test-server.brapi.org/brapi/v2/serverinfo) (V2) to check the available endpoints.
1010

11+
<<<<<<< HEAD
12+
=======
13+
## Prerequisites
14+
* Maven 3.9
15+
* Java 21
16+
* Postgres 17.2
17+
18+
## Auth Configuration
19+
BrAPI has provided a [sample central authentication service for the test server](https://brapi.org/oauth).
20+
21+
Here you can create a user and login to be presented with a token which can be used to make requests to your sample server implementation.
22+
23+
Why offer auth? Apart from security concerns, you can utilize authentication with the BrAPI spec to deliver extra functionality
24+
tailored to what data you want your users to see.
25+
26+
To utilize the sample central auth service, set the following properties in your `application.properties` file:
27+
```
28+
security.oidc_discovery_url=https://test-server.brapi.org/.well-known/openid-configuration
29+
security.issuer_urlhttps://auth.brapi.org/realms/brapi
30+
```
31+
32+
If you are not using the sample BrAPI auth system, you must configure these variables properly with the endpoints they expect for your service.
33+
34+
The [local authorization docker set up](#self-contained-authorization-implementation) has some details about how to find these values.
35+
36+
For instructions on how to send the authentication token in your request, see [this section](#authenticating-a-request).
37+
38+
For more information detailing the authentication of the BrAPI Test Server, more documentation with examples and diagrams
39+
can be found [here](https://plant-breeding-api.readthedocs.io/en/latest/docs/best_practices/Authentication.html)
40+
>>>>>>> e742f19 (Merge pull request #76 from plantbreeding/java-21-upgrade)
1141
## Run
1242

1343
### Java IDE

docker-compose-dev.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
services:
2+
brapi-java-server-v2:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
ports:
7+
- "8080:8080"
8+
- "5005:5005"
9+
depends_on:
10+
- brapi-db
11+
volumes:
12+
- .\src\main\resources\properties\application.properties:/home/brapi/properties/application.properties
13+
brapi-db:
14+
image: postgres:17.2
15+
environment:
16+
POSTGRES_USER: brapi
17+
POSTGRES_PASSWORD: password
18+
volumes:
19+
- /var/lib/postgresql/data
20+
ports:
21+
- "5433:5432"

docker-compose-local-auth.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
services:
2+
brapi-java-server-v2:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
ports:
7+
- "8080:8080"
8+
- "5005:5005"
9+
depends_on:
10+
- brapi-db
11+
volumes:
12+
- .\src\main\resources\properties\application.properties:/home/brapi/properties/application.properties
13+
keycloak-brapi:
14+
image: quay.io/keycloak/keycloak:latest
15+
entrypoint: /opt/keycloak/bin/kc.sh start-dev
16+
depends_on:
17+
- keycloak-db
18+
environment:
19+
- KEYCLOAK_USER=admin
20+
- KEYCLOAK_PASSWORD=admin
21+
# The KC_HOSTNAME needs to be the same as the defined keycloak-brapi service in the compose file for a local setup.
22+
# This allows the brapi app to talk to the keycloak container via the service name in the url, and sets up keycloak
23+
# url defaults so that when brapi gets auth urls from keycloak it can still talk to it.
24+
- KC_HOSTNAME=keycloak-brapi
25+
- KC_DB=postgres
26+
- KC_DB_URL=jdbc:postgresql://keycloak-db:5432/keycloak
27+
- KC_DB_SCHEMA=public
28+
- KC_DB_USERNAME=keycloak
29+
- KC_DB_PASSWORD=password
30+
- KC_HOSTNAME_STRICT=false
31+
- KC_HOSTNAME_STRICT_HTTPS=false
32+
- KC_HTTP_PORT=8008
33+
34+
- KC_LOG_LEVEL=info
35+
- KC_METRICS_ENABLED=true
36+
- KC_HEALTH_ENABLED=true
37+
- KEYCLOAK_ADMIN=admin
38+
- KEYCLOAK_ADMIN_PASSWORD=admin
39+
ports:
40+
- "8008:8008"
41+
brapi-db:
42+
image: postgres:17.2
43+
environment:
44+
POSTGRES_USER: brapi
45+
POSTGRES_PASSWORD: password
46+
volumes:
47+
- brapi-data:/var/lib/postgresql/data
48+
ports:
49+
- "5433:5432"
50+
keycloak-db:
51+
image: postgres:17.2
52+
volumes:
53+
- keycloak-data:/var/lib/postgresql/data
54+
environment:
55+
POSTGRES_USER: keycloak
56+
POSTGRES_PASSWORD: password
57+
ports:
58+
- "5434:5432"
59+
volumes:
60+
keycloak-data:
61+
brapi-data:

docker-compose.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ services:
3030
- KC_DB_USERNAME
3131
- KC_DB_PASSWORD
3232
postgres:
33-
image: postgres:13
34-
restart: unless-stopped
33+
image: postgres:17.2
3534
volumes:
36-
- /home/jenkins/brapi.org/brapi-test-server/data:/var/lib/postgresql/data
35+
# Update this path with the path your pipeline tool expects
36+
- /home/jenkins/brapi.org/brapi-test-server/17-2:/var/lib/postgresql/data
3737
networks:
3838
default:
3939
external:

pom.xml

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,24 @@
1414

1515
<properties>
1616
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17-
<java.version>1.8</java.version>
18-
<spring.version>2.5.12</spring.version>
19-
<maven.compiler.source>1.8</maven.compiler.source>
20-
<maven.compiler.target>1.8</maven.compiler.target>
21-
<springfox-version>2.8.0</springfox-version>
17+
<java.version>21</java.version>
18+
<spring.version>3.4.0</spring.version>
19+
<maven.compiler.source>21</maven.compiler.source>
20+
<maven.compiler.target>21</maven.compiler.target>
21+
<springfox-version>2.10.0</springfox-version>
22+
<slf4j-version>2.0.16</slf4j-version>
2223
</properties>
2324

2425
<dependencies>
2526
<dependency>
26-
<groupId>org.flywaydb</groupId>
27-
<artifactId>flyway-core</artifactId>
28-
<version>7.7.3</version>
27+
<groupId>org.flywaydb</groupId>
28+
<artifactId>flyway-core</artifactId>
29+
<version>11.0.1</version>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.flywaydb</groupId>
33+
<artifactId>flyway-database-postgresql</artifactId>
34+
<version>11.0.1</version>
2935
</dependency>
3036
<dependency>
3137
<groupId>org.postgresql</groupId>
@@ -58,6 +64,11 @@
5864
<artifactId>spring-boot-starter-security</artifactId>
5965
<version>${spring.version}</version>
6066
</dependency>
67+
<dependency>
68+
<groupId>org.springframework.boot</groupId>
69+
<artifactId>spring-boot-starter-validation</artifactId>
70+
<version>${spring.version}</version>
71+
</dependency>
6172
<dependency>
6273
<groupId>io.jsonwebtoken</groupId>
6374
<artifactId>jjwt</artifactId>
@@ -100,6 +111,11 @@
100111
<artifactId>jackson-datatype-threetenbp</artifactId>
101112
<version>2.8.4</version>
102113
</dependency>
114+
<dependency>
115+
<groupId>jakarta.annotation</groupId>
116+
<artifactId>jakarta.annotation-api</artifactId>
117+
<version>3.0.0</version>
118+
</dependency>
103119
<dependency>
104120
<groupId>org.apache.commons</groupId>
105121
<artifactId>commons-lang3</artifactId>
@@ -115,13 +131,24 @@
115131
<artifactId>java-jwt</artifactId>
116132
<version>3.14.0</version>
117133
</dependency>
134+
<dependency>
135+
<groupId>org.slf4j</groupId>
136+
<artifactId>slf4j-api</artifactId>
137+
<version>${slf4j-version}</version>
138+
</dependency>
139+
<dependency>
140+
<groupId>org.slf4j</groupId>
141+
<artifactId>slf4j-simple</artifactId>
142+
<version>${slf4j-version}</version>
143+
</dependency>
118144
</dependencies>
119145

120146
<build>
121147
<plugins>
122148
<plugin>
123149
<groupId>org.apache.maven.plugins</groupId>
124150
<artifactId>maven-jar-plugin</artifactId>
151+
<version>3.4.1</version>
125152
<configuration>
126153
<archive>
127154
<manifest>

src/main/java/io/swagger/api/core/BatchDeletesApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
import java.util.ArrayList;
2525

26-
@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-03-20T16:31:52.030Z[GMT]")
26+
@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-03-20T16:31:52.030Z[GMT]")
2727
@Api(value = "batchDeletes", description = "the batch deletes API")
2828
public interface BatchDeletesApi {
2929

src/main/java/io/swagger/api/core/CommonCropNamesApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import org.springframework.web.bind.annotation.RequestParam;
1818

1919

20-
@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-03-20T16:31:52.030Z[GMT]")
20+
@javax.annotation.processing.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-03-20T16:31:52.030Z[GMT]")
2121
@Api(value = "commoncropnames", description = "the commoncropnames API")
2222
public interface CommonCropNamesApi {
2323

src/main/java/io/swagger/api/core/ListsApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import java.util.ArrayList;
2929
import java.util.List;
3030

31-
@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-03-20T16:31:52.030Z[GMT]")
31+
@javax.annotation.processing.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-03-20T16:31:52.030Z[GMT]")
3232
@Api(value = "lists", description = "the lists API")
3333
public interface ListsApi {
3434

src/main/java/io/swagger/api/core/LocationsApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import jakarta.validation.Valid;
2626
import java.util.List;
2727

28-
@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-03-20T16:31:52.030Z[GMT]")
28+
@javax.annotation.processing.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2020-03-20T16:31:52.030Z[GMT]")
2929
@Api(value = "locations", description = "the locations API")
3030
public interface LocationsApi {
3131

0 commit comments

Comments
 (0)