Search in sources :

Example 1 with AccountLimits

use of com.google.gerrit.server.account.AccountLimits in project gerrit by GerritCodeReview.

the class GetCapabilities method apply.

@Override
public Response<Map<String, Object>> apply(AccountResource resource) throws RestApiException, PermissionBackendException {
    permissionBackend.checkUsesDefaultCapabilities();
    PermissionBackend.WithUser perm = permissionBackend.currentUser();
    if (!self.get().hasSameAccountId(resource.getUser())) {
        perm.check(GlobalPermission.ADMINISTRATE_SERVER);
        perm = permissionBackend.absentUser(resource.getUser().getAccountId());
    }
    Map<String, Object> have = new LinkedHashMap<>();
    for (GlobalOrPluginPermission p : perm.test(permissionsToTest())) {
        have.put(globalOrPluginPermissionName(p), true);
    }
    AccountLimits limits = limitsFactory.create(resource.getUser());
    addRanges(have, limits);
    addPriority(have, limits);
    return Response.ok(have);
}
Also used : AccountLimits(com.google.gerrit.server.account.AccountLimits) PermissionBackend(com.google.gerrit.server.permissions.PermissionBackend) GlobalOrPluginPermission(com.google.gerrit.extensions.api.access.GlobalOrPluginPermission) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

GlobalOrPluginPermission (com.google.gerrit.extensions.api.access.GlobalOrPluginPermission)1 AccountLimits (com.google.gerrit.server.account.AccountLimits)1 PermissionBackend (com.google.gerrit.server.permissions.PermissionBackend)1 LinkedHashMap (java.util.LinkedHashMap)1