use of org.apache.jackrabbit.oak.api.QueryEngine in project jackrabbit-oak by apache.
the class SuggestionIntervalTest method getSuggestions.
Set<String> getSuggestions(String nodeType, String suggestFor) throws Exception {
Set<String> ret = Sets.newHashSet();
String suggQuery = createSuggestQuery(nodeType, suggestFor);
QueryEngine qe = root.getQueryEngine();
Result result = qe.executeQuery(suggQuery, Query.JCR_SQL2, null, null);
for (ResultRow row : result.getRows()) {
ret.add(row.getValue("suggestion").toString());
}
return ret;
}
use of org.apache.jackrabbit.oak.api.QueryEngine in project jackrabbit-oak by apache.
the class AccessControlManagerImpl method searchAces.
@Nonnull
private static Result searchAces(@Nonnull Set<Principal> principals, @Nonnull Root root) throws RepositoryException {
StringBuilder stmt = new StringBuilder(QueryConstants.SEARCH_ROOT_PATH);
stmt.append("//element(*,");
stmt.append(NT_REP_ACE);
stmt.append(")[");
int i = 0;
for (Principal principal : principals) {
if (i > 0) {
stmt.append(" or ");
}
stmt.append('@');
stmt.append(ISO9075.encode(REP_PRINCIPAL_NAME));
stmt.append("='");
stmt.append(principal.getName().replaceAll("'", "''"));
stmt.append('\'');
i++;
}
stmt.append(']');
stmt.append(" order by jcr:path");
try {
QueryEngine queryEngine = root.getQueryEngine();
return queryEngine.executeQuery(stmt.toString(), Query.XPATH, QueryEngine.NO_BINDINGS, QueryEngine.NO_MAPPINGS);
} catch (ParseException e) {
String msg = "Error while collecting effective policies.";
log.error(msg, e);
throw new RepositoryException(msg, e);
}
}
Aggregations