Merge branch 'stable-2.15' into stable-2.16

* stable-2.15:
  Upgrade bazlets to latest stable-2.15 to build with 2.15.10 API

Change-Id: Ia6014024c70ab6cb785a3e71663a26fe2e905e3e
diff --git a/WORKSPACE b/WORKSPACE
index bbbcc0b..eae2d98 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,11 +3,11 @@
 load("//:bazlets.bzl", "load_bazlets")
 
 load_bazlets(
-    commit = "2b1d68959119920e5fa9bdfb9f0cf926bfef4929",
+    commit = "c15e64db2a87c0453427ff45f79d1ed3899b5d92",
     #local_path = "/home/<user>/projects/bazlets",
 )
 
-#Snapshot Plugin API
+# Snapshot Plugin API
 #load(
 #    "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl",
 #    "gerrit_api_maven_local",
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/EventHandler.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/EventHandler.java
index 1c36eeb..ca35e36 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/EventHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/EventHandler.java
@@ -17,10 +17,10 @@
 import static com.googlesource.gerrit.plugins.webhooks.RemoteConfig.REMOTE;
 
 import com.google.common.base.Strings;
-import com.google.gerrit.common.EventListener;
 import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.server.config.PluginConfigFactory;
 import com.google.gerrit.server.events.Event;
+import com.google.gerrit.server.events.EventListener;
 import com.google.gerrit.server.events.ProjectEvent;
 import com.google.gerrit.server.project.NoSuchProjectException;
 import com.google.inject.Inject;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/Module.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/Module.java
index 6c06f6f..edaaeff 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/Module.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/Module.java
@@ -17,10 +17,10 @@
 import static com.googlesource.gerrit.plugins.webhooks.DefaultHttpClientProvider.DEFAULT;
 import static com.googlesource.gerrit.plugins.webhooks.SslVerifyingHttpClientProvider.SSL_VERIFY;
 
-import com.google.gerrit.common.EventListener;
 import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.config.FactoryModule;
 import com.google.gerrit.extensions.registration.DynamicSet;
+import com.google.gerrit.server.events.EventListener;
 import com.google.inject.Inject;
 import com.google.inject.Provides;
 import com.google.inject.Scopes;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/WebhooksConfig.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/WebhooksConfig.java
index 88bb951..56db3f6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/WebhooksConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/WebhooksConfig.java
@@ -27,7 +27,7 @@
 
 import com.google.common.base.Strings;
 import com.google.gerrit.reviewdb.client.RefNames;
-import com.google.gerrit.server.git.VersionedMetaData;
+import com.google.gerrit.server.git.meta.VersionedMetaData;
 import com.google.inject.Inject;
 import com.googlesource.gerrit.plugins.webhooks.rest.UpsertRemote;
 import java.io.IOException;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/DeleteRemote.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/DeleteRemote.java
index 1a4f032..7bb1470 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/DeleteRemote.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/DeleteRemote.java
@@ -17,7 +17,7 @@
 import com.google.gerrit.extensions.restapi.AuthException;
 import com.google.gerrit.extensions.restapi.Response;
 import com.google.gerrit.extensions.restapi.RestModifyView;
-import com.google.gerrit.server.git.MetaDataUpdate;
+import com.google.gerrit.server.git.meta.MetaDataUpdate;
 import com.google.gerrit.server.project.ProjectCache;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/RemotesCollection.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/RemotesCollection.java
index 4f1508c..f1e8acc 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/RemotesCollection.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/RemotesCollection.java
@@ -18,7 +18,6 @@
 
 import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.registration.DynamicMap;
-import com.google.gerrit.extensions.restapi.AcceptsCreate;
 import com.google.gerrit.extensions.restapi.AuthException;
 import com.google.gerrit.extensions.restapi.ChildCollection;
 import com.google.gerrit.extensions.restapi.IdString;
@@ -32,16 +31,13 @@
 import org.eclipse.jgit.lib.Config;
 
 @Singleton
