public Response apply()

in src/main/java/com/googlesource/gerrit/plugins/serviceuser/GetConfig.java [63:93]


  public Response<ConfigInfo> apply(ConfigResource rsrc) throws PermissionBackendException {
    PluginConfig cfg = cfgFactory.getFromGerritConfig(pluginName);
    ConfigInfo info = new ConfigInfo();
    info.info = Strings.emptyToNull(cfg.getString("infoMessage"));
    info.onSuccess = Strings.emptyToNull(cfg.getString("onSuccessMessage"));
    info.allowEmail = toBoolean(cfg.getBoolean("allowEmail", false));
    info.allowHttpPassword = toBoolean(cfg.getBoolean("allowHttpPassword", false));
    info.allowCustomHttpPassword = toBoolean(cfg.getBoolean("allowCustomHttpPassword", false));
    info.allowOwner = toBoolean(cfg.getBoolean("allowOwner", false));
    info.createNotes = toBoolean(cfg.getBoolean("createNotes", true));
    info.createNotesAsync = toBoolean(cfg.getBoolean("createNotesAsync", false));

    String[] blocked = cfg.getStringList("block");
    Arrays.sort(blocked);
    info.blockedNames = Arrays.asList(blocked);

    String[] groups = cfg.getStringList("group");
    info.groups = new TreeMap<>();
    for (String g : groups) {
      Optional<InternalGroup> group = groupCache.get(AccountGroup.nameKey(g));
      if (group.isPresent()) {
        GroupInfo groupInfo = groupJson.format(new InternalGroupDescription(group.get()));
        groupInfo.name = null;
        info.groups.put(g, groupInfo);
      } else {
        log.warn(String.format("Service user group %s does not exist.", g));
      }
    }

    return Response.ok(info);
  }