upgrade spring, add javadoc, formatting
This commit is contained in:
+8
-12
@@ -51,29 +51,28 @@ public class MinetestAccountManager implements UserDataProvider {
|
||||
* @return the all by owner
|
||||
*/
|
||||
public List<MinetestAccount> getAllByOwner(Long userId) {
|
||||
return Lists
|
||||
.newArrayList(minetestAccountRepository.findAll(qMinetestAccount.owner.eq(userId)));
|
||||
return Lists.newArrayList(minetestAccountRepository.findAll(qMinetestAccount.owner.eq(userId)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the.
|
||||
*
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @return the page
|
||||
*/
|
||||
public Page<MinetestAccount> get(int page, int size, String sortBy, boolean descending) {
|
||||
return minetestAccountRepository.findAll(PageRequest.of(page, size,
|
||||
descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending()));
|
||||
return minetestAccountRepository.findAll(
|
||||
PageRequest.of(page, size, descending ? Sort.by(sortBy).descending() : Sort.by(sortBy).ascending()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the.
|
||||
*
|
||||
* @param owner the owner
|
||||
* @param name the name
|
||||
* @param name the name
|
||||
* @param quota the quota
|
||||
* @return the minetest account
|
||||
*/
|
||||
@@ -113,7 +112,7 @@ public class MinetestAccountManager implements UserDataProvider {
|
||||
* Delete.
|
||||
*
|
||||
* @param minetestAccount the minetest account
|
||||
* @param quota the quota
|
||||
* @param quota the quota
|
||||
*/
|
||||
public void delete(MinetestAccount minetestAccount, boolean quota) {
|
||||
if (quota) {
|
||||
@@ -146,7 +145,6 @@ public class MinetestAccountManager implements UserDataProvider {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see de.bstly.we.businesslogic.UserDataProvider#getId()
|
||||
*/
|
||||
@@ -155,7 +153,6 @@ public class MinetestAccountManager implements UserDataProvider {
|
||||
return "minetest-accounts";
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see de.bstly.we.businesslogic.UserDataProvider#getUserData(java.lang.Long)
|
||||
*/
|
||||
@@ -168,7 +165,6 @@ public class MinetestAccountManager implements UserDataProvider {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see de.bstly.we.businesslogic.UserDataProvider#purgeUserData(java.lang.Long)
|
||||
*/
|
||||
|
||||
+1
-2
@@ -76,8 +76,7 @@ public class MinetestAccountController extends BaseController {
|
||||
throw new EntityResponseStatusException(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
Quota minetestAccountsQuota = quotaManager.get(getCurrentUserId(),
|
||||
MinetestQuotas.MINETEST_ACCOUNTS);
|
||||
Quota minetestAccountsQuota = quotaManager.get(getCurrentUserId(), MinetestQuotas.MINETEST_ACCOUNTS);
|
||||
if (minetestAccountsQuota == null || minetestAccountsQuota.getValue() < 1) {
|
||||
throw new EntityResponseStatusException(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
+6
-11
@@ -47,11 +47,9 @@ public class MinetestAccountManagementController extends BaseController {
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@GetMapping
|
||||
public Page<MinetestAccount> getMinetestAccounts(
|
||||
@RequestParam("page") Optional<Integer> pageParameter,
|
||||
public Page<MinetestAccount> getMinetestAccounts(@RequestParam("page") Optional<Integer> pageParameter,
|
||||
@RequestParam("size") Optional<Integer> sizeParameter) {
|
||||
return minetestAccountManager.get(pageParameter.orElse(0), sizeParameter.orElse(10), "name",
|
||||
true);
|
||||
return minetestAccountManager.get(pageParameter.orElse(0), sizeParameter.orElse(10), "name", true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,8 +60,7 @@ public class MinetestAccountManagementController extends BaseController {
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@PostMapping
|
||||
public MinetestAccount createOrUpdateMinetestAccount(
|
||||
@RequestBody MinetestAccount minetestAccount) {
|
||||
public MinetestAccount createOrUpdateMinetestAccount(@RequestBody MinetestAccount minetestAccount) {
|
||||
|
||||
Errors errors = new RequestBodyErrors(minetestAccount);
|
||||
|
||||
@@ -78,7 +75,7 @@ public class MinetestAccountManagementController extends BaseController {
|
||||
/**
|
||||
* Delete minetest account.
|
||||
*
|
||||
* @param name the name
|
||||
* @param name the name
|
||||
* @param quota the quota
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@@ -91,8 +88,7 @@ public class MinetestAccountManagementController extends BaseController {
|
||||
throw new EntityResponseStatusException(HttpStatus.CONFLICT);
|
||||
}
|
||||
|
||||
minetestAccountManager.delete(minetestAccount,
|
||||
quota.isPresent() && quota.get().booleanValue());
|
||||
minetestAccountManager.delete(minetestAccount, quota.isPresent() && quota.get().booleanValue());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,8 +99,7 @@ public class MinetestAccountManagementController extends BaseController {
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@DeleteMapping("/all/{owner}")
|
||||
public void deleteAll(@PathVariable("owner") Long owner,
|
||||
@RequestParam("quota") Optional<Boolean> quota) {
|
||||
public void deleteAll(@PathVariable("owner") Long owner, @RequestParam("quota") Optional<Boolean> quota) {
|
||||
minetestAccountManager.deleteAll(owner, quota.isPresent() && quota.get().booleanValue());
|
||||
}
|
||||
|
||||
|
||||
+7
-8
@@ -26,7 +26,6 @@ public class MinetestAccountValidator implements Validator {
|
||||
private SystemPropertyManager systemPropertyManager;
|
||||
protected static final String NAME_REGEX = "^([-_a-zA-Z0-9]+)$";
|
||||
|
||||
|
||||
/*
|
||||
* @see org.springframework.validation.Validator#supports(java.lang.Class)
|
||||
*/
|
||||
@@ -34,9 +33,9 @@ public class MinetestAccountValidator implements Validator {
|
||||
return clazz.isAssignableFrom(MinetestAccount.class);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors)
|
||||
* @see org.springframework.validation.Validator#validate(java.lang.Object,
|
||||
* org.springframework.validation.Errors)
|
||||
*/
|
||||
public void validate(Object target, Errors errors) {
|
||||
validateMinetestName(target, errors);
|
||||
@@ -79,11 +78,11 @@ public class MinetestAccountValidator implements Validator {
|
||||
public void validateReservedNames(Object target, Errors errors) {
|
||||
MinetestAccount minetestAccount = (MinetestAccount) target;
|
||||
if (StringUtils.hasText(minetestAccount.getName())) {
|
||||
for (String systemUsername : systemPropertyManager
|
||||
.get(UserModelValidator.RESERVED_USERNAMES, "").split(",")) {
|
||||
if (StringUtils.hasText(systemUsername) && (minetestAccount.getName().toLowerCase()
|
||||
.equals(systemUsername)
|
||||
|| minetestAccount.getName().toLowerCase().matches(systemUsername))) {
|
||||
for (String systemUsername : systemPropertyManager.get(UserModelValidator.RESERVED_USERNAMES, "")
|
||||
.split(",")) {
|
||||
if (StringUtils.hasText(systemUsername)
|
||||
&& (minetestAccount.getName().toLowerCase().equals(systemUsername)
|
||||
|| minetestAccount.getName().toLowerCase().matches(systemUsername))) {
|
||||
errors.rejectValue("name", "NOT_VALID");
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user