-public class RemotesCollection
-    implements ChildCollection<ProjectWebhooksResource, RemoteResource>,
-        AcceptsCreate<ProjectWebhooksResource> {
+public class RemotesCollection implements ChildCollection<ProjectWebhooksResource, RemoteResource> {
 
   private final DynamicMap<RestView<RemoteResource>> views;
   private final PluginConfigFactory configFactory;
   private final RemoteConfig.Factory remoteFactory;
   private final Provider<ListRemotes> list;
   private final String pluginName;
-  private final UpsertRemote.Inserter.Factory inserterFactory;
 
   @Inject
   RemotesCollection(
@@ -49,14 +45,12 @@
       PluginConfigFactory configFactory,
       RemoteConfig.Factory remoteFactory,
       Provider<ListRemotes> list,
-      @PluginName String pluginName,
-      UpsertRemote.Inserter.Factory inserterFactory) {
+      @PluginName String pluginName) {
     this.views = views;
     this.configFactory = configFactory;
     this.remoteFactory = remoteFactory;
     this.list = list;
     this.pluginName = pluginName;
-    this.inserterFactory = inserterFactory;
   }
 
   @Override
@@ -80,9 +74,4 @@
   public DynamicMap<RestView<RemoteResource>> views() {
     return views;
   }
-
-  @Override
-  public UpsertRemote.Inserter create(ProjectWebhooksResource parent, IdString id) {
-    return inserterFactory.create(id.get());
-  }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/UpsertRemote.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/UpsertRemote.java
index 0c212c6..41eedae 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/UpsertRemote.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/UpsertRemote.java
@@ -19,17 +19,17 @@
 import com.google.common.base.Strings;
 import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.restapi.AuthException;
+import com.google.gerrit.extensions.restapi.IdString;
+import com.google.gerrit.extensions.restapi.RestCollectionCreateView;
 import com.google.gerrit.extensions.restapi.RestModifyView;
 import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.server.config.PluginConfigFactory;
-import com.google.gerrit.server.git.MetaDataUpdate;
+import com.google.gerrit.server.git.meta.MetaDataUpdate;
 import com.google.gerrit.server.project.NoSuchProjectException;
 import com.google.gerrit.server.project.ProjectCache;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 import com.google.inject.Singleton;
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.assistedinject.AssistedInject;
 import com.googlesource.gerrit.plugins.webhooks.RemoteConfig;
 import com.googlesource.gerrit.plugins.webhooks.WebhooksConfig;
 import java.io.IOException;
@@ -67,25 +67,22 @@
   }
 
   public static class Inserter
-      implements RestModifyView<ProjectWebhooksResource, UpsertRemote.Input> {
-    public interface Factory {
-      Inserter create(String remoteName);
-    }
+      implements RestCollectionCreateView<
+          ProjectWebhooksResource, RemoteResource, UpsertRemote.Input> {
 
     private final UpsertRemote upserter;
-    private final String remoteName;
 
-    @AssistedInject
-    Inserter(UpsertRemote upserter, @Assisted String remoteName) {
+    @Inject
+    Inserter(UpsertRemote upserter) {
       this.upserter = upserter;
-      this.remoteName = remoteName;
     }
 
     @Override
-    public RemoteInfo apply(ProjectWebhooksResource rsrc, UpsertRemote.Input in)
+    public RemoteInfo apply(
+        ProjectWebhooksResource rsrc, IdString remoteName, UpsertRemote.Input in)
         throws RepositoryNotFoundException, IOException, ConfigInvalidException,
             NoSuchProjectException, AuthException {
-      return upserter.upsert(rsrc.getProject(), remoteName, in);
+      return upserter.upsert(rsrc.getProject(), remoteName.get(), in);
     }
   }
 
diff --git a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/WebhooksRestModule.java b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/WebhooksRestModule.java
index 6ab24a4..c227964 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/WebhooksRestModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/WebhooksRestModule.java
@@ -18,7 +18,6 @@
 import static com.googlesource.gerrit.plugins.webhooks.rest.ProjectWebhooksResource.PROJECT_WEBHOOK_KIND;
 import static com.googlesource.gerrit.plugins.webhooks.rest.RemoteResource.REMOTE_KIND;
 
-import com.google.gerrit.extensions.config.FactoryModule;
 import com.google.gerrit.extensions.registration.DynamicMap;
 import com.google.gerrit.extensions.restapi.RestApiModule;
 
@@ -31,18 +30,11 @@
 
     child(CONFIG_KIND, "projects").to(ProjectsCollection.class);
     child(PROJECT_WEBHOOK_KIND, "remotes").to(RemotesCollection.class);
+    create(REMOTE_KIND).to(UpsertRemote.Inserter.class);
     get(REMOTE_KIND).to(GetRemote.class);
     put(REMOTE_KIND).to(UpsertRemote.Updater.class);
     delete(REMOTE_KIND).to(DeleteRemote.class);
 
     bind(Permissions.class).to(PermissionsImpl.class);
-
-    install(
-        new FactoryModule() {
-          @Override
-          protected void configure() {
-            factory(UpsertRemote.Inserter.Factory.class);
-          }
-        });
   }
 }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/webhooks/rest/UpdateRemoteIT.java b/src/test/java/com/googlesource/gerrit/plugins/webhooks/rest/UpdateRemoteIT.java
index 0f3f228..cb6f0c7 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/webhooks/rest/UpdateRemoteIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/webhooks/rest/UpdateRemoteIT.java
@@ -39,8 +39,8 @@
 
   @Override
   @Before
-  public void setUp() throws Exception {
-    super.setUp();
+  public void setUpTestPlugin() throws Exception {
+    super.setUpTestPlugin();
     fooEndpoint = String.format("/config/server/webhooks~projects/%s/remotes/foo", project.get());
   }