Use a common interface for Gerrit permissions

Gerrit has defined permissions for hosts, projects, refs, changes,
labels and plugins. But those permissions are not built on one common
interface even though their behaviors are almost the same. This makes
the life in the PermissionBackend a little bit hard. For example, some
general logic for a permission couldn't be shared with others.

This commit defines the 'GerritPermission' interface and adapts existing
permission class/interface to leverage on this common interface.

Change-Id: I56d5afbf0ddd7703fdbdfa3911929dbfab7ad065
This commit is contained in:
Changcheng Xiao
2018-04-10 13:36:37 +02:00
parent 8c65c396ee
commit 8ded5cb158
10 changed files with 65 additions and 73 deletions

View File

@@ -25,7 +25,6 @@ import com.google.gerrit.extensions.api.access.PluginPermission;
import java.lang.annotation.Annotation;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -133,11 +132,6 @@ public enum GlobalPermission implements GlobalOrPluginPermission {
return name;
}
@Override
public String describeForException() {
return toString().toLowerCase(Locale.US).replace('_', ' ');
}
private static GlobalOrPluginPermission resolve(
@Nullable String pluginName,
String capability,