Title | Request Rpc Handler Get Recent Changes To Take Null Date |
Date | 15-Oct-2005 15:57:42 EEST |
Version | 2.2.x |
Submitter | ChrisWilson |
Bug criticality | EnhancementRequest |
Browser version | |
Bug status | NewBug |
PageProvider used | |
Servlet Container | |
Operating System | |
URL | |
Java version |
I'm writing a Wiki synchroniser that uses the XML-RPC interface, and I need to get the metadata about all pages on each side to see which ones have changed.
Right now I need to first get a list of all page names, then enumerate over them requesting getPageInfo for each one. This is slow (takes about 3 minutes for a 1300-page wiki).
I noticed that getRecentChanges returns a Hashtable about each page, with almost all the info I need, but I can't pass a null Date to get a list of absolutely all pages.
I refactored the code a little to get this:
public Vector getRecentChanges( Date since ) { Collection pages = m_engine.getRecentChanges(); Vector result = new Vector(); if (since != null) { Calendar cal = Calendar.getInstance(); cal.setTime( since ); // // Convert UTC to our time. // cal.add( Calendar.MILLISECOND, cal.get( Calendar.ZONE_OFFSET )); if (cal.getTimeZone().inDaylightTime(since)) { cal.add( Calendar.MILLISECOND, cal.get( Calendar.DST_OFFSET )); } since = cal.getTime(); } for( Iterator i = pages.iterator(); i.hasNext(); ) { WikiPage page = (WikiPage)i.next(); if (page instanceof Attachment) { continue; } if (since == null || page.getLastModified().after( since )) { result.add( encodeWikiPage( page ) ); } } return result; }
which is also easier to read. Might I suggest supporting this in a future version?
Also, it would be really handy to have the page size in the Hashtable. Because I don't want to accidentally permanently delete a page from the wiki, I treat zero-size pages as deleted, and delete a page by removing all the contents (which at least is versioned). However, until JSPWiki's XML-RPC interface supports retrieving the page size separately, I will have to download each page to see if it's empty or not (and if you think 3 minutes is bad... :-)
I added this code to the RPCHandler:
ht.put( "lastModified", cal.getTime() ); ht.put( "version", new Integer(page.getVersion()) ); ht.put( "size", new Long(page.getSize()) );
and I'm working on the equivalent code in Mahlen's client.
Cheers, Chris Wilson.
This one is 17 months old, is this still relevant ? What do we do with this ?
--HarryMetske, 21-Mar-2007
Let me think. I was going to make some tweaks to the XML-RPC code anyway.
--JanneJalkanen, 22-Mar-2007