From fa39b9ab49f1c9bf7ed5feb3b3ed1d025572eda8 Mon Sep 17 00:00:00 2001 From: Jose Date: Tue, 24 Jan 2023 12:40:02 +0100 Subject: [PATCH] Add default implementation for REST Data interfaces The linked issue is caused by Arc because the method interfaces are automatically proxied when there are security annotations. And the problem is that this method are not implemented. However, we can't implement these methods since the generated resources take care also of the response codes. Fix https://github.com/quarkusio/quarkus/issues/30515 --- .../panache/ReactiveRestDataResource.java | 24 ++++++++++++++----- .../rest/data/panache/RestDataResource.java | 24 ++++++++++++++----- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/ReactiveRestDataResource.java b/extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/ReactiveRestDataResource.java index dc6ef6f5d2e92..7ce9d26ea47f2 100644 --- a/extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/ReactiveRestDataResource.java +++ b/extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/ReactiveRestDataResource.java @@ -26,12 +26,16 @@ public interface ReactiveRestDataResource { * @param sort Panache sort instance that should be used in a query. * @return A response with an entities JSON array. */ - Uni> list(Page page, Sort sort); + default Uni> list(Page page, Sort sort) { + throw new RuntimeException("Not implemented yet"); + } /** * @return the total number of entities. */ - Uni count(); + default Uni count() { + throw new RuntimeException("Not implemented yet"); + } /** * Return an entity as a JSON object. @@ -40,7 +44,9 @@ public interface ReactiveRestDataResource { * @param id Entity identifier. * @return A response with a JSON object representing an entity. */ - Uni get(ID id); + default Uni get(ID id) { + throw new RuntimeException("Not implemented yet"); + } /** * Create a new entity from the provided JSON object. @@ -50,7 +56,9 @@ public interface ReactiveRestDataResource { * @param entity Entity to be created * @return A response with a JSON object representing an entity and a location header of the new entity. */ - Uni add(Entity entity); + default Uni add(Entity entity) { + throw new RuntimeException("Not implemented yet"); + } /** * Update an existing entity or create a new one from the provided JSON object. @@ -62,7 +70,9 @@ public interface ReactiveRestDataResource { * @return A response with no-content status in case of the update. * A response with a JSON object representing an entity and a location header in case of the create. */ - Uni update(ID id, Entity entity); + default Uni update(ID id, Entity entity) { + throw new RuntimeException("Not implemented yet"); + } /** * Delete an entity. @@ -70,5 +80,7 @@ public interface ReactiveRestDataResource { * @param id Entity identifier. * @return A boolean indicated whether the entity was deleted or not. */ - Uni delete(ID id); + default Uni delete(ID id) { + throw new RuntimeException("Not implemented yet"); + } } diff --git a/extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/RestDataResource.java b/extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/RestDataResource.java index 2d86466166fd5..fe664c7470070 100644 --- a/extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/RestDataResource.java +++ b/extensions/panache/rest-data-panache/runtime/src/main/java/io/quarkus/rest/data/panache/RestDataResource.java @@ -25,12 +25,16 @@ public interface RestDataResource { * @param sort Panache sort instance that should be used in a query. * @return A response with an entities JSON array. */ - List list(Page page, Sort sort); + default List list(Page page, Sort sort) { + throw new RuntimeException("Not implemented yet"); + } /** * @return the total number of entities. */ - long count(); + default long count() { + throw new RuntimeException("Not implemented yet"); + } /** * Return an entity as a JSON object. @@ -39,7 +43,9 @@ public interface RestDataResource { * @param id Entity identifier. * @return A response with a JSON object representing an entity. */ - Entity get(ID id); + default Entity get(ID id) { + throw new RuntimeException("Not implemented yet"); + } /** * Create a new entity from the provided JSON object. @@ -49,7 +55,9 @@ public interface RestDataResource { * @param entity Entity to be created * @return A response with a JSON object representing an entity and a location header of the new entity. */ - Entity add(Entity entity); + default Entity add(Entity entity) { + throw new RuntimeException("Not implemented yet"); + } /** * Update an existing entity or create a new one from the provided JSON object. @@ -61,7 +69,9 @@ public interface RestDataResource { * @return A response with no-content status in case of the update. * A response with a JSON object representing an entity and a location header in case of the create. */ - Entity update(ID id, Entity entity); + default Entity update(ID id, Entity entity) { + throw new RuntimeException("Not implemented yet"); + } /** * Delete an entity. @@ -69,5 +79,7 @@ public interface RestDataResource { * @param id Entity identifier. * @return A boolean indicated whether the entity was deleted or not. */ - boolean delete(ID id); + default boolean delete(ID id) { + throw new RuntimeException("Not implemented yet"); + } }