@Test public void testQueryFilterWrap2() throws IOException { IndexReader r = getIndexReader(); AccessControlFactory accessControlFactory = new FilterAccessControlFactory(); Collection<String> readAuthorizations = new ArrayList<String>(); Collection<String> discoverAuthorizations = new ArrayList<String>(); Set<String> discoverableFields = new HashSet<String>(Arrays.asList("rowid")); BlurSecureIndexSearcher blurSecureIndexSearcher = new BlurSecureIndexSearcher(r, null, accessControlFactory, readAuthorizations, discoverAuthorizations, discoverableFields, null); Query wrapFilter; Query query = new TermQuery(new Term("a", "b")); Filter filter = new Filter() { @Override public DocIdSet getDocIdSet(AtomicReaderContext context, Bits acceptDocs) throws IOException { throw new RuntimeException("Not implemented."); } }; { Term primeDocTerm = new Term(BlurConstants.PRIME_DOC, BlurConstants.PRIME_DOC_VALUE); ScoreType scoreType = ScoreType.SUPER; SuperQuery superQuery = new SuperQuery(query, scoreType, primeDocTerm); BooleanQuery booleanQuery = new BooleanQuery(); booleanQuery.add(superQuery, Occur.MUST); wrapFilter = blurSecureIndexSearcher.wrapFilter(booleanQuery, filter); System.out.println(wrapFilter); } { assertTrue(wrapFilter instanceof BooleanQuery); BooleanQuery booleanQuery = (BooleanQuery) wrapFilter; assertEquals(1, booleanQuery.clauses().size()); BooleanClause booleanClause = booleanQuery.clauses().get(0); Query innerClause = booleanClause.getQuery(); assertTrue(innerClause instanceof SuperQuery); SuperQuery sq = (SuperQuery) innerClause; Query inner = sq.getQuery(); assertTrue(inner instanceof FilteredQuery); FilteredQuery filteredQuery = (FilteredQuery) inner; Query innerFilteredQuery = filteredQuery.getQuery(); assertEquals(innerFilteredQuery, query); assertTrue(filteredQuery.getFilter() == filter); } }
@Override protected Query wrapFilter(Query query, Filter filter) { if (filter == null) { return query; } else if (query instanceof SuperQuery) { SuperQuery superQuery = (SuperQuery) query; Query innerQuery = superQuery.getQuery(); Term primeDocTerm = superQuery.getPrimeDocTerm(); ScoreType scoreType = superQuery.getScoreType(); return new SuperQuery(wrapFilter(innerQuery, filter), scoreType, primeDocTerm); } else if (query instanceof BooleanQuery) { BooleanQuery booleanQuery = (BooleanQuery) query; List<BooleanClause> clauses = booleanQuery.clauses(); for (BooleanClause booleanClause : clauses) { booleanClause.setQuery(wrapFilter(booleanClause.getQuery(), filter)); } return booleanQuery; } else { return new FilteredQuery(query, filter); } }
BlurSecureIndexSearcher extends SecureIndexSearcher { @Override protected Query wrapFilter(Query query, Filter filter) { if (filter == null) { return query; } else if (query instanceof SuperQuery) { SuperQuery superQuery = (SuperQuery) query; Query innerQuery = superQuery.getQuery(); Term primeDocTerm = superQuery.getPrimeDocTerm(); ScoreType scoreType = superQuery.getScoreType(); return new SuperQuery(wrapFilter(innerQuery, filter), scoreType, primeDocTerm); } else if (query instanceof BooleanQuery) { BooleanQuery booleanQuery = (BooleanQuery) query; List<BooleanClause> clauses = booleanQuery.clauses(); for (BooleanClause booleanClause : clauses) { booleanClause.setQuery(wrapFilter(booleanClause.getQuery(), filter)); } return booleanQuery; } else { return new FilteredQuery(query, filter); } } }
BlurSecureIndexSearcher extends SecureIndexSearcher { @Override protected Query wrapFilter(Query query, Filter filter) { if (filter == null) { return query; } else if (query instanceof SuperQuery) { SuperQuery superQuery = (SuperQuery) query; Query innerQuery = superQuery.getQuery(); Term primeDocTerm = superQuery.getPrimeDocTerm(); ScoreType scoreType = superQuery.getScoreType(); return new SuperQuery(wrapFilter(innerQuery, filter), scoreType, primeDocTerm); } else if (query instanceof BooleanQuery) { BooleanQuery booleanQuery = (BooleanQuery) query; List<BooleanClause> clauses = booleanQuery.clauses(); for (BooleanClause booleanClause : clauses) { booleanClause.setQuery(wrapFilter(booleanClause.getQuery(), filter)); } return booleanQuery; } else { return new FilteredQuery(query, filter); } } BlurSecureIndexSearcher(IndexReader r, ExecutorService executor, AccessControlFactory accessControlFactory,
      Collection<String> readAuthorizations, Collection<String> discoverAuthorizations, Set<String> discoverableFields,
      String defaultReadMaskMessage); }
BlurSecureIndexSearcher extends SecureIndexSearcher { @Override protected Query wrapFilter(Query query, Filter filter) { if (filter == null) { return query; } else if (query instanceof SuperQuery) { SuperQuery superQuery = (SuperQuery) query; Query innerQuery = superQuery.getQuery(); Term primeDocTerm = superQuery.getPrimeDocTerm(); ScoreType scoreType = superQuery.getScoreType(); return new SuperQuery(wrapFilter(innerQuery, filter), scoreType, primeDocTerm); } else if (query instanceof BooleanQuery) { BooleanQuery booleanQuery = (BooleanQuery) query; List<BooleanClause> clauses = booleanQuery.clauses(); for (BooleanClause booleanClause : clauses) { booleanClause.setQuery(wrapFilter(booleanClause.getQuery(), filter)); } return booleanQuery; } else { return new FilteredQuery(query, filter); } } BlurSecureIndexSearcher(IndexReader r, ExecutorService executor, AccessControlFactory accessControlFactory,
      Collection<String> readAuthorizations, Collection<String> discoverAuthorizations, Set<String> discoverableFields,
      String defaultReadMaskMessage);  }
BlurSecureIndexSearcher extends SecureIndexSearcher { @Override protected Query wrapFilter(Query query, Filter filter) { if (filter == null) { return query; } else if (query instanceof SuperQuery) { SuperQuery superQuery = (SuperQuery) query; Query innerQuery = superQuery.getQuery(); Term primeDocTerm = superQuery.getPrimeDocTerm(); ScoreType scoreType = superQuery.getScoreType(); return new SuperQuery(wrapFilter(innerQuery, filter), scoreType, primeDocTerm); } else if (query instanceof BooleanQuery) { BooleanQuery booleanQuery = (BooleanQuery) query; List<BooleanClause> clauses = booleanQuery.clauses(); for (BooleanClause booleanClause : clauses) { booleanClause.setQuery(wrapFilter(booleanClause.getQuery(), filter)); } return booleanQuery; } else { return new FilteredQuery(query, filter); } } BlurSecureIndexSearcher(IndexReader r, ExecutorService executor, AccessControlFactory accessControlFactory,
      Collection<String> readAuthorizations, Collection<String> discoverAuthorizations, Set<String> discoverableFields,
      String defaultReadMaskMessage);   }