Package javax.jcr.query

Examples of javax.jcr.query.InvalidQueryException


                sb.append(" IS NULL");
            } else if (node.getOperation() == OPERATION_NOT_NULL) {
                appendName(node.getProperty(), resolver, sb);
                sb.append(" IS NOT NULL");
            } else {
                exceptions.add(new InvalidQueryException("Invalid operation: " + node.getOperation()));
            }

            if (node.getOperation() == OPERATION_LIKE && node.getStringValue().indexOf('\\') > -1) {
                sb.append(" ESCAPE '\\'");
            }
View Full Code Here


        } else if (node.getValueType() == TYPE_DATE || node.getValueType() == TYPE_TIMESTAMP) {
            Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
            cal.setTime(node.getDateValue());
            b.append("TIMESTAMP '").append(ISO8601.format(cal)).append("'");
        } else {
            exceptions.add(new InvalidQueryException("Invalid type: " + node.getValueType()));
        }

    }
View Full Code Here

                // path is 1) relative or 2) descendant-or-self
                // use root node as context
                context = new TermQuery(new Term(FieldNames.PARENT, ""));
            }
        } else {
            exceptions.add(new InvalidQueryException("Number of location steps must be > 0"));
        }
        // loop over steps
        for (int i = 0; i < steps.length; i++) {
            context = (Query) steps[i].accept(this, context);
        }
View Full Code Here

                throw new IllegalArgumentException("Unknown relation type: "
                        + node.getValueType());
        }

        if (node.getProperty() == null) {
            exceptions.add(new InvalidQueryException("@* not supported in predicate"));
            return data;
        }

        String field = "";
        try {
View Full Code Here

     */
    public Query getQuery(Node node)
            throws InvalidQueryException, RepositoryException {
        sanityCheck();
        if (!node.isNodeType(session.getJCRName(NameConstants.NT_QUERY))) {
            throw new InvalidQueryException("node is not of type nt:query");
        }
        String statement = node.getProperty(session.getJCRName(NameConstants.JCR_STATEMENT)).getString();
        String language = node.getProperty(session.getJCRName(NameConstants.JCR_LANGUAGE)).getString();

        QueryFactory qf = new QueryFactoryImpl(node, language);
View Full Code Here

        String sub = statement.substring(start, i);
        BigDecimal bd;
        try {
            bd = new BigDecimal(sub);
        } catch (NumberFormatException e) {
            throw new InvalidQueryException("Data conversion error converting " + sub + " to BigDecimal: " + e);
        }
        checkLiterals(false);

        currentValue = valueFactory.createValue(bd);
        currentTokenType = VALUE;
View Full Code Here

        int index = Math.min(parseIndex, statement.length() - 1);
        String query = statement.substring(0, index) + "(*)" + statement.substring(index).trim();
        if (expected != null) {
            query += "; expected: " + expected;
        }
        return new InvalidQueryException("Query:\n" + query);
    }
View Full Code Here

                // path is 1) relative or 2) descendant-or-self
                // use root node as context
                context = new JackrabbitTermQuery(new Term(FieldNames.PARENT, ""));
            }
        } else {
            exceptions.add(new InvalidQueryException("Number of location steps must be > 0"));
        }
        // loop over steps
        for (int i = 0; i < steps.length; i++) {
            context = (Query) steps[i].accept(this, context);
        }
View Full Code Here

    public Object visit(RelationQueryNode node, Object data) throws RepositoryException {
        PathQueryNode relPath = node.getRelativePath();
        if (relPath == null
                && node.getOperation() != QueryConstants.OPERATION_SIMILAR
                && node.getOperation() != QueryConstants.OPERATION_SPELLCHECK) {
            exceptions.add(new InvalidQueryException("@* not supported in predicate"));
            return data;
        }
        LocationStepQueryNode[] steps = relPath.getPathSteps();
        Name propertyName = steps[steps.length - 1].getNameTest();
       
        Query query;
        String[] stringValues = new String[1];
        switch (node.getValueType()) {
            case 0:
                // not set: either IS NULL or IS NOT NULL
                break;
            case QueryConstants.TYPE_DATE:
                stringValues[0] = DateField.dateToString(node.getDateValue());
                break;
            case QueryConstants.TYPE_DOUBLE:
                stringValues[0] = DoubleField.doubleToString(node.getDoubleValue());
                break;
            case QueryConstants.TYPE_LONG:
                stringValues[0] = LongField.longToString(node.getLongValue());
                break;
            case QueryConstants.TYPE_STRING:
                if (node.getOperation() == QueryConstants.OPERATION_EQ_GENERAL
                        || node.getOperation() == QueryConstants.OPERATION_EQ_VALUE
                        || node.getOperation() == QueryConstants.OPERATION_NE_GENERAL
                        || node.getOperation() == QueryConstants.OPERATION_NE_VALUE) {
                    // only use coercing on non-range operations
                    stringValues = getStringValues(propertyName, node.getStringValue());
                } else {
                    stringValues[0] = node.getStringValue();
                }
                break;
            case QueryConstants.TYPE_POSITION:
                // ignore position. is handled in the location step
                return null;
            default:
                throw new IllegalArgumentException("Unknown relation type: "
                        + node.getValueType());
        }

        // get property transformation
        final int[] transform = new int[]{TransformConstants.TRANSFORM_NONE};
        node.acceptOperands(new DefaultQueryNodeVisitor() {
            public Object visit(PropertyFunctionQueryNode node, Object data) {
                if (node.getFunctionName().equals(PropertyFunctionQueryNode.LOWER_CASE)) {
                    transform[0] = TransformConstants.TRANSFORM_LOWER_CASE;
                } else if (node.getFunctionName().equals(PropertyFunctionQueryNode.UPPER_CASE)) {
                    transform[0] = TransformConstants.TRANSFORM_UPPER_CASE;
                }
                return data;
            }
        }, null);

        if (node.getOperation() == QueryConstants.OPERATION_SIMILAR) {
            // this is a bit ugly:
            // use the name of a dummy property because relPath actually
            // references a property. whereas the relPath of the similar
            // operation references a node
            propertyName = NameConstants.JCR_PRIMARYTYPE;
        }
        String field = "";
        try {
            field = resolver.getJCRName(propertyName);
        } catch (NamespaceException e) {
            // should never happen
            exceptions.add(e);
        }

        // support for fn:name()
        if (propertyName.getNamespaceURI().equals(SearchManager.NS_FN_URI)
                && propertyName.getLocalName().equals("name()")) {
            if (node.getValueType() != QueryConstants.TYPE_STRING) {
                exceptions.add(new InvalidQueryException("Name function can "
                        + "only be used in conjunction with a string literal"));
                return data;
            }
            if (node.getOperation() != QueryConstants.OPERATION_EQ_VALUE
                    && node.getOperation() != QueryConstants.OPERATION_EQ_GENERAL) {
                exceptions.add(new InvalidQueryException("Name function can "
                        + "only be used in conjunction with an equals operator"));
                return data;
            }
            // check if string literal is a valid XML Name
            if (XMLChar.isValidName(node.getStringValue())) {
View Full Code Here

            throws RepositoryException {
        this.resolver = resolver;
        statement = root.accept(this, new StringBuffer()).toString();
        if (exceptions.size() > 0) {
            Exception e = (Exception) exceptions.get(0);
            throw new InvalidQueryException(e.getMessage(), e);
        }
    }
View Full Code Here

TOP

Related Classes of javax.jcr.query.InvalidQueryException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.