Remove CapabilityControl from CurrentUser
Drop the capabilities reference from all user objects. Most global capabilities can be checked with the PermissionBackend. QoS, query limits, and emailing reviewers still require the capability object. Bundle its factory into the call sites that need it. Continue caching the CapabilityControl in an opaque property on the CurrentUser, and also in the DefaultPermissionBackend.WithUserImpl. Both of these sites reduce evaluations for critical properties like "administrateServer". Change-Id: I5aae8200e0a579ac1295a3fb7005703fd39d2696
This commit is contained in:
committed by
David Pursehouse
parent
f4001aa356
commit
6302ccb2bb
@@ -29,18 +29,20 @@ class ReceiveConfig {
|
||||
final boolean checkReferencedObjectsAreReachable;
|
||||
final boolean allowDrafts;
|
||||
private final int systemMaxBatchChanges;
|
||||
private final CapabilityControl.Factory capabilityFactory;
|
||||
|
||||
@Inject
|
||||
ReceiveConfig(@GerritServerConfig Config config) {
|
||||
ReceiveConfig(@GerritServerConfig Config config, CapabilityControl.Factory capabilityFactory) {
|
||||
checkMagicRefs = config.getBoolean("receive", null, "checkMagicRefs", true);
|
||||
checkReferencedObjectsAreReachable =
|
||||
config.getBoolean("receive", null, "checkReferencedObjectsAreReachable", true);
|
||||
allowDrafts = config.getBoolean("change", null, "allowDrafts", true);
|
||||
systemMaxBatchChanges = config.getInt("receive", "maxBatchChanges", 0);
|
||||
this.capabilityFactory = capabilityFactory;
|
||||
}
|
||||
|
||||
public int getEffectiveMaxBatchChangesLimit(CurrentUser user) {
|
||||
CapabilityControl cap = user.getCapabilities();
|
||||
CapabilityControl cap = capabilityFactory.create(user);
|
||||
if (cap.hasExplicitRange(BATCH_CHANGES_LIMIT)) {
|
||||
return cap.getRange(BATCH_CHANGES_LIMIT).getMax();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user