System.currentTimeMillis() - timeAtStart);
}
// write:
// get previous categories, templates and backlinks:
final MyWikiModel wikiModel = new MyWikiModel("", "", new MyNamespace(siteinfo));
wikiModel.setPageName(title0);
Set<String> oldCats;
Set<String> oldTpls;
Set<String> oldLnks;
if (oldRevId != -1 && oldPage != null && oldPage.getCurRev() != null) {
// get a list of previous categories and templates:
wikiModel.setUp();
final long timeAtRenderStart = System.currentTimeMillis();
wikiModel.render(null, oldPage.getCurRev().unpackedText());
timeAtStart -= (System.currentTimeMillis() - timeAtRenderStart);
// note: no need to normalise the pages, we will do so during the write/read key generation
oldCats = wikiModel.getCategories().keySet();
oldTpls = wikiModel.getTemplates();
if (Options.WIKI_USE_BACKLINKS) {
oldLnks = wikiModel.getLinks();
} else {
// use empty link lists to turn back-links off
oldLnks = new HashSet<String>();
}
wikiModel.tearDown();
} else {
oldCats = new HashSet<String>();
oldTpls = new HashSet<String>();
oldLnks = new HashSet<String>();
}
// get new categories and templates
wikiModel.setUp();
do {
final long timeAtRenderStart = System.currentTimeMillis();
wikiModel.render(null, newRev.unpackedText());
timeAtStart -= (System.currentTimeMillis() - timeAtRenderStart);
} while (false);
if (wikiModel.getRedirectLink() != null) {
newPage.setRedirect(true);
}
if (restrictions != null) {
newPage.setRestrictions(restrictions);
}
// note: do not tear down the wiki model - the following statements
// still need it and it will be removed at the end of the method anyway
// note: no need to normalise the pages, we will do so during the write/read key generation
final Set<String> newCats = wikiModel.getCategories().keySet();
Difference catDiff = new Difference(oldCats, newCats,
new Difference.GetPageListAndCountKey() {
@Override
public String getPageListKey(String name) {
return getCatPageListKey(
wikiModel.getCategoryNamespace() + ":" + name,
nsObject);
}
@Override
public String getPageCountKey(String name) {
return getCatPageCountKey(
wikiModel.getCategoryNamespace() + ":" + name,
nsObject);
}
});
final Set<String> newTpls = wikiModel.getTemplates();
Difference tplDiff = new Difference(oldTpls, newTpls,
new Difference.GetPageListKey() {
@Override
public String getPageListKey(String name) {
return getTplPageListKey(
wikiModel.getTemplateNamespace() + ":" + name,
nsObject);
}
});
// use empty link lists to turn back-links off
final Set<String> newLnks = Options.WIKI_USE_BACKLINKS ? wikiModel.getLinks() : new HashSet<String>();
Difference lnkDiff = new Difference(oldLnks, newLnks,
new Difference.GetPageListKey() {
@Override
public String getPageListKey(String name) {
return getBackLinksPageListKey(name, nsObject);