Source:
<code>protected void buildQuery() { List<SortInfo> sort = null; List<QuickFilter> quickFilters = getQuickFilters(); String quickFiltersClause = ""; if (quickFilters != null && !quickFilters.isEmpty()) { sort = new ArrayList<>(); for (int i = 0; i < quickFilters.size(); i++) { if (!quickFiltersClause.isEmpty() && quickFilters.get(i).getClause() != null) { quickFiltersClause += NXQLQueryBuilder.appendClause(quickFiltersClause, quickFilters.get(i).getClause()); } else { quickFiltersClause = quickFilters.get(i).getClause() != null ? quickFilters.get(i).getClause() : ""; } sort.addAll(quickFilters.get(i).getSortInfos()); } } else if (sortInfos != null) { sort = sortInfos; } SortInfo[] sortArray = null; if (sort != null) { sortArray = sort.toArray(new SortInfo[] {}); } String newQuery; PageProviderDefinition def = getDefinition(); if (def.getWhereClause() == null) { String pattern = quickFiltersClause.isEmpty() ? def.getPattern() : NXQLQueryBuilder.appendClause(def.getPattern(), quickFiltersClause); newQuery = NXQLQueryBuilder.getQuery(pattern, getParameters(), def.getQuotePatternParameters(), def.getEscapePatternParameters(), getSearchDocumentModel(), sortArray); } else { if (!quickFiltersClause.isEmpty()) { <START> String fixedPart = def.getWhereClause().getFixedPart(); <END> if (fixedPart != null) { def.getWhereClause().setFixedPart(NXQLQueryBuilder.appendClause(fixedPart, quickFiltersClause)); } else { def.getWhereClause().setFixedPart(quickFiltersClause); } } DocumentModel searchDocumentModel = getSearchDocumentModel(); if (searchDocumentModel == null) { throw new NuxeoException(String.format( "Cannot build query of provider '%s': " + "no search document model is set", getName())); } newQuery = NXQLQueryBuilder.getQuery(searchDocumentModel, def.getWhereClause(), getParameters(), sortArray); } if (query != null && newQuery != null && !newQuery.equals(query)) { refresh(); } query = newQuery; }</code><technical_language>put def.getWhereClause() in a local var</technical_language>

Target:
protected void buildQuery() { List<SortInfo> sort = null; List<QuickFilter> quickFilters = getQuickFilters(); String quickFiltersClause = ""; if (quickFilters != null && !quickFilters.isEmpty()) { sort = new ArrayList<>(); for (QuickFilter quickFilter : quickFilters) { String clause = quickFilter.getClause(); if (!quickFiltersClause.isEmpty() && clause != null) { quickFiltersClause = NXQLQueryBuilder.appendClause(quickFiltersClause, clause); } else { quickFiltersClause = clause != null ? clause : ""; } sort.addAll(quickFilter.getSortInfos()); } } else if (sortInfos != null) { sort = sortInfos; } SortInfo[] sortArray = null; if (sort != null) { sortArray = sort.toArray(new SortInfo[] {}); } String newQuery; PageProviderDefinition def = getDefinition(); WhereClauseDefinition whereClause = def.getWhereClause(); if (whereClause == null) { String originalPattern = def.getPattern(); String pattern = quickFiltersClause.isEmpty() ? originalPattern : StringUtils.containsIgnoreCase(originalPattern, "WHERE") ? NXQLQueryBuilder.appendClause(originalPattern, quickFiltersClause) : originalPattern + " WHERE " + quickFiltersClause; newQuery = NXQLQueryBuilder.getQuery(pattern, getParameters(), def.getQuotePatternParameters(), def.getEscapePatternParameters(), getSearchDocumentModel(), sortArray); } else { if (!quickFiltersClause.isEmpty()) { String fixedPart = whereClause.getFixedPart(); if (fixedPart != null) { whereClause.setFixedPart(NXQLQueryBuilder.appendClause(fixedPart, quickFiltersClause)); } else { whereClause.setFixedPart(quickFiltersClause); } } DocumentModel searchDocumentModel = getSearchDocumentModel(); if (searchDocumentModel == null) { throw new NuxeoException(String.format( "Cannot build query of provider '%s': " + "no search document model is set", getName())); } newQuery = NXQLQueryBuilder.getQuery(searchDocumentModel, whereClause, getParameters(), sortArray); } if (query != null && newQuery != null && !newQuery.equals(query)) { refresh(); } query = newQuery; }