Skip to content

Commit

Permalink
Merge pull request #272 from cryptomator/feature/quarkus-3.8
Browse files Browse the repository at this point in the history
Update to Quarkus 3.8 and JDK 21
  • Loading branch information
overheadhunter authored Apr 26, 2024
2 parents ce0e65c + 45be869 commit c01fa9d
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

env:
NODE_VERSION: 20
JAVA_VERSION: 17
JAVA_VERSION: 21

defaults:
run:
Expand Down
2 changes: 1 addition & 1 deletion backend/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ Tell JIB which executable to use (replace `nerctl` with `podman` etc):

3x smaller but takes longer to build. Docker VM requires sufficient memory during the build:
```shell script
mvn clean package -Pnative -Dquarkus.container-image.build=true -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel:22.2-java17 -Dquarkus.container-image.tag=latest
mvn clean package -Pnative -Dquarkus.container-image.build=true -Dquarkus.native.container-build=true -Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel-builder-image:23.1-java21 -Dquarkus.container-image.tag=latest
```
22 changes: 5 additions & 17 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
<version>1.4.0-SNAPSHOT</version>

<properties>
<compiler-plugin.version>3.11.0</compiler-plugin.version>
<compiler-plugin.version>3.12.1</compiler-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.jdk.version>17</project.jdk.version>
<project.jdk.version>21</project.jdk.version>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.container-image.group>cryptomator</quarkus.container-image.group>
<quarkus.container-image.name>hub</quarkus.container-image.name>
<quarkus.platform.version>3.2.12.Final</quarkus.platform.version>
<quarkus.jib.base-jvm-image>eclipse-temurin:17-jre</quarkus.jib.base-jvm-image> <!-- irrelevant for -Pnative -->
<quarkus.platform.version>3.8.2</quarkus.platform.version>
<quarkus.jib.base-jvm-image>eclipse-temurin:21-jre</quarkus.jib.base-jvm-image> <!-- irrelevant for -Pnative -->
<jwt.version>4.4.0</jwt.version>
<surefire-plugin.version>3.1.2</surefire-plugin.version>
<surefire-plugin.version>3.2.3</surefire-plugin.version>
</properties>

<dependencyManagement>
Expand All @@ -28,18 +28,6 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<!-- temporarily pin Flyway version until Quarkus LTS contains Flyway >= 9.21.0; see https://github.com/cryptomator/hub/issues/256 -->
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>9.22.3</version>
</dependency>
<dependency>
<!-- temporarily pin Flyway version until Quarkus LTS contains Flyway >= 9.21.0; see https://github.com/cryptomator/hub/issues/256 -->
<groupId>io.quarkus</groupId>
<artifactId>quarkus-flyway</artifactId>
<version>3.3.0</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
37 changes: 13 additions & 24 deletions backend/src/main/java/org/cryptomator/hub/api/AuditLogResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,30 +96,19 @@ public interface AuditEventDto {
Instant timestamp();

static AuditEventDto fromEntity(AuditEvent entity) {
// TODO: refactor to switch in JDK21
if (entity instanceof AuditEventDeviceRegister evt) {
return new AuditEventDeviceRegisterDto(evt.id, evt.timestamp, AuditEventDeviceRegister.TYPE, evt.registeredBy, evt.deviceId, evt.deviceName, evt.deviceType);
} else if (entity instanceof AuditEventDeviceRemove evt) {
return new AuditEventDeviceRemoveDto(evt.id, evt.timestamp, AuditEventDeviceRemove.TYPE, evt.removedBy, evt.deviceId);
} else if (entity instanceof AuditEventVaultCreate evt) {
return new AuditEventVaultCreateDto(evt.id, evt.timestamp, AuditEventVaultCreate.TYPE, evt.createdBy, evt.vaultId, evt.vaultName, evt.vaultDescription);
} else if (entity instanceof AuditEventVaultUpdate evt) {
return new AuditEventVaultUpdateDto(evt.id, evt.timestamp, AuditEventVaultUpdate.TYPE, evt.updatedBy, evt.vaultId, evt.vaultName, evt.vaultDescription, evt.vaultArchived);
} else if (entity instanceof AuditEventVaultAccessGrant evt) {
return new AuditEventVaultAccessGrantDto(evt.id, evt.timestamp, AuditEventVaultAccessGrant.TYPE, evt.grantedBy, evt.vaultId, evt.authorityId);
} else if (entity instanceof AuditEventVaultKeyRetrieve evt) {
return new AuditEventVaultKeyRetrieveDto(evt.id, evt.timestamp, AuditEventVaultKeyRetrieve.TYPE, evt.retrievedBy, evt.vaultId, evt.result);
} else if (entity instanceof AuditEventVaultMemberAdd evt) {
return new AuditEventVaultMemberAddDto(evt.id, evt.timestamp, AuditEventVaultMemberAdd.TYPE, evt.addedBy, evt.vaultId, evt.authorityId, evt.role);
} else if (entity instanceof AuditEventVaultMemberRemove evt) {
return new AuditEventVaultMemberRemoveDto(evt.id, evt.timestamp, AuditEventVaultMemberRemove.TYPE, evt.removedBy, evt.vaultId, evt.authorityId);
} else if (entity instanceof AuditEventVaultMemberUpdate evt) {
return new AuditEventVaultMemberUpdateDto(evt.id, evt.timestamp, AuditEventVaultMemberUpdate.TYPE, evt.updatedBy, evt.vaultId, evt.authorityId, evt.role);
} else if (entity instanceof AuditEventVaultOwnershipClaim evt) {
return new AuditEventVaultOwnershipClaimDto(evt.id, evt.timestamp, AuditEventVaultOwnershipClaim.TYPE, evt.claimedBy, evt.vaultId);
} else {
throw new UnsupportedOperationException("conversion not implemented for event type " + entity.getClass());
}
return switch (entity) {
case AuditEventDeviceRegister evt -> new AuditEventDeviceRegisterDto(evt.id, evt.timestamp, AuditEventDeviceRegister.TYPE, evt.registeredBy, evt.deviceId, evt.deviceName, evt.deviceType);
case AuditEventDeviceRemove evt -> new AuditEventDeviceRemoveDto(evt.id, evt.timestamp, AuditEventDeviceRemove.TYPE, evt.removedBy, evt.deviceId);
case AuditEventVaultCreate evt -> new AuditEventVaultCreateDto(evt.id, evt.timestamp, AuditEventVaultCreate.TYPE, evt.createdBy, evt.vaultId, evt.vaultName, evt.vaultDescription);
case AuditEventVaultUpdate evt -> new AuditEventVaultUpdateDto(evt.id, evt.timestamp, AuditEventVaultUpdate.TYPE, evt.updatedBy, evt.vaultId, evt.vaultName, evt.vaultDescription, evt.vaultArchived);
case AuditEventVaultAccessGrant evt -> new AuditEventVaultAccessGrantDto(evt.id, evt.timestamp, AuditEventVaultAccessGrant.TYPE, evt.grantedBy, evt.vaultId, evt.authorityId);
case AuditEventVaultKeyRetrieve evt -> new AuditEventVaultKeyRetrieveDto(evt.id, evt.timestamp, AuditEventVaultKeyRetrieve.TYPE, evt.retrievedBy, evt.vaultId, evt.result);
case AuditEventVaultMemberAdd evt -> new AuditEventVaultMemberAddDto(evt.id, evt.timestamp, AuditEventVaultMemberAdd.TYPE, evt.addedBy, evt.vaultId, evt.authorityId, evt.role);
case AuditEventVaultMemberRemove evt -> new AuditEventVaultMemberRemoveDto(evt.id, evt.timestamp, AuditEventVaultMemberRemove.TYPE, evt.removedBy, evt.vaultId, evt.authorityId);
case AuditEventVaultMemberUpdate evt -> new AuditEventVaultMemberUpdateDto(evt.id, evt.timestamp, AuditEventVaultMemberUpdate.TYPE, evt.updatedBy, evt.vaultId, evt.authorityId, evt.role);
case AuditEventVaultOwnershipClaim evt -> new AuditEventVaultOwnershipClaimDto(evt.id, evt.timestamp, AuditEventVaultOwnershipClaim.TYPE, evt.claimedBy, evt.vaultId);
default -> throw new UnsupportedOperationException("conversion not implemented for event type " + entity.getClass());
};
}
}

