public Revision getDiscussionRevisionForArticleRevision ( int revisionId ) throws WikiApiException , WikiPageNotFoundException { //get article revision Revision rev = revApi . getRevision ( revisionId ) ; Timestamp revTime = rev . getTimeStamp ( ) ; //get corresponding discussion page Page discussion = wiki . getDiscussionPage ( rev . getArticleID ( ) ) ; /* * find correct revision of discussion page */ List < Timestamp > discussionTs = revApi . getRevisionTimestamps ( discussion . getPageId ( ) ) ; // sort in reverse order - newest first Collections . sort ( discussionTs , new Comparator < Timestamp > ( ) { public int compare ( Timestamp ts1 , Timestamp ts2 ) { return ts2 . compareTo ( ts1 ) ; } } ) ; //find first timestamp equal to or before the article revision timestamp for ( Timestamp curDiscTime : discussionTs ) { if ( curDiscTime == revTime || curDiscTime . before ( revTime ) ) { return revApi . getRevision ( discussion . getPageId ( ) , curDiscTime ) ; } } throw new WikiPageNotFoundException ( "Not discussion page was available at the time of the given article revision" ) ; }
For a given article revision the method returns the revision of the article discussion page which was current at the time the revision was created .