Fix for #60. Added maxPageSize to the RepositoryRestConfiguration so the user can specify a maximum which can be specified as the limit parameter. If the user specifies a value that exceeds the maximum, the configured maximum will be used rather than the value specified as a query parameter.
This commit is contained in:
@@ -28,7 +28,6 @@ import org.springframework.web.method.support.ModelAndViewContainer;
|
||||
public class PagingAndSortingMethodArgumentResolver implements HandlerMethodArgumentResolver {
|
||||
|
||||
private static final int DEFAULT_PAGE = 1; // We're 1-based, not 0-based
|
||||
|
||||
@Autowired
|
||||
private RepositoryRestConfiguration config;
|
||||
|
||||
@@ -64,7 +63,7 @@ public class PagingAndSortingMethodArgumentResolver implements HandlerMethodArgu
|
||||
String sLimit = request.getParameter(config.getLimitParamName());
|
||||
if(StringUtils.hasText(sLimit)) {
|
||||
try {
|
||||
limit = Integer.parseInt(sLimit);
|
||||
limit = Math.min(Integer.parseInt(sLimit), config.getMaxPageSize());
|
||||
} catch(NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user