mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 00:15:44 +01:00
Review - Adds reason for RuntimeException & extends REST docs
This commit is contained in:
@@ -577,6 +577,9 @@ public abstract class AbstractManagerResource<T extends ModelObject,
|
||||
return items;
|
||||
}
|
||||
|
||||
// We have to handle IntrospectionException here, because it's a checked exception
|
||||
// It shouldn't occur really - so creating a new unchecked exception would be over-engineered here
|
||||
@SuppressWarnings("squid:S00112")
|
||||
private void checkSortByField(String sortBy) {
|
||||
try {
|
||||
BeanInfo info = Introspector.getBeanInfo(type);
|
||||
@@ -589,17 +592,17 @@ public abstract class AbstractManagerResource<T extends ModelObject,
|
||||
}
|
||||
}
|
||||
|
||||
protected PageResult<T> fetchPage(String sortby, boolean desc, int pageNumber,
|
||||
protected PageResult<T> fetchPage(String sortBy, boolean desc, int pageNumber,
|
||||
int pageSize) {
|
||||
AssertUtil.assertPositive(pageNumber);
|
||||
AssertUtil.assertPositive(pageSize);
|
||||
|
||||
if (Util.isEmpty(sortby)) {
|
||||
if (Util.isEmpty(sortBy)) {
|
||||
// replace with something useful
|
||||
sortby = "id";
|
||||
sortBy = "id";
|
||||
}
|
||||
|
||||
return manager.getPage(createComparator(sortby, desc), pageNumber, pageSize);
|
||||
return manager.getPage(createComparator(sortBy, desc), pageNumber, pageSize);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
@@ -41,11 +41,12 @@ public class GroupCollectionResource {
|
||||
|
||||
/**
|
||||
* Returns all groups for a given page number with a given page size (default page size is {@value DEFAULT_PAGE_SIZE}).
|
||||
*
|
||||
*
|
||||
* <strong>Note:</strong> This method requires "group" privilege.
|
||||
* @param page the number of the requested page
|
||||
*
|
||||
* @param page the number of the requested page
|
||||
* @param pageSize the page size (default page size is {@value DEFAULT_PAGE_SIZE})
|
||||
* @param sortBy sort parameter
|
||||
* @param sortBy sort parameter (if empty - undefined sorting)
|
||||
* @param desc sort direction desc or aesc
|
||||
*/
|
||||
@GET
|
||||
@@ -54,6 +55,7 @@ public class GroupCollectionResource {
|
||||
@TypeHint(GroupDto[].class)
|
||||
@StatusCodes({
|
||||
@ResponseCode(code = 200, condition = "success"),
|
||||
@ResponseCode(code = 400, condition = "\"sortBy\" field unknown"),
|
||||
@ResponseCode(code = 401, condition = "not authenticated / invalid credentials"),
|
||||
@ResponseCode(code = 403, condition = "not authorized, the current user does not have the \"group\" privilege"),
|
||||
@ResponseCode(code = 500, condition = "internal server error")
|
||||
|
||||
@@ -43,9 +43,10 @@ public class UserCollectionResource {
|
||||
* Returns all users for a given page number with a given page size (default page size is {@value DEFAULT_PAGE_SIZE}).
|
||||
*
|
||||
* <strong>Note:</strong> This method requires "user" privilege.
|
||||
* @param page the number of the requested page
|
||||
*
|
||||
* @param page the number of the requested page
|
||||
* @param pageSize the page size (default page size is {@value DEFAULT_PAGE_SIZE})
|
||||
* @param sortBy sort parameter
|
||||
* @param sortBy sort parameter (if empty - undefined sorting)
|
||||
* @param desc sort direction desc or asc
|
||||
*/
|
||||
@GET
|
||||
@@ -54,6 +55,7 @@ public class UserCollectionResource {
|
||||
@TypeHint(UserDto[].class)
|
||||
@StatusCodes({
|
||||
@ResponseCode(code = 200, condition = "success"),
|
||||
@ResponseCode(code = 400, condition = "\"sortBy\" field unknown"),
|
||||
@ResponseCode(code = 401, condition = "not authenticated / invalid credentials"),
|
||||
@ResponseCode(code = 403, condition = "not authorized, the current user does not have the \"user\" privilege"),
|
||||
@ResponseCode(code = 500, condition = "internal server error")
|
||||
|
||||
Reference in New Issue
Block a user