Package org.restheart.mongodb.utils
Class StagesInterpolator
java.lang.Object
org.restheart.mongodb.utils.StagesInterpolator
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.-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidinjectAvars(MongoRequest request, org.bson.BsonDocument avars) adds the default variables to the avars document Supports accounts handled by MongoRealAuthenticator, FileRealmAuthenticator and JwtAuthenticationMechanismstatic List<org.bson.BsonDocument> interpolate(VarsInterpolator.VAR_OPERATOR varOperator, StagesInterpolator.STAGE_OPERATOR stageOperator, org.bson.BsonArray stages, org.bson.BsonDocument values) static voidshouldNotContainOperators(org.bson.BsonValue values) checks if values contain operators. this is not allowed by default since the client would be able to modify the query or aggregation stages
-
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 mappingsstageOperator- the stage operator, $ifvar for aggregations, $ifarg for GraphQL mappingsstages- the aggregation pipeline stagesvalues- RequestContext.getAggregationVars()- Returns:
- the stages, with unescaped operators and bound variables
- Throws:
InvalidMetadataExceptionQueryVariableNotBoundException
-
shouldNotContainOperators
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
adds the default variables to the avars document Supports accounts handled by MongoRealAuthenticator, FileRealmAuthenticator and JwtAuthenticationMechanism- Parameters:
request-avars-
-