use of com.netflix.metacat.common.server.partition.parser.TokenMgrError in project metacat by Netflix.
the class FilterPartition method evaluatePartitionExpression.
/**
* Evaluates the given expression.
* @param partitionExpression expression
* @param name name
* @param path partition uri path
* @param batchid batch id
* @param values map of values
* @return true if the expression evaluates to true
*/
public boolean evaluatePartitionExpression(final String partitionExpression, final String name, final String path, final boolean batchid, final Map<String, String> values) {
if (partitionExpression != null) {
try {
if (parser == null) {
parser = new PartitionParser(new StringReader(partitionExpression));
} else {
parser.ReInit(new StringReader(partitionExpression));
}
context.clear();
if (batchid) {
PartitionUtil.getPartitionKeyValues(path, context);
}
PartitionUtil.getPartitionKeyValues(name, context);
if (values != null) {
context.putAll(values);
}
if (context.size() > 0) {
return (Boolean) parser.filter().jjtAccept(new PartitionParserEval(context), null);
} else {
return false;
}
} catch (ParseException | TokenMgrError e) {
throw new IllegalArgumentException(String.format("Invalid expression: %s", partitionExpression), e);
} catch (IllegalArgumentException e) {
throw e;
} catch (Throwable t) {
log.warn("Caught unexpected exception during evaluatePartitionExpression,", t);
return false;
}
}
return true;
}
Aggregations