public Response apply()

in src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutConfig.java [72:111]


  public Response<String> apply(ConfigResource rsrc, Input input)
      throws IOException, ConfigInvalidException, UnprocessableEntityException {
    FileBasedConfig cfg = new FileBasedConfig(sitePaths.gerrit_config.toFile(), FS.DETECTED);
    cfg.load();
    if (input.info != null) {
      cfg.setString("plugin", pluginName, "infoMessage", Strings.emptyToNull(input.info));
    }
    if (input.onSuccess != null) {
      cfg.setString("plugin", pluginName, "onSuccessMessage", Strings.emptyToNull(input.onSuccess));
    }
    if (input.allowEmail != null) {
      setBoolean(cfg, "allowEmail", input.allowEmail);
    }
    if (input.allowHttpPassword != null) {
      setBoolean(cfg, "allowHttpPassword", input.allowHttpPassword);
    }
    if (input.allowOwner != null) {
      setBoolean(cfg, "allowOwner", input.allowOwner);
    }
    if (input.createNotes != null) {
      setBoolean(cfg, "createNotes", input.createNotes, true);
    }
    if (input.createNotesAsync != null) {
      setBoolean(cfg, "createNotesAsync", input.createNotesAsync);
    }
    if (input.blockedNames != null) {
      cfg.setStringList("plugin", pluginName, "block", input.blockedNames);
    }
    if (input.groups != null) {
      for (String g : input.groups) {
        if (groupCache.get(AccountGroup.nameKey(g)) == null) {
          throw new UnprocessableEntityException(String.format("Group %s does not exist.", g));
        }
      }
      cfg.setStringList("plugin", pluginName, "group", input.groups);
    }
    cfg.save();
    cfgFactory.getFromGerritConfig(pluginName, true);
    return Response.<String>ok("OK");
  }