Author: tmortagne
Date: 2007-12-17 11:26:50 +0100 (Mon, 17 Dec 2007)
New Revision: 6385
Modified:
xwiki-platform/core/branches/xwiki-core-1.2/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java
Log:
XWIKI-1958: XWiki.getVirtualWikisDatabaseNames does not search in main wiki
Modified:
xwiki-platform/core/branches/xwiki-core-1.2/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java
===================================================================
---
xwiki-platform/core/branches/xwiki-core-1.2/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java
2007-12-15 21:27:36 UTC (rev 6384)
+++
xwiki-platform/core/branches/xwiki-core-1.2/xwiki-core/src/main/java/com/xpn/xwiki/XWiki.java
2007-12-17 10:26:50 UTC (rev 6385)
@@ -395,24 +395,37 @@
}
/**
- * @return the full list of all database names of all defined virtual
wikis. The database names are computed from
- * the names of documents having a XWiki.XWikiServerClass object
attached to them by removing the
- * "XWiki.XWikiServer" prefix and making it lower case. For
example a page named
- * "XWiki.XWikiServerMyDatabase" would return "mydatabase" as the
database name.
+ * @return the full list of all database names of all defined virtual
wikis. The database names
+ * are computed from the names of documents having a
XWiki.XWikiServerClass object
+ * attached to them by removing the "XWiki.XWikiServer" prefix and
making it lower case.
+ * For example a page named "XWiki.XWikiServerMyDatabase" would
return "mydatabase" as
+ * the database name.
*/
public List getVirtualWikisDatabaseNames(XWikiContext context) throws
XWikiException
{
List databaseNames = new ArrayList();
- String hql = ", BaseObject as obj, StringProperty as prop where
obj.name=doc.fullName"
- + " and obj.name <> 'XWiki.XWikiServerClassTemplate' and
obj.className='XWiki.XWikiServerClass' "
- + "and prop.id.id = obj.id ";
- List list = getStore().searchDocumentsNames(hql, context);
- for (Iterator it = list.iterator(); it.hasNext();) {
- String docname = (String) it.next();
- if (docname.startsWith("XWiki.XWikiServer")) {
-
databaseNames.add(docname.substring("XWiki.XWikiServer".length()).toLowerCase());
+
+ String database = context.getDatabase();
+ try {
+ context.setDatabase(context.getMainXWiki());
+
+ String hql =
+ ", BaseObject as obj, StringProperty as prop where
obj.name=doc.fullName"
+ + " and obj.name <> 'XWiki.XWikiServerClassTemplate' and
obj.className='XWiki.XWikiServerClass' "
+ + "and prop.id.id = obj.id ";
+ List list = getStore().searchDocumentsNames(hql, context);
+
+ for (Iterator it = list.iterator(); it.hasNext();) {
+ String docname = (String) it.next();
+ if (docname.startsWith("XWiki.XWikiServer")) {
+
databaseNames.add(docname.substring("XWiki.XWikiServer".length())
+ .toLowerCase());
+ }
}
+ } finally {
+ context.setDatabase(database);
}
+
return databaseNames;
}
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications