Merge branch 'stable-3.0'

* stable-3.0:
  ListQuotas: Refactor apply method's throws list
  Upgrade bazlets to latest stable-2.15
  Upgrade bazlets to latest stable-2.14

Change-Id: Ie4ba28c0b6ea991185bf749dedc734809dbc8bd2
diff --git a/WORKSPACE b/WORKSPACE
index d562b35..9214576 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,24 +3,24 @@
 load("//:bazlets.bzl", "load_bazlets")
 
 load_bazlets(
-    commit = "631205bc4f7903d3cf656a844cab2bfd6b03f246",
+    commit = "1ddb1d6c71b77972a89aa0a717f6250ef256d166",
     #local_path = "/home/<user>/projects/bazlets",
 )
 
 # Snapshot Plugin API
-#load(
-#    "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl",
-#    "gerrit_api_maven_local",
-#)
-
-# Load snapshot Plugin API
-#gerrit_api_maven_local()
-
-# Release Plugin API
 load(
-    "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl",
-    "gerrit_api",
+    "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl",
+    "gerrit_api_maven_local",
 )
 
+# Load snapshot Plugin API
+gerrit_api_maven_local()
+
+# Release Plugin API
+#load(
+#    "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl",
+#    "gerrit_api",
+#)
+
 # Load release Plugin API
-gerrit_api()
+#gerrit_api()
diff --git a/src/main/java/com/googlesource/gerrit/plugins/quota/DeletionListener.java b/src/main/java/com/googlesource/gerrit/plugins/quota/DeletionListener.java
index e625187..c0e72f1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/quota/DeletionListener.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/quota/DeletionListener.java
@@ -29,6 +29,6 @@
 
   @Override
   public void onProjectDeleted(Event event) {
-    repoSizeCache.evict(new Project.NameKey(event.getProjectName()));
+    repoSizeCache.evict(Project.nameKey(event.getProjectName()));
   }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/quota/GCListener.java b/src/main/java/com/googlesource/gerrit/plugins/quota/GCListener.java
index ca2e933..6631b21 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/quota/GCListener.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/quota/GCListener.java
@@ -16,7 +16,6 @@
 
 import com.google.gerrit.extensions.events.GarbageCollectorListener;
 import com.google.gerrit.reviewdb.client.Project;
