Simplify InstallPlugin

Create instances using a Provider, and add builder methods to
set the parameters.

This makes the implementation more consistent with other REST
endpoints, and will make it easier to use from the plugin API.

Change-Id: I5a4db8917c47c62dc5ce199ecad70c724e4e876c
This commit is contained in:
David Pursehouse
2017-07-27 06:37:00 +01:00
parent a43e4a536b
commit 3046b64911
2 changed files with 25 additions and 10 deletions

View File

@@ -33,13 +33,18 @@ public class PluginsCollection
private final DynamicMap<RestView<PluginResource>> views;
private final PluginLoader loader;
private final Provider<ListPlugins> list;
private final Provider<InstallPlugin> install;
@Inject
PluginsCollection(
DynamicMap<RestView<PluginResource>> views, PluginLoader loader, Provider<ListPlugins> list) {
DynamicMap<RestView<PluginResource>> views,
PluginLoader loader,
Provider<ListPlugins> list,
Provider<InstallPlugin> install) {
this.views = views;
this.loader = loader;
this.list = list;
this.install = install;
}
@Override
@@ -64,7 +69,7 @@ public class PluginsCollection
if (!loader.isRemoteAdminEnabled()) {
throw new MethodNotAllowedException("remote installation is disabled");
}
return new InstallPlugin(loader, id.get(), true /* created */);
return install.get().setName(id.get()).setCreated(true);
}
@Override