Remove ProjectControl#isOwnerAnyRef()

In most cases, this method was used as a fallback in case no ref owner
was defined. Comments in the code suggested that it was always intended
to just fall back to ADMINISTRATE_SERVER.

Looking at all use cases individually, it seems safe to just fall back
to ADMINISTRATE_SERVER directly.

Change-Id: I3c7726c3720492f36f737edf7c0e4e7e64c5e6f1
This commit is contained in:
Patrick Hiesel
2017-09-29 09:53:21 +02:00
committed by David Pursehouse
parent f119e29e85
commit bae538bd84
4 changed files with 17 additions and 19 deletions

View File

@@ -40,6 +40,7 @@ import com.google.gerrit.server.account.GroupControl;
import com.google.gerrit.server.config.AllProjectsName;
import com.google.gerrit.server.git.MetaDataUpdate;
import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.permissions.GlobalPermission;
import com.google.gerrit.server.permissions.PermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.gerrit.server.permissions.ProjectPermission;
@@ -193,10 +194,9 @@ class ProjectAccessFactory extends Handler<ProjectAccess> {
}
}
if (ownerOf.isEmpty() && pc.isOwnerAnyRef()) {
if (ownerOf.isEmpty() && isAdmin()) {
// Special case: If the section list is empty, this project has no current
// access control information. Rely on what ProjectControl determines
// is ownership, which probably means falling back to site administrators.
// access control information. Fall back to site administrators.
ownerOf.add(AccessSection.ALL);
}
@@ -271,4 +271,13 @@ class ProjectAccessFactory extends Handler<ProjectAccess> {
return false;
}
}
private boolean isAdmin() throws PermissionBackendException {
try {
permissionBackend.user(user).check(GlobalPermission.ADMINISTRATE_SERVER);
return true;
} catch (AuthException e) {
return false;
}
}
}