Filter out inactive accounts in OWNERS

When an existing but inactive account is specified
in the OWNERS file, filter it out beforehand so that
the add reviewers API won't fail afterwards.

Change-Id: I7c6c7c87a213c406f054a944ff746cf460d12c1c
diff --git a/owners-common/src/main/java/com/vmware/gerrit/owners/common/AccountsImpl.java b/owners-common/src/main/java/com/vmware/gerrit/owners/common/AccountsImpl.java
index 429f7b8..212536e 100644
--- a/owners-common/src/main/java/com/vmware/gerrit/owners/common/AccountsImpl.java
+++ b/owners-common/src/main/java/com/vmware/gerrit/owners/common/AccountsImpl.java
@@ -105,8 +105,19 @@
         return accountIds;
       }
 
+      Set<Id> activeAccountIds =
+          accountIds.stream().filter(this::isActive).collect(Collectors.toSet());
+      if (activeAccountIds.isEmpty()) {
+        log.warn(
+            "User '{}' resolves to {} accounts {}, but none of them are active",
+            nameOrEmail,
+            accountIds.size(),
+            accountIds);
+        return activeAccountIds;
+      }
+
       Set<Id> fulllyMatchedAccountIds =
-          accountIds
+          activeAccountIds
               .stream()
               .filter(id -> isFullMatch(id, nameOrEmail))
               .collect(Collectors.toSet());
@@ -155,6 +166,10 @@
         .isPresent();
   }
 
+  private boolean isActive(Account.Id accountId) {
+    return byId.get(accountId).getAccount().isActive();
+  }
+
   private Optional<String> keySchemeRest(String scheme, ExternalId.Key key) {
     if (scheme != null && key.isScheme(scheme)) {
       return Optional.of(key.get().substring(scheme.length() + 1));