public RemoteInfo upsert()

in src/main/java/com/googlesource/gerrit/plugins/webhooks/rest/UpsertRemote.java [116:137]


  public RemoteInfo upsert(Project.NameKey project, String remoteName, Input in)
      throws NoSuchProjectException, ConfigInvalidException, IOException, AuthException {
    if (Strings.isNullOrEmpty(in.url)) {
      throw new ConfigInvalidException("url must be specificed");
    }
    if (!permissions.canUpdate(project)) {
      throw new AuthException("not allowed to update webhooks");
    }

    try (MetaDataUpdate md = metaDataUpdateFactory.get().create(project)) {
      WebhooksConfig wh = webhooksConfig.get();
      wh.load(md);
      wh.upsertRemote(remoteName, in);
      wh.commit(md);
    }

    projectCache.evictAndReindex(project);

    Config cfg = configFactory.getProjectPluginConfigWithInheritance(project, pluginName);
    RemoteConfig rc = remoteConfigFactory.create(cfg, remoteName);
    return fromRemoteConfig(rc);
  }