-import com.google.gerrit.reviewdb.client.Project.NameKey;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import java.util.Properties;
@@ -33,7 +32,7 @@
 
   @Override
   public void onGarbageCollected(GarbageCollectorListener.Event event) {
-    Project.NameKey key = new NameKey(event.getProjectName());
+    Project.NameKey key = Project.nameKey(event.getProjectName());
     Properties statistics = event.getStatistics();
     if (statistics != null) {
       Number sizeOfLooseObjects = (Number) statistics.get("sizeOfLooseObjects");
diff --git a/src/main/java/com/googlesource/gerrit/plugins/quota/GetQuota.java b/src/main/java/com/googlesource/gerrit/plugins/quota/GetQuota.java
index 854d9ef..8d3d176 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/quota/GetQuota.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/quota/GetQuota.java
@@ -17,6 +17,7 @@
 import static com.googlesource.gerrit.plugins.quota.MaxRepositorySizeQuota.REPO_SIZE_CACHE;
 
 import com.google.common.cache.LoadingCache;
+import com.google.gerrit.extensions.restapi.Response;
 import com.google.gerrit.extensions.restapi.RestReadView;
 import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.server.project.ProjectCache;
@@ -43,8 +44,8 @@
   }
 
   @Override
-  public QuotaInfo apply(ProjectResource rsrc) throws ExecutionException {
-    return getInfo(rsrc.getNameKey());
+  public Response apply(ProjectResource rsrc) throws ExecutionException {
+    return Response.ok(getInfo(rsrc.getNameKey()));
   }
 
   QuotaInfo getInfo(Project.NameKey n) throws ExecutionException {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/quota/ListQuotas.java b/src/main/java/com/googlesource/gerrit/plugins/quota/ListQuotas.java
index 37d1db4..ccaa55c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/quota/ListQuotas.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/quota/ListQuotas.java
@@ -15,12 +15,13 @@
 package com.googlesource.gerrit.plugins.quota;
 
 import com.google.common.collect.Maps;
+import com.google.gerrit.extensions.restapi.Response;
 import com.google.gerrit.extensions.restapi.RestApiException;
 import com.google.gerrit.extensions.restapi.RestReadView;
 import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.server.config.ConfigResource;
-import com.google.gerrit.server.restapi.project.ListProjects;
 import com.google.gerrit.server.permissions.PermissionBackendException;
+import com.google.gerrit.server.restapi.project.ListProjects;
 import com.google.inject.Inject;
 import com.google.inject.Provider;
 import com.googlesource.gerrit.plugins.quota.GetQuota.QuotaInfo;
@@ -50,15 +51,15 @@
   }
 
   @Override
-  public Map<String, QuotaInfo> apply(ConfigResource resource)
+  public Response apply(ConfigResource resource)
       throws RestApiException, ExecutionException, PermissionBackendException {
     Map<String, QuotaInfo> result = Maps.newTreeMap();
     ListProjects lister = listProjects.get();
     lister.setMatchPrefix(matchPrefix);
     for (String projectName : lister.apply().keySet()) {
-      Project.NameKey n = new Project.NameKey(projectName);
+      Project.NameKey n = Project.nameKey(projectName);
       result.put(projectName, getQuota.getInfo(n));
     }
-    return result;
+    return Response.ok(result);
   }
 }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/quota/DeletionListenerTest.java b/src/test/java/com/googlesource/gerrit/plugins/quota/DeletionListenerTest.java
index 592809e..74d45c2 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/quota/DeletionListenerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/quota/DeletionListenerTest.java
@@ -29,7 +29,7 @@
   @Test
   public void testName() throws Exception {
     RepoSizeCache repoSizeCache = createMock(RepoSizeCache.class);
-    Project.NameKey p = new Project.NameKey(MY_PROJECT);
+    Project.NameKey p = Project.nameKey(MY_PROJECT);
     repoSizeCache.evict(p);
     DeletionListener classUnderTest = new DeletionListener(repoSizeCache);
     replay(repoSizeCache);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/quota/GCListenerTest.java b/src/test/java/com/googlesource/gerrit/plugins/quota/GCListenerTest.java
index f73ef3d..7376ee5 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/quota/GCListenerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/quota/GCListenerTest.java
@@ -31,7 +31,7 @@
   @Test
   public void testEventWithStatistics() {
     RepoSizeCache repoSizeCache = createMock(RepoSizeCache.class);
-    repoSizeCache.set(new Project.NameKey(PROJECT_NAME), 9999L);
+    repoSizeCache.set(Project.nameKey(PROJECT_NAME), 9999L);
     expectLastCall();
     replay(repoSizeCache);
 
@@ -49,7 +49,7 @@
   @Test
   public void testEventWithoutStatistics() {
     RepoSizeCache repoSizeCache = createMock(RepoSizeCache.class);
-    repoSizeCache.evict(new Project.NameKey(PROJECT_NAME));
+    repoSizeCache.evict(Project.nameKey(PROJECT_NAME));
     expectLastCall();
     replay(repoSizeCache);
 
@@ -63,7 +63,7 @@
   @Test
   public void testEventWithEmptyStatistics() {
     RepoSizeCache repoSizeCache = createMock(RepoSizeCache.class);
-    repoSizeCache.evict(new Project.NameKey(PROJECT_NAME));
+    repoSizeCache.evict(Project.nameKey(PROJECT_NAME));
     expectLastCall();
     replay(repoSizeCache);
 
diff --git a/src/test/java/com/googlesource/gerrit/plugins/quota/RateLimitUploadListenerTest.java b/src/test/java/com/googlesource/gerrit/plugins/quota/RateLimitUploadListenerTest.java
index a6f2a47..fb7fad8 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/quota/RateLimitUploadListenerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/quota/RateLimitUploadListenerTest.java
@@ -70,7 +70,6 @@
     when(currentUser.isIdentifiedUser()).thenReturn(true);
     when(currentUser.asIdentifiedUser().getAccountId()).thenReturn(accountId);
     when(limitsPerAccount.get(accountId)).thenThrow(new ExecutionException(null));
-    when(accountId.toString()).thenReturn("123");
   }
 
   private void setUpAnonymous() throws ExecutionException {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/quota/RepoSizeEventCreatorTest.java b/src/test/java/com/googlesource/gerrit/plugins/quota/RepoSizeEventCreatorTest.java
index 2b40ca4..df01576 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/quota/RepoSizeEventCreatorTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/quota/RepoSizeEventCreatorTest.java
@@ -32,9 +32,9 @@
 import org.junit.Test;
 
 public class RepoSizeEventCreatorTest {
-  private Project.NameKey p1 = new Project.NameKey("p1");
-  private Project.NameKey p2 = new Project.NameKey("p2");
-  private Project.NameKey p3 = new Project.NameKey("p3");
+  private Project.NameKey p1 = Project.nameKey("p1");
+  private Project.NameKey p2 = Project.nameKey("p2");
+  private Project.NameKey p3 = Project.nameKey("p3");
   private ProjectCache projectCache;
   private RepoSizeEventCreator classUnderTest;
   private File tmp;
diff --git a/src/test/java/com/googlesource/gerrit/plugins/quota/RestApiRateLimiterTest.java b/src/test/java/com/googlesource/gerrit/plugins/quota/RestApiRateLimiterTest.java
index 64fe0c7..aba42be 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/quota/RestApiRateLimiterTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/quota/RestApiRateLimiterTest.java
@@ -86,7 +86,6 @@
     when(currentUser.isIdentifiedUser()).thenReturn(true);
     when(currentUser.asIdentifiedUser().getAccountId()).thenReturn(accountId);
     when(limitsPerAccount.get(accountId)).thenThrow(new ExecutionException(null));
-    when(accountId.toString()).thenReturn("123");
   }
 
   private void setUpAnonymous() throws ExecutionException {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/quota/TestNamespaceMatching.java b/src/test/java/com/googlesource/gerrit/plugins/quota/TestNamespaceMatching.java
index 53253ee..b4ad2e6 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/quota/TestNamespaceMatching.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/quota/TestNamespaceMatching.java
@@ -25,22 +25,22 @@
   @Test
   public void exactNamespace() {
     String exact = "test/myProject";
-    assertTrue(new Namespace(exact).matches(new Project.NameKey("test/myProject")));
-    assertFalse(new Namespace(exact).matches(new Project.NameKey("test/myOtherProject")));
+    assertTrue(new Namespace(exact).matches(Project.nameKey("test/myProject")));
+    assertFalse(new Namespace(exact).matches(Project.nameKey("test/myOtherProject")));
   }
 
   @Test
   public void patternNamespace() {
     String pattern = "test/*";
-    assertTrue(new Namespace(pattern).matches(new Project.NameKey("test/myProject")));
-    assertFalse(new Namespace(pattern).matches(new Project.NameKey("other/myOtherProject")));
+    assertTrue(new Namespace(pattern).matches(Project.nameKey("test/myProject")));
+    assertFalse(new Namespace(pattern).matches(Project.nameKey("other/myOtherProject")));
   }
 
   @Test
   public void regExp() {
     String pattern = "^test/.*/my.*";
-    assertTrue(new Namespace(pattern).matches(new Project.NameKey("test/a/myProject")));
-    assertTrue(new Namespace(pattern).matches(new Project.NameKey("test/b/myOtherProject")));
-    assertFalse(new Namespace(pattern).matches(new Project.NameKey("other/otherProject")));
+    assertTrue(new Namespace(pattern).matches(Project.nameKey("test/a/myProject")));
+    assertTrue(new Namespace(pattern).matches(Project.nameKey("test/b/myOtherProject")));
+    assertFalse(new Namespace(pattern).matches(Project.nameKey("other/otherProject")));
   }
 }