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:
Jon Brisbin
2013-01-22 10:18:29 -06:00
committed by Jon Brisbin
parent 9f082f00fd
commit ef2b37f3e3
2 changed files with 25 additions and 2 deletions

View File

@@ -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) {
}
}