Merge branch 'stable-2.16' into stable-3.0

* stable-2.16:
  Bump required Bazel version to 2.1.0

Change-Id: I6d6048ac5de343f5c2f8887140709b71c27b6c43
diff --git a/WORKSPACE b/WORKSPACE
index ddd16da..f1961d8 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,7 +3,7 @@
 load("//:bazlets.bzl", "load_bazlets")
 
 load_bazlets(
-    commit = "1b6fc9b39001806b37a4eedbb0a4816daf1a227d",
+    commit = "96f691ebbf4ef1c46b798e871ed5acd9d844651c",
     #local_path = "/home/<user>/projects/bazlets",
 )
 
diff --git a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/GetFullPathCommand.java b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/GetFullPathCommand.java
index 12be859..ae16ef6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/GetFullPathCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/GetFullPathCommand.java
@@ -52,7 +52,7 @@
     if (localDiskRepositoryManager == null) {
       throw new UnloggedFailure(1, "Command only works with disk based repository managers");
     }
-    Project.NameKey nameKey = new Project.NameKey(projectName);
+    Project.NameKey nameKey = Project.nameKey(projectName);
     stdout.println(
         localDiskRepositoryManager
             .getBasePath(nameKey)
diff --git a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowAccountCommand.java b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowAccountCommand.java
index 99c140e..ffeaed4 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowAccountCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowAccountCommand.java
@@ -21,7 +21,6 @@
 import com.google.gerrit.extensions.common.SshKeyInfo;
 import com.google.gerrit.extensions.restapi.AuthException;
 import com.google.gerrit.reviewdb.client.Account;
-import com.google.gerrit.reviewdb.client.Account.Id;
 import com.google.gerrit.server.IdentifiedUser;
 import com.google.gerrit.server.account.AccountCache;
 import com.google.gerrit.server.account.AccountResolver;
@@ -89,7 +88,7 @@
 
   @Override
   public void run() throws UnloggedFailure, Exception {
-    Account account;
+    AccountState account;
 
     if (name.isEmpty()) {
       throw new UnloggedFailure(
@@ -97,7 +96,7 @@
           "You need to tell me who to find:  LastName,\\\\ Firstname, email@address.com, account id or an user name.  "
               + "Be sure to double-escape spaces, for example: \"show-account Last,\\\\ First\"");
     }
-    Set<Id> idList = accountResolver.findAll(name);
+    Set<Account.Id> idList = accountResolver.resolve(name).asIdSet();
     if (idList.isEmpty()) {
       throw new UnloggedFailure(
           1,
@@ -116,26 +115,26 @@
             + "\"");
     stdout.println();
 
-    for (Id id : idList) {
-      account = accountResolver.find(id.toString());
+    for (Account.Id id : idList) {
+      account = accountResolver.resolve(id.toString()).asUnique();
       if (account == null) {
         throw new UnloggedFailure("Account " + id.toString() + " does not exist.");
       }
-      stdout.println("Full name:         " + account.getFullName());
+      stdout.println("Full name:         " + account.getAccount().getFullName());
       stdout.println("Account Id:        " + id.toString());
-      stdout.println("Preferred Email:   " + account.getPreferredEmail());
+      stdout.println("Preferred Email:   " + account.getAccount().getPreferredEmail());
       Optional<AccountState> accountState = accountCache.get(id);
       if (accountState.isPresent()) {
         stdout.println("User Name:         " + accountState.get().getUserName().get());
       }
-      stdout.println("Active:            " + account.isActive());
-      stdout.println("Registered on:     " + account.getRegisteredOn());
+      stdout.println("Active:            " + account.getAccount().isActive());
+      stdout.println("Registered on:     " + account.getAccount().getRegisteredOn());
 
       stdout.println("");
       stdout.println("External Ids:");
       stdout.println(String.format("%-50s %s", "Email Address:", "External Id:"));
       try {
-        for (ExternalId externalId : externalIds.byAccount(account.getId())) {
+        for (ExternalId externalId : externalIds.byAccount(account.getAccount().getId())) {
           stdout.println(
               String.format(
                   "%-50s %s",
diff --git a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccessCommand.java b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccessCommand.java
index 4c88634..1a79ee7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccessCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccessCommand.java
@@ -45,11 +45,14 @@
   private boolean wide;
 
   @Inject
-  ShowRepoAccessCommand(MetaDataUpdate.Server metaDataUpdateFactory) {
+  ShowRepoAccessCommand(
+      MetaDataUpdate.Server metaDataUpdateFactory, ProjectConfig.Factory projectConfigFactory) {
     this.metaDataUpdateFactory = metaDataUpdateFactory;
+    this.projectConfigFactory = projectConfigFactory;
   }
 
   private final MetaDataUpdate.Server metaDataUpdateFactory;
+  private final ProjectConfig.Factory projectConfigFactory;
 
   private int columns = 80;
   private int permissionGroupWidth;
@@ -64,14 +67,14 @@
     if (projectName.isEmpty()) {
       throw new UnloggedFailure(1, "Please specify a project to show access for");
     }
-    Project.NameKey nameKey = new Project.NameKey(projectName);
+    Project.NameKey nameKey = Project.nameKey(projectName);
 
     permissionGroupWidth = wide ? Integer.MAX_VALUE : columns - 9 - 5 - 9;
 
     ProjectConfig config;
     try {
       MetaDataUpdate md = metaDataUpdateFactory.create(nameKey);
-      config = ProjectConfig.read(md);
+      config = projectConfigFactory.read(md);
       for (AccessSection accessSection : config.getAccessSections()) {
 
         stdout.print((String.format(sectionNameFormatter, accessSection.getName().toString())));
diff --git a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccountAccessCommand.java b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccountAccessCommand.java
index 2f542bf..6d0e4ca 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccountAccessCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccountAccessCommand.java
@@ -22,11 +22,11 @@
 import com.google.gerrit.extensions.annotations.RequiresCapability;
 import com.google.gerrit.extensions.common.GroupInfo;
 import com.google.gerrit.reviewdb.client.Account;
-import com.google.gerrit.reviewdb.client.Account.Id;
 import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.server.IdentifiedUser;
 import com.google.gerrit.server.account.AccountResolver;
 import com.google.gerrit.server.account.AccountResource;
+import com.google.gerrit.server.account.AccountState;
 import com.google.gerrit.server.git.meta.MetaDataUpdate;
 import com.google.gerrit.server.project.ProjectConfig;
 import com.google.gerrit.server.restapi.account.GetGroups;
@@ -65,23 +65,26 @@
       MetaDataUpdate.Server metaDataUpdateFactory,
       Provider<GetGroups> accountGetGroups,
       AccountResolver accountResolver,
-      IdentifiedUser.GenericFactory userFactory) {
+      IdentifiedUser.GenericFactory userFactory,
+      ProjectConfig.Factory projectConfigFactory) {
     this.metaDataUpdateFactory = metaDataUpdateFactory;
     this.accountGetGroups = accountGetGroups;
     this.accountResolver = accountResolver;
     this.userFactory = userFactory;
+    this.projectConfigFactory = projectConfigFactory;
   }
 
   private final MetaDataUpdate.Server metaDataUpdateFactory;
   private final AccountResolver accountResolver;
   private final Provider<GetGroups> accountGetGroups;
   private final IdentifiedUser.GenericFactory userFactory;
+  private final ProjectConfig.Factory projectConfigFactory;
   private int columns = 80;
   private int permissionGroupWidth;
 
   @Override
   public void run() throws UnloggedFailure, Failure, Exception {
-    Account account;
+    AccountState account;
     String sectionNameFormatter = "  %-25s\n";
     String ruleNameFormatter = "    %-15s\n ";
     String permissionNameFormatter = "      %5s %9s %s\n";
@@ -99,7 +102,7 @@
           "You need to tell me who to find:  LastName,\\\\ Firstname, email@address.com, account id or an user name.  "
               + "Be sure to double-escape spaces, for example: \"show-repo-account-access All-Projects --user Last,\\\\ First\"");
     }
-    Set<Id> idList = accountResolver.findAll(name);
+    Set<Account.Id> idList = accountResolver.resolve(name).asIdSet();
     if (idList.isEmpty()) {
       throw new UnloggedFailure(
           1,
@@ -109,19 +112,19 @@
               + " Tip: Try double-escaping spaces, for example: \"--user Last,\\\\ First\"");
     }
 
-    Project.NameKey nameKey = new Project.NameKey(projectName);
+    Project.NameKey nameKey = Project.nameKey(projectName);
 
     try {
       MetaDataUpdate md = metaDataUpdateFactory.create(nameKey);
       ProjectConfig config;
-      config = ProjectConfig.read(md);
+      config = projectConfigFactory.read(md);
 
       permissionGroupWidth = wide ? Integer.MAX_VALUE : columns - 9 - 5 - 9;
 
-      for (Id id : idList) {
+      for (Account.Id id : idList) {
         userHasPermissionsInProject = false;
-        account = accountResolver.find(id.toString());
-        stdout.println("Full name:         " + account.getFullName());
+        account = accountResolver.resolve(id.toString()).asUnique();
+        stdout.println("Full name:         " + account.getAccount().getFullName());
         // Need to know what groups the user is in. This is not a great
         // solution, but it does work.
         List<GroupInfo> groupInfos =