Merge branch 'stable-2.15'

* stable-2.15:
  Fix common-dbcp dependency name for in-tree build
  Format BUILD files with buildifier
  Format Java files with google-java-format 1.6
  Update bazlets to latest revision on stable-2.15 to use 2.15.2 API
  Bazel: Switch to using release plugin API
  Adapt to recent API changes

Change-Id: Icbf8533f0c0ac397852585b439630663f8a79ab7
diff --git a/BUILD b/BUILD
index 71c2c0d..4fded0a 100644
--- a/BUILD
+++ b/BUILD
@@ -1,8 +1,8 @@
 load(
     "//tools/bzl:plugin.bzl",
-    "gerrit_plugin",
     "PLUGIN_DEPS",
     "PLUGIN_TEST_DEPS",
+    "gerrit_plugin",
 )
 
 gerrit_plugin(
@@ -19,7 +19,7 @@
         "Implementation-URL: https://gerrit-review.googlesource.com/#/admin/projects/plugins/verify-status",
     ],
     provided_deps = [
-        "@commons_dbcp//jar:neverlink",
+        "@commons-dbcp//jar:neverlink",
     ],
     resources = glob(["src/main/**/*"]),
 )
@@ -28,8 +28,8 @@
     name = "verify-status-tests",
     size = "small",
     srcs = ["src/test/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusIT.java"],
-    test_class = "com.googlesource.gerrit.plugins.verifystatus.VerifyStatusIT",
     tags = ["verify-status"],
+    test_class = "com.googlesource.gerrit.plugins.verifystatus.VerifyStatusIT",
     deps = PLUGIN_DEPS + PLUGIN_TEST_DEPS + [
         ":verify-status__plugin",
     ],
diff --git a/WORKSPACE b/WORKSPACE
index 65c1637..12a9504 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,38 +3,38 @@
 load("//:bazlets.bzl", "load_bazlets")
 
 load_bazlets(
-    commit = "696f59e1b591c23469433cd7a8e5933c738682c5",
+    commit = "7ce9a3f58f030635b3a1229b7fb4c62ee7979bc8",
     # local_path = "/home/<user>/projects/bazlets",
 )
 
 # Snapshot Plugin API
-load(
-    "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl",
-    "gerrit_api_maven_local",
-)
+#load(
+#    "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl",
+#    "gerrit_api_maven_local",
+#)
 
 # Release Plugin API
-#load(
-#    "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl",
-#    "gerrit_api",
-#)
+load(
+    "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl",
+    "gerrit_api",
+)
 load(
     "@com_googlesource_gerrit_bazlets//:gerrit_gwt.bzl",
     "gerrit_gwt",
 )
 
 # Load release Plugin API
-#gerrit_api()
+gerrit_api()
 
 # Load snapshot Plugin API
-gerrit_api_maven_local()
+#gerrit_api_maven_local()
 
 gerrit_gwt()
 
 load("@com_googlesource_gerrit_bazlets//tools:maven_jar.bzl", "maven_jar")
 
 maven_jar(
-    name = "commons_dbcp",
+    name = "commons-dbcp",
     artifact = "commons-dbcp:commons-dbcp:1.4",
     sha1 = "30be73c965cc990b153a100aaaaafcf239f82d39",
 )
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SaveCommand.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SaveCommand.java
index b0ff5bd..97d7114 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SaveCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/SaveCommand.java
@@ -26,6 +26,7 @@
 import com.google.gerrit.server.change.ChangesCollection;
 import com.google.gerrit.server.change.RevisionResource;
 import com.google.gerrit.server.change.Revisions;
+import com.google.gerrit.server.permissions.PermissionBackendException;
 import com.google.gerrit.server.project.ProjectControl;
 import com.google.gerrit.sshd.CommandMetaData;
 import com.google.gerrit.sshd.SshCommand;
@@ -51,12 +52,11 @@
   private final Set<PatchSet> patchSets = new HashSet<>();
 
   @Argument(
-    index = 0,
-    required = true,
-    multiValued = true,
-    metaVar = "{COMMIT | CHANGE,PATCHSET}",
-    usage = "list of commits or patch sets to verify"
-  )
+      index = 0,
+      required = true,
+      multiValued = true,
+      metaVar = "{COMMIT | CHANGE,PATCHSET}",
+      usage = "list of commits or patch sets to verify")
   void addPatchSetId(String token) {
     try {
       PatchSet ps = psParser.parsePatchSet(token, projectControl, branch);
@@ -69,21 +69,19 @@
   }
 
   @Option(
-    name = "--project",
-    aliases = "-p",
-    usage = "project containing the specified patch set(s)"
-  )
+      name = "--project",
+      aliases = "-p",
+      usage = "project containing the specified patch set(s)")
   private ProjectControl projectControl;
 
   @Option(name = "--branch", aliases = "-b", usage = "branch containing the specified patch set(s)")
   private String branch;
 
   @Option(
-    name = "--verification",
-    aliases = "-v",
-    usage = "verification to set the result for",
-    metaVar = "VERIFY=OUTCOME"
-  )
+      name = "--verification",
+      aliases = "-v",
+      usage = "verification to set the result for",
+      metaVar = "VERIFY=OUTCOME")
   void addJob(String token) {
     parseWithEquals(token);
   }
