Author: tmortagne
Date: 2008-02-22 17:08:43 +0100 (Fri, 22 Feb 2008)
New Revision: 7919

Modified:
   
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/api/XWiki.java
Log:
XWIKI-2144: Can't search in another wiki without programming rights

Modified: 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/api/XWiki.java
===================================================================
--- 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/api/XWiki.java 
    2008-02-22 15:36:57 UTC (rev 7918)
+++ 
xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/api/XWiki.java 
    2008-02-22 16:08:43 UTC (rev 7919)
@@ -437,7 +437,7 @@
      * Search documents by passing HQL where clause values as parameters. This 
allows generating
      * a Named HQL query which will automatically encode the passed values 
(like escaping single
      * quotes). This API is recommended to be used over the other similar 
methods where the values
-     * are passed inside the where clause and for which you'll need to do the 
encoding/escpaing
+     * are passed inside the where clause and for which you'll need to do the 
encoding/escaping
      * yourself before calling them.
      *
      * <p>Example</p>
@@ -475,6 +475,34 @@
     }
 
     /**
+     * Search documents in the provided by passing HQL where clause values as 
parameters. See
+     * [EMAIL PROTECTED] #searchDocuments(String, int, int, java.util.List)} 
for more details.
+     * 
+     * @param wikiName the name of the wiki where to search.
+     * @param parametrizedSqlClause the HQL where clause. For example <code>" 
where doc.fullName
+     *        <> ? and (doc.parent = ? or (doc.parent = ? and doc.web = 
?))"</code>
+     * @param nb the number of rows to return. If 0 then all rows are returned
+     * @param start the number of rows to skip. If 0 don't skip any row
+     * @param parameterValues the where clause values that replace the 
question marks (?)
+     * @return a list of document full names (Space.Name).
+     * @see #searchDocuments(String, int, int, java.util.List)
+     * @throws XWikiException in case of error while performing the query
+     */
+    public List searchDocumentsNames(String wikiName, String 
parametrizedSqlClause, int nb,
+        int start, List parameterValues) throws XWikiException
+    {
+        String database = this.context.getDatabase();
+
+        try {
+            context.setDatabase(wikiName);
+
+            return searchDocuments(parametrizedSqlClause, nb, start, 
parameterValues);
+        } finally {
+            context.setDatabase(database);
+        }
+    }
+    
+    /**
      * Function to wrap a list of XWikiDocument into Document objects
      * 
      * @param docs list of XWikiDocument

_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to