mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +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;
|
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) {
|
private void checkSortByField(String sortBy) {
|
||||||
try {
|
try {
|
||||||
BeanInfo info = Introspector.getBeanInfo(type);
|
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) {
|
int pageSize) {
|
||||||
AssertUtil.assertPositive(pageNumber);
|
AssertUtil.assertPositive(pageNumber);
|
||||||
AssertUtil.assertPositive(pageSize);
|
AssertUtil.assertPositive(pageSize);
|
||||||
|
|
||||||
if (Util.isEmpty(sortby)) {
|
if (Util.isEmpty(sortBy)) {
|
||||||
// replace with something useful
|
// 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 ----------------------------------------------------------
|
//~--- get methods ----------------------------------------------------------
|
||||||
|
|||||||
@@ -43,9 +43,10 @@ public class GroupCollectionResource {
|
|||||||
* Returns all groups for a given page number with a given page size (default page size is {@value DEFAULT_PAGE_SIZE}).
|
* 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.
|
* <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 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
|
* @param desc sort direction desc or aesc
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@@ -54,6 +55,7 @@ public class GroupCollectionResource {
|
|||||||
@TypeHint(GroupDto[].class)
|
@TypeHint(GroupDto[].class)
|
||||||
@StatusCodes({
|
@StatusCodes({
|
||||||
@ResponseCode(code = 200, condition = "success"),
|
@ResponseCode(code = 200, condition = "success"),
|
||||||
|
@ResponseCode(code = 400, condition = "\"sortBy\" field unknown"),
|
||||||
@ResponseCode(code = 401, condition = "not authenticated / invalid credentials"),
|
@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 = 403, condition = "not authorized, the current user does not have the \"group\" privilege"),
|
||||||
@ResponseCode(code = 500, condition = "internal server error")
|
@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}).
|
* 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.
|
* <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 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
|
* @param desc sort direction desc or asc
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@@ -54,6 +55,7 @@ public class UserCollectionResource {
|
|||||||
@TypeHint(UserDto[].class)
|
@TypeHint(UserDto[].class)
|
||||||
@StatusCodes({
|
@StatusCodes({
|
||||||
@ResponseCode(code = 200, condition = "success"),
|
@ResponseCode(code = 200, condition = "success"),
|
||||||
|
@ResponseCode(code = 400, condition = "\"sortBy\" field unknown"),
|
||||||
@ResponseCode(code = 401, condition = "not authenticated / invalid credentials"),
|
@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 = 403, condition = "not authorized, the current user does not have the \"user\" privilege"),
|
||||||
@ResponseCode(code = 500, condition = "internal server error")
|
@ResponseCode(code = 500, condition = "internal server error")
|
||||||
|
|||||||
Reference in New Issue
Block a user