use of com.google.gerrit.server.plugins.ListPlugins.PluginInfo in project gerrit by GerritCodeReview.
the class InstallPlugin method apply.
@Override
public Response<PluginInfo> apply(TopLevelResource resource, Input input) throws BadRequestException, MethodNotAllowedException, IOException {
if (!loader.isRemoteAdminEnabled()) {
throw new MethodNotAllowedException("remote installation is disabled");
}
try {
try (InputStream in = openStream(input)) {
String pluginName = loader.installPluginFromStream(name, in);
ListPlugins.PluginInfo info = new ListPlugins.PluginInfo(loader.get(pluginName));
return created ? Response.created(info) : Response.ok(info);
}
} catch (PluginInstallException e) {
StringWriter buf = new StringWriter();
buf.write(String.format("cannot install %s", name));
if (e.getCause() instanceof ZipException) {
buf.write(": ");
buf.write(e.getCause().getMessage());
} else {
buf.write(":\n");
PrintWriter pw = new PrintWriter(buf);
e.printStackTrace(pw);
pw.flush();
}
throw new BadRequestException(buf.toString());
}
}
Aggregations