Interface CloseableQueryBuilder


  • @ProviderType
    public interface CloseableQueryBuilder
    A drop-in replacement for the CQ QueryBuilder service that wraps Query instances to produce CloseableQuery instances, whose CloseableQuery.close() method cleans up the internal shallow resource resolver.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void clearFacetCache()
      Clears the QueryBuilder facet cache, in case you need to do that.
      CloseableQuery createQuery​(com.day.cq.search.PredicateGroup predicates, javax.jcr.Session session)
      Create a closeable query around the provided predicate group.
      CloseableQuery createQuery​(com.day.cq.search.PredicateGroup predicates, org.apache.sling.api.resource.ResourceResolver resourceResolver)
      Create a closeable query around the provided predicate group.
      CloseableQuery createQuery​(javax.jcr.Session session)
      Create a closeable query.
      CloseableQuery createQuery​(org.apache.sling.api.resource.ResourceResolver resourceResolver)
      Create a closeable query.
      CloseableQuery loadQuery​(String path, javax.jcr.Session session)
      Load a CQ Search query from a properties file located at the specified path.
      CloseableQuery loadQuery​(String path, org.apache.sling.api.resource.ResourceResolver resourceResolver)
      Load a CQ Search query from a properties file located at the specified path.
      void storeQuery​(com.day.cq.search.Query query, String path, boolean createFile, javax.jcr.Session session)
      Saves the query predicates to a properties file in the repository at the specified path.
      void storeQuery​(com.day.cq.search.Query query, String path, boolean createFile, org.apache.sling.api.resource.ResourceResolver resourceResolver)
      Saves the query predicates to a properties file in the repository at the specified path.
    • Method Detail

      • createQuery

        CloseableQuery createQuery​(com.day.cq.search.PredicateGroup predicates,
                                   org.apache.sling.api.resource.ResourceResolver resourceResolver)
        Create a closeable query around the provided predicate group.
        Parameters:
        predicates - the root group of predicates
        resourceResolver - the session to use
        Returns:
        a closeable query
      • createQuery

        CloseableQuery createQuery​(org.apache.sling.api.resource.ResourceResolver resourceResolver)
        Create a closeable query.
        Parameters:
        resourceResolver - the session to use
        Returns:
        a closeable query
      • createQuery

        CloseableQuery createQuery​(com.day.cq.search.PredicateGroup predicates,
                                   javax.jcr.Session session)
        Create a closeable query around the provided predicate group.
        Parameters:
        predicates - the root group of predicates
        session - the session to use
        Returns:
        a closeable query
      • createQuery

        CloseableQuery createQuery​(javax.jcr.Session session)
        Create a closeable query.
        Parameters:
        session - the session to use
        Returns:
        a closeable query
      • loadQuery

        CloseableQuery loadQuery​(String path,
                                 org.apache.sling.api.resource.ResourceResolver resourceResolver)
                          throws javax.jcr.RepositoryException,
                                 IOException
        Load a CQ Search query from a properties file located at the specified path. If the specified path does not exist, returns null.
        Parameters:
        path - a repository path to a properties file
        resourceResolver - the resource resolver providing access to the repository
        Returns:
        a query ready for execution
        Throws:
        javax.jcr.RepositoryException - on JCR failure
        IOException - on failure to read properties file
      • loadQuery

        CloseableQuery loadQuery​(String path,
                                 javax.jcr.Session session)
                          throws javax.jcr.RepositoryException,
                                 IOException
        Load a CQ Search query from a properties file located at the specified path. If the specified path does not exist, returns null.
        Parameters:
        path - a repository path to a properties file
        session - the session providing access to the repository
        Returns:
        a query ready for execution
        Throws:
        javax.jcr.RepositoryException - on JCR failure
        IOException - on failure to read properties file
      • storeQuery

        void storeQuery​(com.day.cq.search.Query query,
                        String path,
                        boolean createFile,
                        org.apache.sling.api.resource.ResourceResolver resourceResolver)
                 throws javax.jcr.RepositoryException,
                        IOException
        Saves the query predicates to a properties file in the repository at the specified path.
        Parameters:
        query - the query whose predicates should be stored
        path - the path of the properties file
        createFile - true to create the file if it doesn't exist already
        resourceResolver - the session to use
        Throws:
        javax.jcr.RepositoryException - on JCR failure
        IOException - on failure save properties file
      • storeQuery

        void storeQuery​(com.day.cq.search.Query query,
                        String path,
                        boolean createFile,
                        javax.jcr.Session session)
                 throws javax.jcr.RepositoryException,
                        IOException
        Saves the query predicates to a properties file in the repository at the specified path.
        Parameters:
        query - the query whose predicates should be stored
        path - the path of the properties file
        createFile - true to create the file if it doesn't exist already
        session - the session to use
        Throws:
        javax.jcr.RepositoryException - on JCR failure
        IOException - on failure save properties file
      • clearFacetCache

        void clearFacetCache()
        Clears the QueryBuilder facet cache, in case you need to do that.