public BigQueryRemoteFnResponse process()

in src/main/java/com/google/cloud/solutions/bqremoteencryptionfn/BigQueryFnCallController.java [48:73]


  public BigQueryRemoteFnResponse process(@RequestBody BigQueryRemoteFnRequest request) {
    try {
      var options =
          checkNotNull(request.userDefinedContext(), "userDefinedContext is required. Found null.");
      var callMode = identifyCallMode(options);
      var algo = checkNotNull(options.get(TRANSFORM_ALGO_KEY), "Invalid Algorithm. Found null");

      var transformFn =
          transformFnFactories.stream()
              .filter(factory -> factory.getFnName().equals(algo))
              .findFirst()
              .orElseGet(IdentityTransformFnFactory::new)
              .createFn(options);

      var replies =
          switch (callMode) {
            case DEIDENTIFY -> transformFn.deidentify(request.calls());
            case REIDENTIFY -> transformFn.reidentify(request.calls());
          };

      return BigQueryRemoteFnResponse.withReplies(replies);
    } catch (Exception exp) {
      logger.atInfo().withCause(exp).log("error processing request");
      return BigQueryRemoteFnResponse.withErrorMessage(exp.getMessage());
    }
  }