code: private void extractTemplates() throws WikiApiException
  	{
  		PageIterator pageIter = new PageIterator(getWiki(), true, pageBuffer);
  		RevisionApi revApi = new RevisionApi(dbConf);
  
  		int pageCounter = 0;
  		long revisionCounter =0L;
  
  		while (pageIter.hasNext()) {
  			pageCounter++;
  
  			if (pageCounter % VERBOSITY == 0) {
  				logger.info( "{} pages processed ...", pageCounter);
  			}
  
  			Page curPage = pageIter.next();
  			int curPageId = curPage.getPageId();
  
  
  			//PROCESS PAGES
  			if (mode.active_for_pages) {
  				fillMapWithTemplateData(curPage.getText(), pageFilter, curPageId,
  						TPLNAME_TO_PAGEIDS);
  			}
  
  			//PROCESS REVISIONS
  			if (mode.active_for_revisions) {
  				List<Timestamp> tsList = revApi.getRevisionTimestamps(curPageId);
  				for(Timestamp ts:tsList){
  
  					revisionCounter++;
  					if (revisionCounter % (VERBOSITY*10) == 0) {
  						logger.info("{} revisions processed ...", revisionCounter);
  					}
  
  					Revision curRevision = revApi.getRevision(curPageId, ts);
  					int curRevisionId = curRevision.getRevisionID();
  
  					fillMapWithTemplateData(curRevision.getRevisionText(),
  							revisionFilter, curRevisionId, TPLNAME_TO_REVISIONIDS);
  				}
  			}
  		}
  	}
docs: Extracts templates from pages and revisions