From f23381abe781414f16f43ef59679a511919e9fa7 Mon Sep 17 00:00:00 2001 From: Patrick Hiesel Date: Wed, 11 Jul 2018 09:22:51 +0200 Subject: [PATCH] Remove user-rescoping from PermissionBackend We previously had the option to rescope a permission backend to a user when being already scoped to a change, ref or project. This was in place for performance reasons. A recent experiment showed that this is not needed. Removing rescoping leads to a cleaner interface definition. Change-Id: I3fd524d26a72f4af020c0bdef5122ee5ef7f1af8 --- .../server/permissions/ChangeControl.java | 10 ------ .../permissions/FailedPermissionBackend.java | 32 ------------------- .../server/permissions/PermissionBackend.java | 18 ----------- .../server/permissions/ProjectControl.java | 11 ------- .../gerrit/server/permissions/RefControl.java | 11 ------- .../extensions/webui/UiActionsTest.java | 10 ------ 6 files changed, 92 deletions(-) diff --git a/java/com/google/gerrit/server/permissions/ChangeControl.java b/java/com/google/gerrit/server/permissions/ChangeControl.java index 4aaf61d4ea..b9221471d9 100644 --- a/java/com/google/gerrit/server/permissions/ChangeControl.java +++ b/java/com/google/gerrit/server/permissions/ChangeControl.java @@ -260,16 +260,6 @@ class ChangeControl { return cd; } - @Override - public ForChange user(CurrentUser user) { - return forUser(user).asForChange(cd, db); - } - - @Override - public ForChange absentUser(Account.Id id) { - return user(identifiedUserFactory.create(id)); - } - @Override public String resourcePath() { if (resourcePath == null) { diff --git a/java/com/google/gerrit/server/permissions/FailedPermissionBackend.java b/java/com/google/gerrit/server/permissions/FailedPermissionBackend.java index 6c6f136a7d..bd7c5498a7 100644 --- a/java/com/google/gerrit/server/permissions/FailedPermissionBackend.java +++ b/java/com/google/gerrit/server/permissions/FailedPermissionBackend.java @@ -16,10 +16,8 @@ package com.google.gerrit.server.permissions; import com.google.gerrit.extensions.api.access.GlobalOrPluginPermission; import com.google.gerrit.extensions.conditions.BooleanCondition; -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; import com.google.gerrit.server.notedb.ChangeNotes; import com.google.gerrit.server.permissions.PermissionBackend.ForChange; import com.google.gerrit.server.permissions.PermissionBackend.ForProject; @@ -121,16 +119,6 @@ public class FailedPermissionBackend { return this; } - @Override - public ForProject user(CurrentUser user) { - return this; - } - - @Override - public ForProject absentUser(Account.Id id) { - return this; - } - @Override public String resourcePath() { throw new UnsupportedOperationException( @@ -180,16 +168,6 @@ public class FailedPermissionBackend { return this; } - @Override - public ForRef user(CurrentUser user) { - return this; - } - - @Override - public ForRef absentUser(Account.Id id) { - return this; - } - @Override public String resourcePath() { throw new UnsupportedOperationException( @@ -243,16 +221,6 @@ public class FailedPermissionBackend { return this; } - @Override - public ForChange user(CurrentUser user) { - return this; - } - - @Override - public ForChange absentUser(Account.Id id) { - return this; - } - @Override public String resourcePath() { throw new UnsupportedOperationException( diff --git a/java/com/google/gerrit/server/permissions/PermissionBackend.java b/java/com/google/gerrit/server/permissions/PermissionBackend.java index 0690d6cd3e..4719aa9bd9 100644 --- a/java/com/google/gerrit/server/permissions/PermissionBackend.java +++ b/java/com/google/gerrit/server/permissions/PermissionBackend.java @@ -294,12 +294,6 @@ public abstract class PermissionBackend { /** Returns the fully qualified resource path that this instance is scoped to. */ public abstract String resourcePath(); - /** Returns a new instance rescoped to same project, but different {@code user}. */ - public abstract ForProject user(CurrentUser user); - - /** @see PermissionBackend#absentUser(Account.Id) */ - public abstract ForProject absentUser(Account.Id id); - /** Returns an instance scoped for {@code ref} in this project. */ public abstract ForRef ref(String ref); @@ -400,12 +394,6 @@ public abstract class PermissionBackend { /** Returns a fully qualified resource path that this instance is scoped to. */ public abstract String resourcePath(); - /** Returns a new instance rescoped to same reference, but different {@code user}. */ - public abstract ForRef user(CurrentUser user); - - /** @see PermissionBackend#absentUser(Account.Id) */ - public abstract ForRef absentUser(Account.Id id); - /** Returns an instance scoped to change. */ public abstract ForChange change(ChangeData cd); @@ -456,12 +444,6 @@ public abstract class PermissionBackend { /** Returns the fully qualified resource path that this instance is scoped to. */ public abstract String resourcePath(); - /** Returns a new instance rescoped to same change, but different {@code user}. */ - public abstract ForChange user(CurrentUser user); - - /** @see PermissionBackend#absentUser(Account.Id) */ - public abstract ForChange absentUser(Account.Id id); - /** Verify scoped user can {@code perm}, throwing if denied. */ public abstract void check(ChangePermissionOrLabel perm) throws AuthException, PermissionBackendException; diff --git a/java/com/google/gerrit/server/permissions/ProjectControl.java b/java/com/google/gerrit/server/permissions/ProjectControl.java index ed12a2be60..67662c720a 100644 --- a/java/com/google/gerrit/server/permissions/ProjectControl.java +++ b/java/com/google/gerrit/server/permissions/ProjectControl.java @@ -21,7 +21,6 @@ import com.google.gerrit.common.data.Permission; import com.google.gerrit.common.data.PermissionRule; import com.google.gerrit.extensions.conditions.BooleanCondition; import com.google.gerrit.extensions.restapi.AuthException; -import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.AccountGroup; import com.google.gerrit.reviewdb.client.Branch; import com.google.gerrit.reviewdb.client.Change; @@ -323,16 +322,6 @@ class ProjectControl { private DefaultRefFilter refFilter; private String resourcePath; - @Override - public ForProject user(CurrentUser user) { - return forUser(user).asForProject().database(db); - } - - @Override - public ForProject absentUser(Account.Id id) { - return user(identifiedUserFactory.create(id)); - } - @Override public String resourcePath() { if (resourcePath == null) { diff --git a/java/com/google/gerrit/server/permissions/RefControl.java b/java/com/google/gerrit/server/permissions/RefControl.java index 012d68a00d..3bd2817e8a 100644 --- a/java/com/google/gerrit/server/permissions/RefControl.java +++ b/java/com/google/gerrit/server/permissions/RefControl.java @@ -22,7 +22,6 @@ import com.google.gerrit.common.data.PermissionRule; import com.google.gerrit.common.data.PermissionRule.Action; import com.google.gerrit.extensions.conditions.BooleanCondition; import com.google.gerrit.extensions.restapi.AuthException; -import com.google.gerrit.reviewdb.client.Account; import com.google.gerrit.reviewdb.client.Change; import com.google.gerrit.reviewdb.client.Project; import com.google.gerrit.reviewdb.client.RefNames; @@ -408,16 +407,6 @@ class RefControl { private class ForRefImpl extends ForRef { private String resourcePath; - @Override - public ForRef user(CurrentUser user) { - return forUser(user).asForRef().database(db); - } - - @Override - public ForRef absentUser(Account.Id id) { - return user(identifiedUserFactory.create(id)); - } - @Override public String resourcePath() { if (resourcePath == null) { diff --git a/javatests/com/google/gerrit/server/extensions/webui/UiActionsTest.java b/javatests/com/google/gerrit/server/extensions/webui/UiActionsTest.java index f63b18148f..08d7082518 100644 --- a/javatests/com/google/gerrit/server/extensions/webui/UiActionsTest.java +++ b/javatests/com/google/gerrit/server/extensions/webui/UiActionsTest.java @@ -48,16 +48,6 @@ public class UiActionsTest { return "/projects/test-project"; } - @Override - public ForProject user(CurrentUser user) { - throw new UnsupportedOperationException("not implemented"); - } - - @Override - public ForProject absentUser(Account.Id id) { - throw new UnsupportedOperationException("not implemented"); - } - @Override public ForRef ref(String ref) { throw new UnsupportedOperationException("not implemented");