Merge branch 'stable-2.14' into stable-2.15
* stable-2.14:
Upgrade bazlets to latest stable-2.14
Change-Id: I6ad91abdca19cfad38dcd57c7a330cfa5c0e4ae0
diff --git a/WORKSPACE b/WORKSPACE
index 0bb77c7..ec1b78c 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,7 +3,7 @@
load("//:bazlets.bzl", "load_bazlets")
load_bazlets(
- commit = "ece89b00ac1049233d9f5bb471a8d37b57667d9e",
+ commit = "ae1cd231b0262b2738e6c0593eb3c504209ad4f5",
#local_path = "/home/<user>/projects/bazlets",
)
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
index e3648d3..02099ff 100644
--- a/external_plugin_deps.bzl
+++ b/external_plugin_deps.bzl
@@ -3,8 +3,8 @@
def external_plugin_deps():
maven_jar(
name = "javamelody-core",
- artifact = "net.bull.javamelody:javamelody-core:1.77.0",
- sha1 = "a2b2dd1d39f21d185ea3215830661002445664a4",
+ artifact = "net.bull.javamelody:javamelody-core:1.79.0",
+ sha1 = "9413e29625402900e69feae8f1948ea694a88244",
)
maven_jar(
diff --git a/src/main/java/com/googlesource/gerrit/plugins/javamelody/CapabilityChecker.java b/src/main/java/com/googlesource/gerrit/plugins/javamelody/CapabilityChecker.java
index d8e8fe5..fc7bef2 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/javamelody/CapabilityChecker.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/javamelody/CapabilityChecker.java
@@ -14,27 +14,45 @@
package com.googlesource.gerrit.plugins.javamelody;
+import com.google.common.collect.ImmutableSet;
import com.google.gerrit.extensions.annotations.PluginName;
+import com.google.gerrit.extensions.api.access.PluginPermission;
+import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.server.CurrentUser;
-import com.google.gerrit.server.account.CapabilityControl;
+import com.google.gerrit.server.permissions.GlobalPermission;
+import com.google.gerrit.server.permissions.PermissionBackend;
+import com.google.gerrit.server.permissions.PermissionBackendException;
import com.google.inject.Inject;
import com.google.inject.Provider;
+import com.google.inject.Singleton;
+@Singleton
public class CapabilityChecker {
+ private final PermissionBackend permissionBackend;
private final Provider<CurrentUser> userProvider;
- private final String capabilityName;
+ private final String pluginName;
@Inject
- CapabilityChecker(Provider<CurrentUser> userProvider, @PluginName String pluginName) {
+ CapabilityChecker(
+ PermissionBackend permissionBackend,
+ Provider<CurrentUser> userProvider,
+ @PluginName String pluginName) {
+ this.permissionBackend = permissionBackend;
this.userProvider = userProvider;
- this.capabilityName = String.format("%s-%s", pluginName, MonitoringCapability.ID);
+ this.pluginName = pluginName;
}
public boolean canMonitor() {
- if (userProvider.get().isIdentifiedUser()) {
- CapabilityControl ctl = userProvider.get().getCapabilities();
- return ctl.canAdministrateServer() || ctl.canPerform(capabilityName);
+ try {
+ permissionBackend
+ .user(userProvider)
+ .checkAny(
+ ImmutableSet.of(
+ GlobalPermission.ADMINISTRATE_SERVER,
+ new PluginPermission(pluginName, MonitoringCapability.ID)));
+ return true;
+ } catch (AuthException | PermissionBackendException e) {
+ return false;
}
- return false;
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/javamelody/MonitoringTopMenu.java b/src/main/java/com/googlesource/gerrit/plugins/javamelody/MonitoringTopMenu.java
index 60ebf86..6e1b0a1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/javamelody/MonitoringTopMenu.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/javamelody/MonitoringTopMenu.java
@@ -29,7 +29,7 @@
if (capabilityChecker.canMonitor()) {
menuEntries.add(
new MenuEntry(
- "Monitoring", Collections.singletonList(new MenuItem("JavaMelody", "monitoring"))));
+ "Monitoring", Collections.singletonList(new MenuItem("JavaMelody", "/monitoring"))));
}
}
diff --git a/src/main/resources/Documentation/build.md b/src/main/resources/Documentation/build.md
index 25725b9..65935ad 100644
--- a/src/main/resources/Documentation/build.md
+++ b/src/main/resources/Documentation/build.md
@@ -89,7 +89,7 @@
bazel build plugins/javamelody:javamelody
```
-Note, that the plugin dependencies with the [database interception](database-monitoring.md)
+Note, that the plugin dependencies with [database interception](database-monitoring.md)
are built separately. To do that, issue this command:
```
@@ -114,9 +114,15 @@
bazel test plugins/@PLUGIN@:@PLUGIN@_tests
```
+[IMPORTANT]
+Both targets above are required and must be deployed to the right
+locations: `javamelody.jar` to `<gerrit_site>/plugins` directory
+and `javamelody-deps_deploy.jar` to `<gerrit_site>/lib` directory.
+
This project can be imported into the Eclipse IDE.
-Add the plugin name to the `CUSTOM_PLUGINS` set in
-Gerrit core in `tools/bzl/plugins.bzl`, and execute:
+Add the plugin name to the `CUSTOM_PLUGINS` and to the
+`CUSTOM_PLUGINS_TEST_DEPS` set in Gerrit core in
+`tools/bzl/plugins.bzl`, and execute:
```
./tools/eclipse/project.py