use of com.yahoo.elide.modelconfig.validator.PermissionExpressionVisitor in project elide by yahoo.
the class AggregationDataStore method validateModelExpressionChecks.
/**
* Validates The security Check expression type for both Table and all its fields.
* Table Security Check Condition - User Checks and Filter Expression Checks
* Field Security Check Condition - User Checks
* @param dictionary - Entity Dictionary
* @param clz - Model Type.
*/
private void validateModelExpressionChecks(EntityDictionary dictionary, Type<?> clz) {
PermissionExpressionVisitor visitor = new PermissionExpressionVisitor();
ParseTree parseTree = dictionary.getPermissionsForClass(clz, ReadPermission.class);
if (parseTree != null) {
validateExpression(dictionary, visitor.visit(parseTree), (checkClass) -> UserCheck.class.isAssignableFrom(checkClass) || FilterExpressionCheck.class.isAssignableFrom(checkClass), "Table Can only have User Check and Filter Expression Check." + "Operation Checks Not allowed. given - %s");
}
dictionary.getAllExposedFields(clz).stream().map(field -> dictionary.getPermissionsForField(clz, field, ReadPermission.class)).filter(Objects::nonNull).forEach(tree -> validateExpression(dictionary, visitor.visit(tree), (checkClass) -> UserCheck.class.isAssignableFrom(checkClass), "Fields Can only have User checks. Given - %s"));
}
Aggregations