Remove RefControl#isVisibleByRegisteredUsers

This method was just called from tests and SuggestChangeReviewers. In
SuggestChangeReviewers it was used as a performance shortcut and the
result won't be different when it is removed.

This change removes isVisibleByRegisteredUsers to support our move
towards PermissionBackend which is based on permission checks of
individual refs.

Change-Id: If8e84bd125da62f31fd00bde0f3b3db825d00684
This commit is contained in:
Patrick Hiesel
2017-08-09 15:36:02 +02:00
parent 57945a0f41
commit 4767faa84d
3 changed files with 1 additions and 54 deletions

View File

@@ -80,17 +80,9 @@ public class SuggestChangeReviewers extends SuggestReviewers
}
private VisibilityControl getVisibility(ChangeResource rsrc) {
if (rsrc.getControl().getRefControl().isVisibleByRegisteredUsers()) {
return new VisibilityControl() {
@Override
public boolean isVisibleTo(Account.Id account) throws OrmException {
return true;
}
};
}
// Use the destination reference, not the change, as drafts may deny
// anyone who is not already a reviewer.
// TODO(hiesel) Replace this with a check on the change resource once support for drafts was removed
PermissionBackend.ForRef perm = permissionBackend.user(self).ref(rsrc.getChange().getDest());
return new VisibilityControl() {
@Override

View File

@@ -26,7 +26,6 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.server.CurrentUser;
import com.google.gerrit.server.group.SystemGroupBackend;
import com.google.gerrit.server.notedb.ChangeNotes;
import com.google.gerrit.server.permissions.FailedPermissionBackend;
import com.google.gerrit.server.permissions.PermissionBackend.ForChange;
@@ -127,28 +126,6 @@ public class RefControl {
return canViewPrivateChanges();
}
/** True if this reference is visible by all REGISTERED_USERS */
public boolean isVisibleByRegisteredUsers() {
List<PermissionRule> access = relevant.getPermission(Permission.READ);
List<PermissionRule> overridden = relevant.getOverridden(Permission.READ);
Set<ProjectRef> allows = new HashSet<>();
Set<ProjectRef> blocks = new HashSet<>();
for (PermissionRule rule : access) {
if (rule.isBlock()) {
blocks.add(relevant.getRuleProps(rule));
} else if (SystemGroupBackend.isAnonymousOrRegistered(rule.getGroup())) {
allows.add(relevant.getRuleProps(rule));
}
}
for (PermissionRule rule : overridden) {
if (SystemGroupBackend.isAnonymousOrRegistered(rule.getGroup())) {
blocks.remove(relevant.getRuleProps(rule));
}
}
blocks.removeAll(allows);
return blocks.isEmpty() && !allows.isEmpty();
}
private boolean canUpload() {
return projectControl.controlForRef("refs/for/" + getRefName()).canPerform(Permission.PUSH)
&& isProjectStatePermittingWrite();