private void addGroups()

in src/main/java/com/googlesource/gerrit/plugins/importer/ImportGroup.java [304:335]


  private void addGroups(
      Input input, AccountGroup.Id groupId, String groupName, List<GroupInfo> includedGroups)
      throws NoSuchAccountException, OrmException, IOException, RestApiException,
          ConfigInvalidException {
    List<AccountGroupById> includeList = new ArrayList<>();
    for (GroupInfo includedGroup : includedGroups) {
      if (isInternalGroup(new AccountGroup.UUID(includedGroup.id))) {
        if (getGroupByUUID(includedGroup.id) == null) {
          String includedGroupName = getGroupName(includedGroup.id);
          if (input.importIncludedGroups) {
            importGroupFactory
                .create(new AccountGroup.NameKey(includedGroupName))
                .apply(new ConfigResource(), input);
          } else {
            throw new IllegalStateException(
                String.format(
                    "Cannot include non-existing group %s into group %s.",
                    includedGroupName, groupName));
          }
        }
      }
      AccountGroup.UUID memberUUID = new AccountGroup.UUID(includedGroup.id);
      AccountGroupById groupInclude =
          new AccountGroupById(new AccountGroupById.Key(groupId, memberUUID));
      includeList.add(groupInclude);
    }
    db.accountGroupById().insert(includeList);

    for (GroupInfo member : includedGroups) {
      groupIncludeCache.evictParentGroupsOf(new AccountGroup.UUID(member.id));
    }
  }