Add #absentUser() to ForProject, ForRef and ForChange

We used to think adding this method to the top level is enough
and could avoid misuses. But it turns out we still need them in
other permission backend classes so that we only need to rescope
a user when necessary, which could provide better performance.
See I67b72b59 as an example.

Change-Id: I9ef30fb38315250fa63fb8b3d27e19e19d5e3e22
This commit is contained in:
Changcheng Xiao
2018-05-15 16:27:32 +02:00
parent 4501481b2a
commit 2b2a99e538
9 changed files with 85 additions and 11 deletions

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.permissions;
import com.google.gerrit.extensions.api.access.GlobalOrPluginPermission;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.CurrentUser;
@@ -128,6 +129,11 @@ public class FailedPermissionBackend {
return this;
}
@Override
public ForProject absentUser(Account.Id id) {
return this;
}
@Override
public String resourcePath() {
throw new UnsupportedOperationException(
@@ -181,6 +187,11 @@ public class FailedPermissionBackend {
return this;
}
@Override
public ForRef absentUser(Account.Id id) {
return this;
}
@Override
public String resourcePath() {
throw new UnsupportedOperationException(
@@ -233,6 +244,11 @@ public class FailedPermissionBackend {
return this;
}
@Override
public ForChange absentUser(Account.Id id) {
return this;
}
@Override
public String resourcePath() {
throw new UnsupportedOperationException(