Permalink
Browse files

MODE-1680:

Remove unused commented lines
Add more checks at the parsing stage
  • Loading branch information...
1 parent 2cd2c19 commit 7c4bee89dfa4db620efffa1f4a9126ecf527c533 @okulikov okulikov committed with rhauch Mar 11, 2013
@@ -698,15 +698,41 @@ protected OrderBySpec parseOrderBySpec( TokenStream tokens ) {
}
PathExpression path = this.parsePathExpr(tokens);
+
+ if (!path.isRelative()) {
+ throw new ParsingException(tokens.nextPosition(),
+ "Expected either 'jcr:score(tableName)', '@<propertyName>', "
+ + "or '<childName>/@<propertyOnChild>' but absolute path was found "
+ + tokens.consume());
+ }
+
+ List<StepExpression> steps = path.getSteps();
+ if (steps.size() != 2) {
+ throw new ParsingException(tokens.nextPosition(),
+ "Expected either 'jcr:score(tableName)', '@<propertyName>', "
+ + "or '<childName>/@<propertyOnChild>' but was found "
+ + tokens.consume());
+ }
+
+ if (!(((AxisStep)steps.get(0)).getNodeTest() instanceof NameTest)) {
+ throw new ParsingException(tokens.nextPosition(),
+ "Expected '<childName>/@<propertyOnChild>' but was found "
+ + tokens.consume());
+ }
+
+ if (!(((AxisStep)steps.get(1)).getNodeTest() instanceof AttributeNameTest)) {
+ throw new ParsingException(tokens.nextPosition(),
+ "Expected '<childName>/@<propertyOnChild>' but was found "
+ + tokens.consume());
+ }
+
Order order = Order.ASCENDING;
if (tokens.canConsume("ascending")) {
order = Order.ASCENDING;
} else if (tokens.canConsume("descending")) {
order = Order.DESCENDING;
}
return new OrderBySpec(order, path);
-// throw new ParsingException(tokens.nextPosition(),
-// "Expected either 'jcr:score(tableName)' or '@<propertyName>' but found " + tokens.consume());
}
/**
@@ -618,11 +618,6 @@ protected String translatePredicate( Component predicate,
throw new InvalidQueryException(query, "The 'jcr:like' function requires two parameters; therefore '"
+ predicate + "' is not valid");
}
-// if (!(param1 instanceof AttributeNameTest)) {
-// throw new InvalidQueryException(query,
-// "The first parameter of 'jcr:like' must be an property reference with the '@' symbol; therefore '"
-// + predicate + "' is not valid");
-// }
if (!(param2 instanceof Literal)) {
throw new InvalidQueryException(query, "The second parameter of 'jcr:like' must be a literal; therefore '"
+ predicate + "' is not valid");

0 comments on commit 7c4bee8

Please sign in to comment.