public Response apply()

in src/main/java/com/googlesource/gerrit/plugins/serviceuser/PutHttpPassword.java [61:86]


  public Response<String> apply(ServiceUserResource rsrc, Input input)
      throws ConfigInvalidException, IOException, PermissionBackendException, RestApiException,
          RuntimeException {
    if (input == null) {
      input = new Input();
    }
    input.httpPassword = Strings.emptyToNull(input.httpPassword);

    ConfigInfo config;
    try {
      config = getConfig.get().apply(new ConfigResource()).value();
    } catch (Exception e) {
      throw asRestApiException("Cannot get configuration", e);
    }

    if ((config.allowHttpPassword == null || !config.allowHttpPassword)) {
      permissionBackend.user(self.get()).check(ADMINISTRATE_SERVER);
    } else if (!input.generate && input.httpPassword != null) {
      if ((config.allowCustomHttpPassword == null || !config.allowCustomHttpPassword)) {
        permissionBackend.user(self.get()).check(ADMINISTRATE_SERVER);
      }
    }

    String newPassword = input.generate ? generate() : input.httpPassword;
    return putHttpPassword.apply(rsrc.getUser(), newPassword);
  }