Search in sources :

Example 1 with QueryObjectModelBuilder

use of org.apache.jackrabbit.commons.query.QueryObjectModelBuilder in project jackrabbit by apache.

the class QueryManagerImpl method getQuery.

/**
     * @see QueryManager#getQuery(Node)
     */
public Query getQuery(Node node) throws InvalidQueryException, RepositoryException {
    checkIsAlive();
    NamePathResolver resolver = mgrProvider.getNamePathResolver();
    if (!node.isNodeType(resolver.getJCRName(NameConstants.NT_QUERY))) {
        throw new InvalidQueryException("Node is not of type nt:query");
    }
    if (node.getSession() != session) {
        throw new InvalidQueryException("Node belongs to a different session.");
    }
    String statement = node.getProperty(resolver.getJCRName(NameConstants.JCR_STATEMENT)).getString();
    String language = node.getProperty(resolver.getJCRName(NameConstants.JCR_LANGUAGE)).getString();
    if (Query.JCR_JQOM.equals(language)) {
        QueryObjectModelFactory qomFactory = new QOMFactory(node, resolver);
        QueryObjectModelBuilder builder = QueryObjectModelBuilderRegistry.getQueryObjectModelBuilder(language);
        return builder.createQueryObjectModel(statement, qomFactory, valueFactory);
    } else {
        return new QueryImpl(session, mgrProvider, itemMgr, wspManager, statement, language, node);
    }
}
Also used : NamePathResolver(org.apache.jackrabbit.spi.commons.conversion.NamePathResolver) QueryObjectModelBuilder(org.apache.jackrabbit.commons.query.QueryObjectModelBuilder) QueryObjectModelFactory(javax.jcr.query.qom.QueryObjectModelFactory) InvalidQueryException(javax.jcr.query.InvalidQueryException)

Aggregations

InvalidQueryException (javax.jcr.query.InvalidQueryException)1 QueryObjectModelFactory (javax.jcr.query.qom.QueryObjectModelFactory)1 QueryObjectModelBuilder (org.apache.jackrabbit.commons.query.QueryObjectModelBuilder)1 NamePathResolver (org.apache.jackrabbit.spi.commons.conversion.NamePathResolver)1