}
// Check if an update has been made on a monitored page
for (RecentChange rc : filteredNewRC) {
if (monitoredPages.containsKey(rc.getTitle())) {
Page page = DataManager.getPage(getWikipedia(), rc.getTitle(), null, null, null);
try {
updateDabWarning.updateWarning(
Collections.singletonList(page), null, null, null);
} catch (APIException e) {
// Nothing to do
}
monitoredPages.put(rc.getTitle(), Long.valueOf(currentTime.getTime()));
}
}
// Check monitored pages for expired delay
Iterator<Entry<String, Long>> itPages = monitoredPages.entrySet().iterator();
while (itPages.hasNext()) {
Entry<String, Long> entry = itPages.next();
if (currentTime.getTime() > entry.getValue().longValue() + delayMonitoring) {
itPages.remove();
}
}
// Update list of interesting recent changes
for (RecentChange rc : filteredNewRC) {
if (isInterestingNamespace(rc)) {
if (RecentChange.TYPE_NEW.equals(rc.getType())) {
if (rc.isNew()) {
modelRCInteresting.addRecentChange(rc);
}
} else if (RecentChange.TYPE_EDIT.equals(rc.getType())) {
if (modelRCInteresting.containsRecentChange(rc.getTitle())) {
modelRCInteresting.addRecentChange(rc);
}
} else if (RecentChange.TYPE_LOG.equals(rc.getType())) {
if (RecentChange.LOG_TYPE_DELETE.equals(rc.getLogType()) &&
RecentChange.LOG_ACTION_DELETE_DELETE.equals(rc.getLogAction())) {
modelRCInteresting.removeRecentChanges(rc.getTitle());
}
}
}
}
// Check if interesting recent changes are old enough
List<RecentChange> interestingRC = modelRCInteresting.getRecentChanges();
List<Page> pages = new ArrayList<Page>();
Map<String, String> creators = new HashMap<String, String>();
Map<String, List<String>> modifiers = new HashMap<String, List<String>>();
while (!interestingRC.isEmpty()) {
// Retrieve synthetic information about recent changes for one title
List<RecentChange> listRC = extractRecentChanges(interestingRC);
String title = listRC.get(0).getTitle();
String creator = null;
List<String> pageModifiers = new ArrayList<String>();
boolean oldEnough = true;
boolean redirect = false;
for (int rcNum = listRC.size(); rcNum > 0; rcNum--) {
RecentChange rc = listRC.get(rcNum - 1);
if (currentTime.getTime() <= rc.getTimestamp().getTime() + delayForNew) {
oldEnough = false;
}
String user = rc.getUser();
redirect = rc.isRedirect();
if (rc.isNew()) {
creator = user;
} else {
if (!rc.isBot()) {
if ((creator == null) || (!creator.equals(user))) {
if (!pageModifiers.contains(user)) {
pageModifiers.add(user);
}
}
}
}
}
if (oldEnough) {
modelRCInteresting.removeRecentChanges(title);
if (!redirect) {
Page page = DataManager.getPage(getWikipedia(), title, null, null, null);
pages.add(page);
creators.put(title, creator);
modifiers.put(title, pageModifiers);
}
}
}
// Update disambiguation warnings
if (!pages.isEmpty()) {
try {
Stats stats = new Stats();
createDabWarning.updateWarning(
pages, creators, modifiers, stats);
List<Page> updatedPages = stats.getUpdatedPages();
if (updatedPages != null) {
for (Page page : updatedPages) {
monitoredPages.put(page.getTitle(), Long.valueOf(currentTime.getTime()));
}
}
} catch (APIException e) {
// Nothing to do
}