Search in sources :

Example 1 with QueryEngine

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;
}
Also used : ResultRow(org.apache.jackrabbit.oak.api.ResultRow) QueryEngine(org.apache.jackrabbit.oak.api.QueryEngine) Result(org.apache.jackrabbit.oak.api.Result)

Example 2 with QueryEngine

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);
    }
}
Also used : RepositoryException(javax.jcr.RepositoryException) QueryEngine(org.apache.jackrabbit.oak.api.QueryEngine) ParseException(java.text.ParseException) ItemBasedPrincipal(org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal) Principal(java.security.Principal) Nonnull(javax.annotation.Nonnull)

Aggregations

QueryEngine (org.apache.jackrabbit.oak.api.QueryEngine)2 Principal (java.security.Principal)1 ParseException (java.text.ParseException)1 Nonnull (javax.annotation.Nonnull)1 RepositoryException (javax.jcr.RepositoryException)1 ItemBasedPrincipal (org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal)1 Result (org.apache.jackrabbit.oak.api.Result)1 ResultRow (org.apache.jackrabbit.oak.api.ResultRow)1