Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MODE-1680:

Remove unused commented lines
Add more checks at the parsing stage
  • Loading branch information...
commit 7c4bee89dfa4db620efffa1f4a9126ecf527c533 1 parent 2cd2c19
Oleg Kulikov okulikov authored rhauch committed
30 modeshape-jcr/src/main/java/org/modeshape/jcr/query/xpath/XPathParser.java
@@ -698,6 +698,34 @@ protected OrderBySpec parseOrderBySpec( TokenStream tokens ) {
698 698 }
699 699
700 700 PathExpression path = this.parsePathExpr(tokens);
  701 +
  702 + if (!path.isRelative()) {
  703 + throw new ParsingException(tokens.nextPosition(),
  704 + "Expected either 'jcr:score(tableName)', '@<propertyName>', "
  705 + + "or '<childName>/@<propertyOnChild>' but absolute path was found "
  706 + + tokens.consume());
  707 + }
  708 +
  709 + List<StepExpression> steps = path.getSteps();
  710 + if (steps.size() != 2) {
  711 + throw new ParsingException(tokens.nextPosition(),
  712 + "Expected either 'jcr:score(tableName)', '@<propertyName>', "
  713 + + "or '<childName>/@<propertyOnChild>' but was found "
  714 + + tokens.consume());
  715 + }
  716 +
  717 + if (!(((AxisStep)steps.get(0)).getNodeTest() instanceof NameTest)) {
  718 + throw new ParsingException(tokens.nextPosition(),
  719 + "Expected '<childName>/@<propertyOnChild>' but was found "
  720 + + tokens.consume());
  721 + }
  722 +
  723 + if (!(((AxisStep)steps.get(1)).getNodeTest() instanceof AttributeNameTest)) {
  724 + throw new ParsingException(tokens.nextPosition(),
  725 + "Expected '<childName>/@<propertyOnChild>' but was found "
  726 + + tokens.consume());
  727 + }
  728 +
701 729 Order order = Order.ASCENDING;
702 730 if (tokens.canConsume("ascending")) {
703 731 order = Order.ASCENDING;
@@ -705,8 +733,6 @@ protected OrderBySpec parseOrderBySpec( TokenStream tokens ) {
705 733 order = Order.DESCENDING;
706 734 }
707 735 return new OrderBySpec(order, path);
708   -// throw new ParsingException(tokens.nextPosition(),
709   -// "Expected either 'jcr:score(tableName)' or '@<propertyName>' but found " + tokens.consume());
710 736 }
711 737
712 738 /**
5 modeshape-jcr/src/main/java/org/modeshape/jcr/query/xpath/XPathToQueryTranslator.java
@@ -618,11 +618,6 @@ protected String translatePredicate( Component predicate,
618 618 throw new InvalidQueryException(query, "The 'jcr:like' function requires two parameters; therefore '"
619 619 + predicate + "' is not valid");
620 620 }
621   -// if (!(param1 instanceof AttributeNameTest)) {
622   -// throw new InvalidQueryException(query,
623   -// "The first parameter of 'jcr:like' must be an property reference with the '@' symbol; therefore '"
624   -// + predicate + "' is not valid");
625   -// }
626 621 if (!(param2 instanceof Literal)) {
627 622 throw new InvalidQueryException(query, "The second parameter of 'jcr:like' must be a literal; therefore '"
628 623 + predicate + "' is not valid");

0 comments on commit 7c4bee8

Please sign in to comment.
Something went wrong with that request. Please try again.