spring-data-rest icon indicating copy to clipboard operation
spring-data-rest copied to clipboard

disableDefaultExposure breaks ListPagingAndSortingRepository

Open xanscale opened this issue 1 year ago • 2 comments

if you are using disableDefaultExposure just if you add ListPagingAndSortingRepository as interface of your repository (together with ListCrudRepository or not) it breaks all rest visibility of annotated methods

@RepositoryRestResource
public interface CourseRepository extends ListCrudRepository<Course, Long> {
    @NotNull @Override @RestResource List<Course> findAll();
}

o.s.web.servlet.DispatcherServlet        : GET "/courses", parameters={}
m.m.a.RequestResponseBodyMethodProcessor : Using 'application/prs.hal-forms+json', given [application/prs.hal-forms+json, application/hal+json, application/json, */*] and supported [application/hal+json, application/json, application/prs.hal-forms+json]
m.m.a.RequestResponseBodyMethodProcessor : HalFormsRejectingResponseBodyAdvice - Changing content type to 'application/hal+json' as no affordances were registered on the representation model to be rendered
m.m.a.RequestResponseBodyMethodProcessor : Writing [CollectionModel { content: [EntityModel { content: ...Course@3 (truncated)...]
o.s.web.servlet.DispatcherServlet        : Completed 200 OK

@RepositoryRestResource
public interface CourseRepository extends ListCrudRepository<Course, Long>, ListPagingAndSortingRepository<Course, Long> {
    @NotNull @Override @RestResource List<Course> findAll();
}

o.s.web.servlet.DispatcherServlet        : GET "/courses", parameters={}
.m.m.a.ExceptionHandlerExceptionResolver : Using @ExceptionHandler org.springframework.data.rest.webmvc.RepositoryRestExceptionHandler#handle(HttpRequestMethodNotSupportedException)
o.s.w.s.m.m.a.HttpEntityMethodProcessor  : Using 'application/prs.hal-forms+json', given [application/prs.hal-forms+json, application/hal+json, application/json, */*] and supported [application/json, application/*+json]
o.s.w.s.m.m.a.HttpEntityMethodProcessor  : Nothing to write: null body
.m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' is not supported]
o.s.web.servlet.DispatcherServlet        : Completed 405 METHOD_NOT_ALLOWED

if i remove disableDefaultExposure all works, but i need to manage permission on all methods

xanscale avatar Jan 23 '25 17:01 xanscale

@odrotbohm any news? i need to use ListPagingAndSortingRepository without exposing everything by default

xanscale avatar Feb 12 '25 14:02 xanscale

@mp911de for me seams a huge bug: seams we cant use paging without exposing all repository methods.

xanscale avatar Mar 04 '25 11:03 xanscale