Skip to content

Commit

Permalink
AuditLog id and timestamp prop was missing when using native image
Browse files Browse the repository at this point in the history
If we return List<AuditEventDto> directly, everything looks fine with Quarkus versions 3.0.1 and 3.1.0.

[build image]
  • Loading branch information
SailReal committed Jul 10, 2023
1 parent 11ab6f7 commit d31e0ee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
2 changes: 1 addition & 1 deletion backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<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.0.1.Final</quarkus.platform.version>
<quarkus.platform.version>3.1.0.Final</quarkus.platform.version>
<quarkus.native.builder-image>quay.io/quarkus/ubi-quarkus-mandrel:22.3-java17</quarkus.native.builder-image>
<quarkus.jib.base-jvm-image>eclipse-temurin:17-jre</quarkus.jib.base-jvm-image> <!-- irrelevant for -Pnative -->
<jwt.version>4.4.0</jwt.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;

import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

Expand All @@ -40,7 +39,7 @@ public class AuditLogResource {
@APIResponse(responseCode = "200", description = "Body contains list of events in the specified time interval")
@APIResponse(responseCode = "400", description = "startDate or endDate not specified, startDate > endDate, order specified and not in ['asc','desc'] or pageSize not in [1 .. 100]")
@APIResponse(responseCode = "403", description = "requesting user is does not have admin role")
public EventList getAllEvents(@QueryParam("startDate") Instant startDate, @QueryParam("endDate") Instant endDate, @QueryParam("paginationId") Long paginationId, @QueryParam("order") @DefaultValue("desc") String order, @QueryParam("pageSize") @DefaultValue("20") int pageSize) {
public List<AuditEventDto> getAllEvents(@QueryParam("startDate") Instant startDate, @QueryParam("endDate") Instant endDate, @QueryParam("paginationId") Long paginationId, @QueryParam("order") @DefaultValue("desc") String order, @QueryParam("pageSize") @DefaultValue("20") int pageSize) {
if (startDate == null || endDate == null) {
throw new BadRequestException("startDate and endDate must be specified");
} else if (startDate.isAfter(endDate)) {
Expand All @@ -53,15 +52,7 @@ public EventList getAllEvents(@QueryParam("startDate") Instant startDate, @Query
throw new BadRequestException("paginationId must be specified");
}

var events = AuditEvent.findAllInPeriod(startDate, endDate, paginationId, order.equals("asc"), pageSize).map(AuditEventDto::fromEntity).toList();
return new EventList(events);
}

// Helper class to prevent type erasure for @JsonTypeInfo, see https://github.com/FasterXML/jackson-databind/issues/336
public static class EventList extends ArrayList<AuditEventDto> {
EventList(List<AuditEventDto> events) {
super(events);
}
return AuditEvent.findAllInPeriod(startDate, endDate, paginationId, order.equals("asc"), pageSize).map(AuditEventDto::fromEntity).toList();
}

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
Expand Down

0 comments on commit d31e0ee

Please sign in to comment.