private boolean searchContentForIndex()

in src/main/java/org/apache/sling/testing/clients/indexing/IndexingClient.java [401:436]


    private boolean searchContentForIndex(final String lane, final String uniqueValue)
            throws ClientException, InterruptedException {
        QueryClient queryClient = adaptTo(QueryClient.class);

        for (String query : QUERIES) {
            // prepare the query with the final values
            String indexName = getIndexName(lane);
            String effectiveQuery = replacePlaceholders(query, lane, uniqueValue);

            try {
                // Check query plan to make sure we use the good index
                String plan = queryClient.getPlan(effectiveQuery, QueryClient.QueryType.XPATH);
                if (plan.contains(indexName)) {
                    // The proper index is used, we can check the results
                    long results = queryClient.doCount(effectiveQuery, QueryClient.QueryType.XPATH);
                    if (results > 0) {
                        LOG.debug("Found {} results using query {}", results, effectiveQuery);
                        return true;
                    }
                } else {
                    LOG.debug("Did not find index {} in plan: {}", indexName, plan);
                    LOG.debug("Will try the next query, if available");
                }
            } catch (ClientException e) {
                if (e.getHttpStatusCode() == 400) {
                    LOG.debug("Unsupported query: {}", effectiveQuery);
                    LOG.debug("Will try the next query, if available");
                } else {
                    // We don't continue if there's another problem
                    throw e;
                }
            }
        }
        // No query returned results
        return false;
    }