Skip to content
Browse files

XWIKI-7568 : Implement mechanism to hide technical content

Minor improvements.
  • Loading branch information...
1 parent 6bee761 commit 29c60069b0b5ba5069c4ffac2932c95b40ebd4ef @jvdrean jvdrean committed
View
5 ...-platform-oldcore/src/main/java/com/xpn/xwiki/store/hibernate/query/HqlQueryExecutor.java
@@ -119,6 +119,11 @@ public void initialize() throws InitializationException
{
org.hibernate.Query hquery = query.isNamed() ? session.getNamedQuery(query.getStatement()) : session
.createQuery(query.getStatement());
+
+ // Since we can't modify the hibernate query statement at this point we need to create a new one to apply the
+ // query filter. This comes with a performance cost, we could fix it by handling named queries ourselves and
+ // not delegate them to hibernate. This way we would always get a statement that we can transform before the
+ // execution.
if (query.getFilter() != null) {
hquery = session.createQuery(query.getFilter().filterStatement(hquery.getQueryString(), Query.HQL));
}
View
11 ...latform-query/xwiki-platform-query-manager/src/main/java/org/xwiki/query/QueryFilter.java
@@ -22,7 +22,10 @@
import org.xwiki.component.annotation.Role;
/**
- * Query Filter interface.
+ * Query Filter interface. A filter can be added to a query through {@link Query#setFilter(QueryFilter)}, it will be
+ * called by the {@link QueryExecutor} before the query is executed. An example of this is the
+ * {@link org.xwiki.query.internal.HiddenDocumentFilter} which transform statements in order to exclude hidden documents
+ * from query results.
*
* @version $Id$
* @since 4.0RC1
@@ -31,9 +34,9 @@
public interface QueryFilter
{
/**
- * @param statement query statement to insert the filter in.
- * @param language language of the query statement.
- * @return the original statement, potentially including a new exclusion clause.
+ * @param statement the query statement to insert the filter in.
+ * @param language the language of the query statement.
+ * @return the original statement, potentially including new conditions.
*/
String filterStatement(String statement, String language);
}
View
2 ...i-platform-query-manager/src/main/java/org/xwiki/query/internal/HiddenDocumentFilter.java
@@ -113,7 +113,7 @@ public String filterStatement(String statement, String language)
}
if (!original.equals(result)) {
- logger.debug("Query [" + original + "] has been transformed into [" + result + "]");
+ logger.debug("Query [{}] has been transformed into [{}]", original, result);
}
return result;

0 comments on commit 29c6006

Please sign in to comment.
Something went wrong with that request. Please try again.