Expand Down
13 changes: 5 additions & 8 deletions backend/src/main/java/org/cryptomator/hub/api/AuthorityDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,11 @@ protected AuthorityDto(String id, Type type, String name, String pictureUrl) {
}

static AuthorityDto fromEntity(Authority a) {
// TODO refactor to JEP 441 in JDK 21
if (a instanceof User user) {
return UserDto.justPublicInfo(user);
} else if (a instanceof Group group) {
return GroupDto.fromEntity(group);
} else {
throw new IllegalStateException("authority is not of type user or group");
}
return switch (a) {
case User u -> UserDto.justPublicInfo(u);
case Group g -> GroupDto.fromEntity(g);
default -> throw new IllegalStateException("authority is not of type user or group");
};
}

}
14 changes: 4 additions & 10 deletions backend/src/main/java/org/cryptomator/hub/api/VaultResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public class VaultResource {
@Operation(summary = "list all accessible vaults", description = "list all vaults that have been shared with the currently logged in user or a group in wich this user is")
public List<VaultDto> getAccessible(@Nullable @QueryParam("role") VaultAccess.Role role) {
var currentUserId = jwt.getSubject();
// TODO refactor to JEP 441 in JDK 21
final Stream<Vault> resultStream;
if (role == null) {
resultStream = Vault.findAccessibleByUser(currentUserId);
Expand Down Expand Up @@ -130,15 +129,10 @@ public List<VaultDto> getAllVaults() {
@APIResponse(responseCode = "200")
@APIResponse(responseCode = "403", description = "not a vault owner")
public List<MemberDto> getDirectMembers(@PathParam("vaultId") UUID vaultId) {
return VaultAccess.forVault(vaultId).map(access -> {
// TODO switch to switch expressions, once we can make Authority sealed
if (access.authority instanceof User u) {
return MemberDto.fromEntity(u, access.role);
} else if (access.authority instanceof Group g) {
return MemberDto.fromEntity(g, access.role);
} else {
throw new IllegalStateException();
}
return VaultAccess.forVault(vaultId).map(access -> switch (access.authority) {
case User u -> MemberDto.fromEntity(u, access.role);
case Group g -> MemberDto.fromEntity(g, access.role);
default -> throw new IllegalStateException();
}).toList();
}

Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ quarkus.datasource.db-kind=postgresql
quarkus.datasource.jdbc.driver=org.postgresql.Driver
quarkus.datasource.jdbc.transaction-requirement=off
quarkus.datasource.jdbc.max-size=16
quarkus.hibernate-orm.dialect=org.hibernate.dialect.PostgreSQL10Dialect
quarkus.hibernate-orm.dialect=org.hibernate.dialect.PostgreSQLDialect
quarkus.hibernate-orm.database.globally-quoted-identifiers=true
quarkus.flyway.migrate-at-start=true
quarkus.flyway.locations=classpath:org/cryptomator/hub/flyway
Expand Down

0 comments on commit c01fa9d

Please sign in to comment.