public boolean checkValidity(CachedSourceResponse response, Source source, long expires) {
final SourceValidity[] validities = response.getValidityObjects();
boolean valid = true;
final ExpiresValidity expiresValidity = (ExpiresValidity) validities[0];
final SourceValidity sourceValidity = validities[1];
if (expiresValidity.isValid() != SourceValidity.VALID) {
int validity = sourceValidity != null? sourceValidity.isValid() : SourceValidity.INVALID;
if (validity == SourceValidity.INVALID ||
validity == SourceValidity.UNKNOWN &&
sourceValidity.isValid(source.getValidity()) != SourceValidity.VALID) {
if (logger.isDebugEnabled()) {
logger.debug("Response expired, invalid for " + logger);
}
valid = false;
} else {
if (logger.isDebugEnabled()) {
logger.debug("Response expired, still valid for " + logger);
}
// set new expiration period
validities[0] = new ExpiresValidity(expires);
}
} else {
if (logger.isDebugEnabled()) {
logger.debug("Response not expired for " + logger);
}