protected Result executeQuery(String statement, String language, Map<String, PropertyValue> sv) throws ParseException { return qe.executeQuery(statement, language, sv, NO_MAPPINGS); }
if (!root.getQueryEngine().getSupportedQueryLanguages().contains(language)) { throw new IllegalArgumentException("language not supported"); results = root.getQueryEngine().executeQuery(query, language, limit, offset, new HashMap<String, PropertyValue>(), new HashMap<String, String>()); } catch (ParseException e) { throw new RemoteQueryParseException("invalid query", e);
/** * Parse the query and get the bind variable names. * * @param statement the query statement * @param language the query language * @return the bind variable names */ public List<String> parse(String statement, String language) throws InvalidQueryException { try { return queryEngine.getBindVariableNames( statement, language, sessionContext.getSessionLocalMappings()); } catch (ParseException e) { throw new InvalidQueryException(e); } }
@Override public String[] getSupportedQueryLanguages() throws RepositoryException { ArrayList<String> list = new ArrayList<String>(queryEngine.getSupportedQueryLanguages()); // JQOM is supported in this level only (converted to JCR_SQL2) list.add(Query.JCR_JQOM); // create a new instance each time because the array is mutable // (the caller could modify it) return list.toArray(new String[list.size()]); }
@Override public String[] getSupportedQueryLanguages() throws RepositoryException { ArrayList<String> list = new ArrayList<String>(queryEngine.getSupportedQueryLanguages()); // JQOM is supported in this level only (converted to JCR_SQL2) list.add(Query.JCR_JQOM); // create a new instance each time because the array is mutable // (the caller could modify it) return list.toArray(new String[list.size()]); }
return queryEngine.executeQuery( stmt.toString(), Query.XPATH, QueryEngine.NO_BINDINGS, QueryEngine.NO_MAPPINGS);
@Override public String[] getSupportedQueryLanguages() throws RepositoryException { ArrayList<String> list = new ArrayList<String>(queryEngine.getSupportedQueryLanguages()); // JQOM is supported in this level only (converted to JCR_SQL2) list.add(Query.JCR_JQOM); // create a new instance each time because the array is mutable // (the caller could modify it) return list.toArray(new String[list.size()]); }
/** * Parse the query and get the bind variable names. * * @param statement the query statement * @param language the query language * @return the bind variable names */ public List<String> parse(String statement, String language) throws InvalidQueryException { try { return queryEngine.getBindVariableNames( statement, language, sessionContext.getSessionLocalMappings()); } catch (ParseException e) { throw new InvalidQueryException(e); } }
return queryEngine.executeQuery( stmt.toString(), Query.XPATH, QueryEngine.NO_BINDINGS, QueryEngine.NO_MAPPINGS);
public QueryManagerImpl(SessionContext sessionContext) { this.sessionDelegate = sessionContext.getSessionDelegate(); this.sessionContext = sessionContext; qomFactory = new QueryObjectModelFactoryImpl(this, sessionContext); queryEngine = sessionDelegate.getQueryEngine(); supportedQueryLanguages.addAll(queryEngine.getSupportedQueryLanguages()); queryCount = sessionContext.getMeter(QUERY_COUNT); queryDuration = sessionContext.getTimer(QUERY_DURATION); }
/** * Parse the query and get the bind variable names. * * @param statement the query statement * @param language the query language * @return the bind variable names */ public List<String> parse(String statement, String language) throws InvalidQueryException { try { return queryEngine.getBindVariableNames( statement, language, sessionContext.getSessionLocalMappings()); } catch (ParseException e) { throw new InvalidQueryException(e); } }
return queryEngine.executeQuery( stmt.toString(), Query.XPATH, QueryEngine.NO_BINDINGS, QueryEngine.NO_MAPPINGS);
public QueryManagerImpl(SessionContext sessionContext) { this.sessionDelegate = sessionContext.getSessionDelegate(); this.sessionContext = sessionContext; qomFactory = new QueryObjectModelFactoryImpl(this, sessionContext); queryEngine = sessionDelegate.getQueryEngine(); supportedQueryLanguages.addAll(queryEngine.getSupportedQueryLanguages()); queryCount = sessionContext.getMeter(QUERY_COUNT); queryDuration = sessionContext.getTimer(QUERY_DURATION); }
@NotNull private Iterator<Authorizable> findAuthorizables(@NotNull String statement, long limit, long offset, @Nullable AuthorizableType type) throws RepositoryException { try { Result query = root.getQueryEngine().executeQuery( statement, javax.jcr.query.Query.XPATH, limit, offset, NO_BINDINGS, namePathMapper.getSessionLocalMappings()); Iterable<? extends ResultRow> resultRows = query.getRows(); Iterator<Authorizable> authorizables = Iterators.transform(resultRows.iterator(), new ResultRowToAuthorizable(userManager, root, type)); return Iterators.filter(authorizables, new UniqueResultPredicate()); } catch (ParseException e) { log.warn("Invalid user query: " + statement, e); throw new RepositoryException(e); } }
public QueryManagerImpl(SessionContext sessionContext) { this.sessionDelegate = sessionContext.getSessionDelegate(); this.sessionContext = sessionContext; qomFactory = new QueryObjectModelFactoryImpl(this, sessionContext); queryEngine = sessionDelegate.getQueryEngine(); supportedQueryLanguages.addAll(queryEngine.getSupportedQueryLanguages()); queryCount = sessionContext.getMeter(QUERY_COUNT); queryDuration = sessionContext.getTimer(QUERY_DURATION); }
@Nullable Tree getAuthorizableByPrincipal(@NotNull Principal principal) { if (principal instanceof TreeBasedPrincipal) { return root.getTree(((TreeBasedPrincipal) principal).getOakPath()); } // NOTE: in contrast to JR2 the extra shortcut for ID==principalName // can be omitted as principals names are stored in user defined // index as well. try { StringBuilder stmt = new StringBuilder(); stmt.append("SELECT * FROM [").append(UserConstants.NT_REP_AUTHORIZABLE).append(']'); stmt.append(" WHERE [").append(UserConstants.REP_PRINCIPAL_NAME).append("] = $principalName"); stmt.append(QueryEngine.INTERNAL_SQL2_QUERY); Result result = root.getQueryEngine().executeQuery(stmt.toString(), Query.JCR_SQL2, 1, 0, Collections.singletonMap("principalName", PropertyValues.newString(principal.getName())), NO_MAPPINGS); Iterator<? extends ResultRow> rows = result.getRows().iterator(); if (rows.hasNext()) { String path = rows.next().getPath(); return root.getTree(path); } } catch (ParseException ex) { log.error("Failed to retrieve authorizable by principal", ex); } return null; }
@Nullable Tree getAuthorizableByPrincipal(@NotNull Principal principal) { if (principal instanceof TreeBasedPrincipal) { return root.getTree(((TreeBasedPrincipal) principal).getOakPath()); } // NOTE: in contrast to JR2 the extra shortcut for ID==principalName // can be omitted as principals names are stored in user defined // index as well. try { StringBuilder stmt = new StringBuilder(); stmt.append("SELECT * FROM [").append(UserConstants.NT_REP_AUTHORIZABLE).append(']'); stmt.append(" WHERE [").append(UserConstants.REP_PRINCIPAL_NAME).append("] = $principalName"); stmt.append(QueryEngine.INTERNAL_SQL2_QUERY); Result result = root.getQueryEngine().executeQuery(stmt.toString(), Query.JCR_SQL2, 1, 0, Collections.singletonMap("principalName", PropertyValues.newString(principal.getName())), NO_MAPPINGS); Iterator<? extends ResultRow> rows = result.getRows().iterator(); if (rows.hasNext()) { String path = rows.next().getPath(); return root.getTree(path); } } catch (ParseException ex) { log.error("Failed to retrieve authorizable by principal", ex); } return null; }
@NotNull private Iterator<Authorizable> findAuthorizables(@NotNull String statement, long limit, long offset, @Nullable AuthorizableType type) throws RepositoryException { try { Result query = root.getQueryEngine().executeQuery( statement, javax.jcr.query.Query.XPATH, limit, offset, NO_BINDINGS, namePathMapper.getSessionLocalMappings()); Iterable<? extends ResultRow> resultRows = query.getRows(); Iterator<Authorizable> authorizables = Iterators.transform(resultRows.iterator(), new ResultRowToAuthorizable(userManager, root, type)); return Iterators.filter(authorizables, new UniqueResultPredicate()); } catch (ParseException e) { log.warn("Invalid user query: " + statement, e); throw new RepositoryException(e); } }
@Nonnull private Iterator<Authorizable> findAuthorizables(@Nonnull String statement, long limit, long offset, @Nullable AuthorizableType type) throws RepositoryException { try { Result query = root.getQueryEngine().executeQuery( statement, javax.jcr.query.Query.XPATH, limit, offset, NO_BINDINGS, namePathMapper.getSessionLocalMappings()); Iterable<? extends ResultRow> resultRows = query.getRows(); Iterator<Authorizable> authorizables = Iterators.transform(resultRows.iterator(), new ResultRowToAuthorizable(userManager, root, type)); return Iterators.filter(authorizables, new UniqueResultPredicate()); } catch (ParseException e) { log.warn("Invalid user query: " + statement, e); throw new RepositoryException(e); } }
@CheckForNull Tree getAuthorizableByPrincipal(@Nonnull Principal principal) { if (principal instanceof TreeBasedPrincipal) { return root.getTree(((TreeBasedPrincipal) principal).getOakPath()); } // NOTE: in contrast to JR2 the extra shortcut for ID==principalName // can be omitted as principals names are stored in user defined // index as well. try { StringBuilder stmt = new StringBuilder(); stmt.append("SELECT * FROM [").append(UserConstants.NT_REP_AUTHORIZABLE).append(']'); stmt.append(" WHERE [").append(UserConstants.REP_PRINCIPAL_NAME).append("] = $principalName"); stmt.append(QueryEngine.INTERNAL_SQL2_QUERY); Result result = root.getQueryEngine().executeQuery(stmt.toString(), Query.JCR_SQL2, 1, 0, Collections.singletonMap("principalName", PropertyValues.newString(principal.getName())), NO_MAPPINGS); Iterator<? extends ResultRow> rows = result.getRows().iterator(); if (rows.hasNext()) { String path = rows.next().getPath(); return root.getTree(path); } } catch (ParseException ex) { log.error("Failed to retrieve authorizable by principal", ex); } return null; }