Merge branch 'stable-3.1' into stable-3.2

* stable-3.1:
  Upgrade bazlets to latest stable-3.1 to build with 3.1.10 API

Change-Id: Ic09169e648034b1e2df5ea7f1dc80b8d776753d4
diff --git a/WORKSPACE b/WORKSPACE
index c6690fa..880def2 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,7 +3,7 @@
 load("//:bazlets.bzl", "load_bazlets")
 
 load_bazlets(
-    commit = "91ea277efd6d9f24c18d6ddeba65bed866b00872",
+    commit = "0f81174e3d1b892a1342ebc75bb4bbb158ae0efe",
     #local_path = "/home/<user>/projects/bazlets",
 )
 
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutOwner.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutOwner.java
index 78bc448..fd8bbbf 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutOwner.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutOwner.java
@@ -22,6 +22,7 @@
 import com.google.common.base.Strings;
 import com.google.gerrit.common.data.GroupDescription;
 import com.google.gerrit.entities.AccountGroup;
+import com.google.gerrit.entities.AccountGroup.UUID;
 import com.google.gerrit.entities.Project;
 import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.common.GroupInfo;
@@ -109,10 +110,11 @@
       db.unset(USER, rsrc.getUser().getUserName().get(), KEY_OWNER);
     } else {
       group = groups.parse(TopLevelResource.INSTANCE, IdString.fromDecoded(input.group)).getGroup();
-      if (!AccountGroup.isInternalGroup(group.getGroupUUID())) {
-        throw new MethodNotAllowedException();
+      UUID groupUUID = group.getGroupUUID();
+      if (!AccountGroup.uuid(groupUUID.get()).isInternalGroup()) {
+        throw new MethodNotAllowedException("Group with UUID '" + groupUUID + "' is external");
       }
-      db.setString(USER, rsrc.getUser().getUserName().get(), KEY_OWNER, group.getGroupUUID().get());
+      db.setString(USER, rsrc.getUser().getUserName().get(), KEY_OWNER, groupUUID.get());
     }
     MetaDataUpdate md = metaDataUpdateFactory.create(allProjects);
     md.setMessage("Set owner for service user '" + rsrc.getUser().getUserName() + "'\n");