* @param deprecatedPages The list of pages that match the URL but that are expected to be.
* @param currDate The current date, to check for expiration.
* @return The non-expired matching page if found, {@code null} otherwise.
*/
private CachedPage extractMatchingPage(Map<Key<CachedPage>, CachedPage> deprecatedPages, Date currDate) {
CachedPage matchingPage = findMostRecentPage(deprecatedPages);
// Keep the matching page only if it has not expired
if (matchingPage == null ||
currDate.getTime() > matchingPage.getFetchDate().getTime() + cachedPageTimeoutSec * 1000) {
matchingPage = null;
} else {
deprecatedPages.remove(Key.create(CachedPage.class, matchingPage.getId()));
}
return matchingPage;
}