Merge branch 'stable-2.16' into stable-3.0

* stable-2.16:
  Upgrade bazlets to latest stable-2.16 to build with 2.16.21 API
  Upgrade bazlets to latest stable-2.15 to build with 2.15.19 API
  Upgrade bazlets to latest stable-2.14 to build with 2.14.21 API

Change-Id: I7365ee0c7baa0a4090714dd7b35e177c23666448
diff --git a/WORKSPACE b/WORKSPACE
index 1244157..32e4e6f 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,7 +3,7 @@
 load("//:bazlets.bzl", "load_bazlets")
 
 load_bazlets(
-    commit = "fff6f20bb2eceaf872a8acf8ad51471c25a82d38",
+    commit = "15eae2ee5cd524a204bd62c3d59bfd0ce86916ec",
     #local_path = "/home/<user>/projects/bazlets",
 )
 
diff --git a/src/main/java/com/ericsson/gerrit/plugins/projectgroupstructure/DefaultAccessRights.java b/src/main/java/com/ericsson/gerrit/plugins/projectgroupstructure/DefaultAccessRights.java
index 099a85f..2b7e337 100644
--- a/src/main/java/com/ericsson/gerrit/plugins/projectgroupstructure/DefaultAccessRights.java
+++ b/src/main/java/com/ericsson/gerrit/plugins/projectgroupstructure/DefaultAccessRights.java
@@ -17,8 +17,7 @@
 import com.google.gerrit.common.data.AccessSection;
 import com.google.gerrit.common.data.Permission;
 import com.google.gerrit.common.data.PermissionRule;
-import com.google.gerrit.common.data.RefConfigSection;
-import com.google.gerrit.common.errors.InvalidNameException;
+import com.google.gerrit.exceptions.InvalidNameException;
 import com.google.gerrit.extensions.annotations.PluginData;
 import com.google.gerrit.extensions.events.NewProjectCreatedListener;
 import com.google.gerrit.reviewdb.client.AccountGroup;
@@ -60,10 +59,12 @@
   private final GroupCache groupCache;
   private final ProjectCache projectCache;
   private final MetaDataUpdate.User metaDataUpdateFactory;
+  private final ProjectConfig.Factory projectConfigFactory;
   private final FileBasedConfig defaultAccessRightsConfig;
 
   @Inject
   public DefaultAccessRights(
+      ProjectConfig.Factory projectConfigFactory,
       MetaDataUpdate.User metaDataUpdateFactory,
       ProjectCache projectCache,
       GroupCache groupCache,
@@ -71,6 +72,7 @@
     this.groupCache = groupCache;
     this.projectCache = projectCache;
     this.metaDataUpdateFactory = metaDataUpdateFactory;
+    this.projectConfigFactory = projectConfigFactory;
     defaultAccessRightsConfig =
         new FileBasedConfig(dataDir.resolve(ProjectConfig.PROJECT_CONFIG).toFile(), FS.DETECTED);
     try {
@@ -102,7 +104,7 @@
     }
 
     try (MetaDataUpdate md = metaDataUpdateFactory.create(project.getProject().getNameKey())) {
-      ProjectConfig config = ProjectConfig.read(md);
+      ProjectConfig config = projectConfigFactory.read(md);
       setAccessRights(config, project);
       md.setMessage("Set default access rights\n");
       config.commit(md);
@@ -113,7 +115,7 @@
 
   private void setAccessRights(ProjectConfig config, ProjectState project) {
     for (String refName : defaultAccessRightsConfig.getSubsections(ProjectConfig.ACCESS)) {
-      if (RefConfigSection.isValid(refName) && isValidRegex(refName)) {
+      if (AccessSection.isValidRefSectionName(refName) && isValidRegex(refName)) {
         AccessSection as = config.getAccessSection(refName, true);
         getPermissions(refName, as);
         setPermissions(refName, as, getOwnerGroupName(project));
diff --git a/src/test/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidatorIT.java b/src/test/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidatorIT.java
index 6f74514..f390a30 100644
--- a/src/test/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidatorIT.java
+++ b/src/test/java/com/ericsson/gerrit/plugins/projectgroupstructure/ProjectCreationValidatorIT.java
@@ -134,7 +134,7 @@
     assertThat(r.getEntityContent()).contains("You must be owner of the parent project");
 
     // Creation is OK when user is owner of parent
-    g.addMembers(user.username);
+    g.addMembers(user.username());
     userRestSession.put("/projects/" + Url.encode(parent + "/childProject"), in).assertCreated();
   }
 
@@ -211,7 +211,7 @@
     // the user is in the delegating group
     String delegatingGroup = name("groupB");
     GroupApi dGroup = gApi.groups().create(delegatingGroup);
-    dGroup.addMembers(user.username);
+    dGroup.addMembers(user.username());
     // the group is in the project.config
     Project.NameKey parentNameKey = new Project.NameKey(parent);
     try (ProjectConfigUpdate cfgUpdate = updateProject(parentNameKey)) {
@@ -235,7 +235,7 @@
 
     String delegatingGroup = name("someGroup");
     GroupApi dGroup = gApi.groups().create(delegatingGroup);
-    dGroup.addMembers(user.username);
+    dGroup.addMembers(user.username());
     Project.NameKey parentNameKey = new Project.NameKey(parent);
     try (ProjectConfigUpdate cfgUpdate = updateProject(parentNameKey)) {
       ProjectConfig cfg = cfgUpdate.getConfig();
@@ -290,7 +290,7 @@
 
     String delegatingGroup = name("someGroup");
     GroupApi dGroup = gApi.groups().create(delegatingGroup);
-    dGroup.addMembers(user.username);
+    dGroup.addMembers(user.username());
     Project.NameKey parentNameKey = new Project.NameKey(parent);
     try (ProjectConfigUpdate cfgUpdate = updateProject(parentNameKey)) {
       ProjectConfig cfg = cfgUpdate.getConfig();
@@ -332,7 +332,7 @@
     // the user is in the delegating group
     String delegatingGroup = name("groupB");
     GroupApi dGroup = gApi.groups().create(delegatingGroup);
-    dGroup.addMembers(user.username);
+    dGroup.addMembers(user.username());
     // the group is in the project.config
     Project.NameKey parentNameKey = new Project.NameKey(parent);
     try (ProjectConfigUpdate cfgUpdate = updateProject(parentNameKey)) {
@@ -367,7 +367,7 @@
 
     String nestedGroup = name("groupC");
     GroupApi nGroup = gApi.groups().create(nestedGroup);
-    nGroup.addMembers(user.username);
+    nGroup.addMembers(user.username());
 
     dGroup.addGroups(nestedGroup);
     // the group is in the project.config
@@ -472,7 +472,7 @@
     // the user is in the delegating group
     String delegatingGroup = name("groupB");
     GroupApi dGroup = gApi.groups().create(delegatingGroup);
-    dGroup.addMembers(user.username);
+    dGroup.addMembers(user.username());
     // the group is in the project.config
     Project.NameKey parentNameKey = new Project.NameKey(parent);
     try (ProjectConfigUpdate cfgUpdate = updateProject(parentNameKey)) {