// Javadoc inherited.
public ProviderResult retrieve(
SystemClock clock, Object key, CacheEntry entry) {
CacheControl cacheControl;
ActivatedPolicy policy;
Throwable throwable = null;
try {
policy = retriever.retrievePolicy(project, name);
// todo need to be able to handle the case where the policy could
// todo not be retrieved but the project for the policy was found
// todo and is not the same as the supplied one. i.e. when a
// todo request is made to a remote repository which finds the
// todo project for the policy but not the policy. The reason we
// todo need to do that is because we need to use the actual
// todo project for the policy to get default cache control stuff.
if (policy == null) {
cacheControl = cache.getDefaultCacheControl(project, key);
} else {
// Determine whether the policy is cacheable.
cacheControl = policy.getCacheControl();
}
} catch (Throwable e) {
// Catch all exceptions so that they will trigger the retry
// mechanism if configured.
if (logger.isErrorEnabled()) {
logger.error(e);
}
cacheControl = cache.getDefaultCacheControl(project, key);
policy = null;
// Remember the throwable so that it can be returned back to the
// cache which will place the entry into the error state.
throwable = e;
}
// If this is cacheable then update the state, either the one
// associated with the entry, or a newly created one if the entry has
// not been supplied, or does not have one. The latter will only occur
// if this is the first time that a policy is being retrieved for the
// entry.
//
// If this is not cacheable then there is no point in updating the
// state as while it will be stored in the entry it will not be used.
// Therefore, in that case return null so that state based on an
// uncacheable policy is not stored in the entry.
final boolean cacheable = cacheControl.getCacheThisPolicy();
CachedPolicyState state = null;
if (cacheable) {
ActivatedPolicy expiredPolicy = null;