Re: [xwiki-devs] [xwiki-notifications] r7914 - xwiki-platform/xwiki-plugins/trunk/watchlist/src/main/java/com/xpn/xwiki/plugin/watchlist
Hi JV, On Feb 22, 2008, at 12:07 PM, jvdrean (SVN) wrote:
Author: jvdrean Date: 2008-02-22 12:07:00 +0100 (Fri, 22 Feb 2008) New Revision: 7914
Modified: xwiki-platform/xwiki-plugins/trunk/watchlist/src/main/java/com/xpn/ xwiki/plugin/watchlist/WatchListJob.java xwiki-platform/xwiki-plugins/trunk/watchlist/src/main/java/com/xpn/ xwiki/plugin/watchlist/WatchListPlugin.java xwiki-platform/xwiki-plugins/trunk/watchlist/src/main/java/com/xpn/ xwiki/plugin/watchlist/WatchListPluginApi.java Log: XPWATCHLIST-12 : Global user can't watch sub-wiki's documents
[snip]
+ /** + * @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(Context context, XWiki xwiki) throws XWikiException + { + List databaseNames = new ArrayList(); + + String database = context.getDatabase(); + try { + context.setDatabase(context.getMainWikiName()); + + 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 = xwiki.searchDocuments(hql); + + 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; + }
This method looks like a duplicate of the code in the XWiki class. Why is that? Thanks -Vincent
This method looks like a duplicate of the code in the XWiki class. Why is that?
Yes this is a duplicate, the problem here is that WatchListJob gets a wrapped context and getVirtualWikisDatabaseNames isn't accessible from api.XWiki. IMHO the underlying problem is that jobs don't get an unwrapped context and it'll have to be fixed, I've prefered to duplicate this method in the plugin instead of adding a new method to api.XWiki, please tell me if I was wrong. JV.
On Feb 24, 2008, at 1:26 PM, Jean-Vincent Drean wrote:
This method looks like a duplicate of the code in the XWiki class. Why is that?
Yes this is a duplicate, the problem here is that WatchListJob gets a wrapped context and getVirtualWikisDatabaseNames isn't accessible from api.XWiki.
Well in that case why not propose to put it in the API? In any case we must not have duplications so we need a solution.
IMHO the underlying problem is that jobs don't get an unwrapped context and it'll have to be fixed,
I agree. Why not fix this then? :)
I've prefered to duplicate this method in the plugin instead of adding a new method to api.XWiki, please tell me if I was wrong.
Duplication is evil :) I don't see why we shouldn't have it in the API for users having admin rights. Under what user is the scheduler executed? In any case that user should probably have admin rights so it should be ok. WDYT? Thanks -Vincent
On Sun, Feb 24, 2008 at 2:44 PM, Vincent Massol <[email protected]> wrote:
On Feb 24, 2008, at 1:26 PM, Jean-Vincent Drean wrote:
This method looks like a duplicate of the code in the XWiki class. Why is that?
Yes this is a duplicate, the problem here is that WatchListJob gets a wrapped context and getVirtualWikisDatabaseNames isn't accessible from api.XWiki.
Well in that case why not propose to put it in the API? In any case we must not have duplications so we need a solution.
IMHO the underlying problem is that jobs don't get an unwrapped context and it'll have to be fixed,
I agree. Why not fix this then? :)
Ok done in 7932.
I've prefered to duplicate this method in the plugin instead of adding a new method to api.XWiki, please tell me if I was wrong.
Duplication is evil :)
Duplication removed in r7933. JV.
participants (2)
-
Jean-Vincent Drean -
Vincent Massol