@@ -148,7 +146,7 @@
   }
 
   private void applyVerification(PatchSet patchSet, VerifyInput verify)
-      throws RestApiException, OrmException, IOException {
+      throws RestApiException, OrmException, IOException, PermissionBackendException {
     RevisionResource revResource =
         revisions.parse(
             changes.parse(patchSet.getId().getParentKey()),
@@ -161,7 +159,7 @@
     verify.verifications = jobResult;
     try {
       applyVerification(patchSet, verify);
-    } catch (RestApiException | OrmException | IOException e) {
+    } catch (RestApiException | OrmException | IOException | PermissionBackendException e) {
       throw PatchSetParser.error(e.getMessage());
     }
   }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/GetVerifications.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/GetVerifications.java
index 3d72b63..b50606b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/GetVerifications.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/GetVerifications.java
@@ -43,21 +43,19 @@
   private String filter;
 
   @Option(
-    name = "--sort",
-    aliases = {"-s"},
-    metaVar = "SORT",
-    usage = "Sort the list by an entry"
-  )
+      name = "--sort",
+      aliases = {"-s"},
+      metaVar = "SORT",
+      usage = "Sort the list by an entry")
   public void setSort(String sort) {
     this.sort = sort.toUpperCase();
   }
 
   @Option(
-    name = "--filter",
-    aliases = {"-f"},
-    metaVar = "FILTER",
-    usage = "filter the results"
-  )
+      name = "--filter",
+      aliases = {"-f"},
+      metaVar = "FILTER",
+      usage = "filter the results")
   public void setFilter(String filter) {
     this.filter = filter.toUpperCase();
   }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PatchSetVerificationAccess.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PatchSetVerificationAccess.java
index c78a05f..2bd9ffb 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PatchSetVerificationAccess.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/PatchSetVerificationAccess.java
@@ -1,16 +1,16 @@
-//Copyright (C) 2015 The Android Open Source Project
+// Copyright (C) 2015 The Android Open Source Project
 //
-//Licensed under the Apache License, Version 2.0 (the "License");
-//you may not use this file except in compliance with the License.
-//You may obtain a copy of the License at
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
 //
-//http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
 //
-//Unless required by applicable law or agreed to in writing, software
-//distributed under the License is distributed on an "AS IS" BASIS,
-//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//See the License for the specific language governing permissions and
-//limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
 
 package com.googlesource.gerrit.plugins.verifystatus.server;
 
diff --git a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDataSourceProvider.java b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDataSourceProvider.java
index 9b710ca..fcd783f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDataSourceProvider.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/verifystatus/server/schema/CiDataSourceProvider.java
@@ -105,7 +105,7 @@
   }
 
   private DataSource open(Context context, CiDataSourceType dst) {
-    //ConfigSection dbs = new ConfigSection(cfg, "database");
+    // ConfigSection dbs = new ConfigSection(cfg, "database");
     String driver = config.getString("driver");
     if (Strings.isNullOrEmpty(driver)) {
       driver = dst.getDriver();
diff --git a/src/test/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusIT.java b/src/test/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusIT.java
index dbd8d03..2906561 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusIT.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/verifystatus/VerifyStatusIT.java
@@ -37,11 +37,10 @@
 import org.junit.Test;
 
 @TestPlugin(
-  name = "verify-status",
-  sysModule = "com.googlesource.gerrit.plugins.verifystatus.GlobalModule",
-  httpModule = "com.googlesource.gerrit.plugins.verifystatus.HttpModule",
-  sshModule = "com.googlesource.gerrit.plugins.verifystatus.SshModule"
-)
+    name = "verify-status",
+    sysModule = "com.googlesource.gerrit.plugins.verifystatus.GlobalModule",
+    httpModule = "com.googlesource.gerrit.plugins.verifystatus.HttpModule",
+    sshModule = "com.googlesource.gerrit.plugins.verifystatus.SshModule")
 public class VerifyStatusIT extends LightweightPluginDaemonTest {
   private static final String NAME = "verify-status";
   private static final String DB_TYPE_CONFIG = "plugin." + NAME + ".dbType";
diff --git a/tools/bzl/BUILD b/tools/bzl/BUILD
index 8b13789..e69de29 100644
--- a/tools/bzl/BUILD
+++ b/tools/bzl/BUILD
@@ -1 +0,0 @@
-