Class StagesInterpolator

java.lang.Object
org.restheart.mongodb.utils.StagesInterpolator

public class StagesInterpolator extends Object
Utility class for interpolating aggregation stages with a specified format, e.g., { [operator]: "name"}, and replacing placeholders with provided values. It also supports conditional stages using { "$ifvar": [var] }, which are removed if the variable is missing.
  • Constructor Details

    • StagesInterpolator

      public StagesInterpolator()
  • Method Details

    • interpolate

      public static List<org.bson.BsonDocument> interpolate(VarsInterpolator.VAR_OPERATOR varOperator, StagesInterpolator.STAGE_OPERATOR stageOperator, org.bson.BsonArray stages, org.bson.BsonDocument values) throws InvalidMetadataException, QueryVariableNotBoundException
      Parameters:
      varOperator - the var operator, $var for queries and aggregations, $arg for GraphQL mappings
      stageOperator - the stage operator, $ifvar for aggregations, $ifarg for GraphQL mappings
      stages - the aggregation pipeline stages
      values - RequestContext.getAggregationVars()
      Returns:
      the stages, with unescaped operators and bound variables
      Throws:
      InvalidMetadataException
      QueryVariableNotBoundException
    • shouldNotContainOperators

      public static void shouldNotContainOperators(org.bson.BsonValue values) throws SecurityException
      checks if values contain operators. this is not allowed by default since the client would be able to modify the query or aggregation stages
      Parameters:
      values - RequestContext.getAggregationVars()
      Throws:
      SecurityException
    • injectAvars

      public static void injectAvars(MongoRequest request, org.bson.BsonDocument avars)
      adds the default variables to the avars document Supports accounts handled by MongoRealAuthenticator, FileRealmAuthenticator and JwtAuthenticationMechanism
      Parameters:
      request -
      avars -