private StaticOperand checkFullTextSearchExpression(StaticOperand fullTextSearchExpression) throws RepositoryException { if (fullTextSearchExpression == null) { throw new InvalidQueryException( "fullTextSearchExpression must not be null"); } return fullTextSearchExpression; } }
/** * Create an exception wrapping the given checked JCR exception * * @param cause The wrapped JCR <code>InvalidQueryException</code> */ public InvalidQueryException(javax.jcr.query.InvalidQueryException cause) { super(cause.getMessage(), cause); } }
response.sendError(400, e.getMessage()); e.printStackTrace(response.getWriter()); } catch (final Exception e) { response.sendError(500, e.getMessage());
private static boolean isValidQuery(QueryManager qm, String language, String query) throws RepositoryException { try { qm.createQuery(query, language).execute(); return true; } catch (InvalidQueryException e) { assertTrue(e.toString(), e.toString().indexOf("query without index") >= 0); return false; } }
@Test public void noLiterals() throws RepositoryException { Session session = getAdminSession(); ValueFactory vf = session.getValueFactory(); QueryManager qm = session.getWorkspace().getQueryManager(); // insecure try { Query q = qm.createQuery( "select text from [nt:base] where password = 'x'", Query.JCR_SQL2 + "-noLiterals"); q.execute(); fail(); } catch (InvalidQueryException e) { assertTrue(e.toString(), e.toString().indexOf( "literals of this type not allowed") > 0); } // secure Query q = qm.createQuery( "select text from [nt:base] where password = $p", Query.JCR_SQL2 + "-noLiterals"); q.bindValue("p", vf.createValue("x")); q.execute(); }
private StaticOperand checkFullTextSearchExpression(StaticOperand fullTextSearchExpression) throws RepositoryException { if (fullTextSearchExpression == null) { throw new InvalidQueryException( "fullTextSearchExpression must not be null"); } return fullTextSearchExpression; } }
/** * Create an exception wrapping the given checked JCR exception * * @param cause The wrapped JCR <code>InvalidQueryException</code> */ public InvalidQueryException(javax.jcr.query.InvalidQueryException cause) { super(cause.getMessage(), cause); } }
public Object visit(DerefQueryNode node, Object data) { exceptions.add(new InvalidQueryException("jcr:deref() function not supported in SQL")); return data; }
private static void extractPrototype(final JcrMatcher matcher, final Map<String, Set<String>> types, final QueryManager qmgr, final Node queryTemplate) throws RepositoryException { try { Set<String> prototypes = new TreeSet<>(); if (queryTemplate.isNodeType("nt:query")) { Query query = qmgr.getQuery(queryTemplate); query = qmgr.createQuery(queryTemplate.getProperty("jcr:statement").getString(), query.getLanguage()); // HREPTWO-1266 QueryResult rs = query.execute(); for (NodeIterator iter = rs.getNodes(); iter.hasNext(); ) { Node typeNode = iter.nextNode(); if (typeNode.getName().equals(EssentialConst.HIPPOSYSEDIT_PROTOTYPE)) { String documentType = typeNode.getPrimaryNodeType().getName(); final boolean isTemplate = INTERNAL_TYPES_PREDICATE.apply(documentType); if (isTemplate && (matcher == null || matcher.matches(typeNode))) { prototypes.add(documentType); } } else { prototypes.add(typeNode.getName()); } } } types.put(queryTemplate.getName(), prototypes); } catch (InvalidQueryException ex) { log.error(MessageFormat.format("{0}: {1}", ex.getClass().getName(), ex.getMessage()), ex); } }
public Object visit(DerefQueryNode node, Object data) { exceptions.add(new InvalidQueryException("jcr:deref() function not supported in SQL")); return data; }
private static void extractPrototype(final JcrMatcher matcher, final Map<String, Set<String>> types, final QueryManager qmgr, final Node queryTemplate) throws RepositoryException { try { Set<String> prototypes = new TreeSet<>(); if (queryTemplate.isNodeType("nt:query")) { Query query = qmgr.getQuery(queryTemplate); query = qmgr.createQuery(queryTemplate.getProperty("jcr:statement").getString(), query.getLanguage()); // HREPTWO-1266 QueryResult rs = query.execute(); for (NodeIterator iter = rs.getNodes(); iter.hasNext(); ) { Node typeNode = iter.nextNode(); if (typeNode.getName().equals(EssentialConst.HIPPOSYSEDIT_PROTOTYPE)) { String documentType = typeNode.getPrimaryNodeType().getName(); final boolean isTemplate = INTERNAL_TYPES_PREDICATE.apply(documentType); if (isTemplate && (matcher == null || matcher.matches(typeNode))) { prototypes.add(documentType); } } else { prototypes.add(typeNode.getName()); } } } types.put(queryTemplate.getName(), prototypes); } catch (InvalidQueryException ex) { log.error(MessageFormat.format("{0}: {1}", ex.getClass().getName(), ex.getMessage()), ex); } }
public Object visit(DerefQueryNode node, Object data) { exceptions.add(new InvalidQueryException("jcr:deref() function not supported in SQL")); return data; }
log.error(ex.getClass().getName()+": "+ex.getMessage(), ex);
private InvalidQueryException getSyntaxError(String expected) { int index = Math.min(parseIndex, statement.length() - 1); String query = statement.substring(0, index) + "(*)" + statement.substring(index).trim(); if (expected != null) { query += "; expected: " + expected; } return new InvalidQueryException("Query:\n" + query); }
return new HstQueryResultImpl(this.objectConverter, queryResult, this.hstCtxWhereClauseComputer.getVirtualizer(scopes, this.skipInvalidScopes)); } catch (InvalidQueryException e) { throw new QueryException(e.getMessage(), e); } catch (LoginException e) { log.warn("LoginException. Return null : {}", e);
private InvalidQueryException getSyntaxError(String expected) { int index = Math.min(parseIndex, statement.length() - 1); String query = statement.substring(0, index) + "(*)" + statement.substring(index).trim(); if (expected != null) { query += "; expected: " + expected; } return new InvalidQueryException("Query:\n" + query); }
@Override public HstQueryResult execute() throws QueryException { try { String query = getQuery(); QueryManager jcrQueryManager = getQueryManager(); Query jcrQuery = jcrQueryManager.createQuery(query, "xpath"); if (offset > -1){ jcrQuery.setOffset(offset); } if (limit > -1){ jcrQuery.setLimit(limit); } QueryResult queryResult = jcrQuery.execute(); return new HstQueryResultImpl(objectConverter, queryResult); } catch (InvalidQueryException e) { throw new QueryException(e.getMessage(), e); } catch (LoginException e) { log.warn("LoginException. Return null : {}", e); } catch (RepositoryException e) { throw new QueryException(e.getMessage(), e); } return null; }
private InvalidQueryException getSyntaxError(String expected) { int index = Math.min(parseIndex, statement.length() - 1); String query = statement.substring(0, index) + "(*)" + statement.substring(index).trim(); if (expected != null) { query += "; expected: " + expected; } return new InvalidQueryException("Query:\n" + query); }
throw new QuerySyntaxException(iqe.getMessage(), query, language, iqe); } catch (final RepositoryException re) {
@Override public QueryImpl createQuery(String statement, String language) throws RepositoryException { if (!supportedQueryLanguages.contains(language)) { throw new InvalidQueryException("The specified language is not supported: " + language); } return new QueryImpl(this, statement, language, sessionContext); }