@Override
public Object construct() {
try {
CheckWiki checkWiki = APIFactory.getCheckWiki();
MediaWiki mw = MediaWiki.getMediaWikiAccess(this);
EnumWikipedia wiki = getWikipedia();
StringBuilder result = new StringBuilder();
StringBuilder details = new StringBuilder();
List<CheckErrorAlgorithm> algorithms = CheckErrorAlgorithms.getAlgorithms(wiki);
for (CheckErrorAlgorithm algorithm : algorithms) {
int errorNumber = algorithm.getErrorNumber();
if (algorithm.isAvailable() &&
CheckErrorAlgorithms.isAlgorithmActive(wiki, errorNumber)) {
setText(GT._("Checking whitelist for error {0}", String.valueOf(errorNumber)));
CWConfigurationError cwConfig = wiki.getCWConfiguration().getErrorConfiguration(errorNumber);
Set<String> whiteList = cwConfig.getWhiteList();
if (whiteList != null) {
details.setLength(0);
if (whiteList.size() > 0) {
List<Page> pages = new ArrayList<Page>(whiteList.size());
for (String pageName : whiteList) {
Page page = DataManager.getPage(wiki, pageName, null, null, null);
pages.add(page);
}
Collections.sort(pages);
mw.retrieveContents(wiki, pages, true, false, false, false);
for (Page page : pages) {
if (Boolean.FALSE.equals(page.isExisting())) {
details.append("<li>");
details.append(GT._("The page {0} doesn''t exist on Wikipedia", page.getTitle()));
details.append("</li>");
} else {
CheckErrorPage errorPage = CheckError.analyzeError(
algorithm, page.getAnalysis(page.getContents(), true));
if ((errorPage == null) || (!errorPage.getErrorFound())) {
details.append("<li>");
String pageLink =
"<a href=\"" +
wiki.getSettings().getURL(page.getTitle(), false, true) +
"\">" +
page.getTitle() +
"</a>";
details.append(GT._("The error hasn''t been detected in page {0}.", pageLink));
Boolean errorDetected = checkWiki.isErrorDetected(page, errorNumber);
if (errorDetected != null) {
details.append(" ");
if (Boolean.TRUE.equals(errorDetected)) {
details.append(GT._("It's still being detected by CheckWiki."));
} else {
details.append(GT._("It's not detected either by CheckWiki."));
}
}
details.append("</li>");
}
}
}
}
if (details.length() > 0) {
String pageLink = String.valueOf(errorNumber);
if (cwConfig.getWhiteListPageName() != null) {
pageLink =
"<a href=\"" +
wiki.getSettings().getURL(cwConfig.getWhiteListPageName(), false, true) +
"\">" +
String.valueOf(errorNumber) +
"</a>";
}
result.append(GT._(