Skip to content

Commit

Permalink
Add default implementation for REST Data interfaces
Browse files Browse the repository at this point in the history
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 quarkusio#30515
  • Loading branch information
Sgitario committed Jan 24, 2023
1 parent 4cef3b7 commit fa39b9a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ public interface ReactiveRestDataResource<Entity, ID> {
* @param sort Panache sort instance that should be used in a query.
* @return A response with an entities JSON array.
*/
Uni<List<Entity>> list(Page page, Sort sort);
default Uni<List<Entity>> list(Page page, Sort sort) {
throw new RuntimeException("Not implemented yet");
}

/**
* @return the total number of entities.
*/
Uni<Long> count();
default Uni<Long> count() {
throw new RuntimeException("Not implemented yet");
}

/**
* Return an entity as a JSON object.
Expand All @@ -40,7 +44,9 @@ public interface ReactiveRestDataResource<Entity, ID> {
* @param id Entity identifier.
* @return A response with a JSON object representing an entity.
*/
Uni<Entity> get(ID id);
default Uni<Entity> get(ID id) {
throw new RuntimeException("Not implemented yet");
}

/**
* Create a new entity from the provided JSON object.
Expand All @@ -50,7 +56,9 @@ public interface ReactiveRestDataResource<Entity, ID> {
* @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<Entity> add(Entity entity);
default Uni<Entity> add(Entity entity) {
throw new RuntimeException("Not implemented yet");
}

/**
* Update an existing entity or create a new one from the provided JSON object.
Expand All @@ -62,13 +70,17 @@ public interface ReactiveRestDataResource<Entity, ID> {
* @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<Entity> update(ID id, Entity entity);
default Uni<Entity> update(ID id, Entity entity) {
throw new RuntimeException("Not implemented yet");
}

/**
* Delete an entity.
*
* @param id Entity identifier.
* @return A boolean indicated whether the entity was deleted or not.
*/
Uni<Boolean> delete(ID id);
default Uni<Boolean> delete(ID id) {
throw new RuntimeException("Not implemented yet");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ public interface RestDataResource<Entity, ID> {
* @param sort Panache sort instance that should be used in a query.
* @return A response with an entities JSON array.
*/
List<Entity> list(Page page, Sort sort);
default List<Entity> 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.
Expand All @@ -39,7 +43,9 @@ public interface RestDataResource<Entity, ID> {
* @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.
Expand All @@ -49,7 +55,9 @@ public interface RestDataResource<Entity, ID> {
* @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.
Expand All @@ -61,13 +69,17 @@ public interface RestDataResource<Entity, ID> {
* @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.
*
* @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");
}
}

0 comments on commit fa39b9a

Please sign in to comment.