final String source = projection.getSourceName();
if (sourceNames != null && !sourceNames.contains(source)) continue;
final RepositoryConnection sourceConnection = getConnection(projection);
if (sourceConnection == null) continue; // No source exists by this name
// Get the cached information ...
CachePolicy cachePolicy = sourceConnection.getDefaultCachePolicy();
if (cachePolicy == null) cachePolicy = this.defaultCachePolicy;
DateTime expirationTime = null;
if (cachePolicy != null) {
expirationTime = getCurrentTimeInUtc().plus(cachePolicy.getTimeToLive(), TimeUnit.MILLISECONDS);
}
// Submit the request ...
ReadNodeRequest request = new ReadNodeRequest(location);
sourceConnection.execute(context, request);
if (request.hasError()) continue;
DateTime expTime = request.getCachePolicy() == null ? expirationTime : getCurrentTimeInUtc().plus(request.getCachePolicy().getTimeToLive(),
TimeUnit.MILLISECONDS);
// Convert the locations of the children (relative to the source) to be relative to this node
Contribution contribution = Contribution.create(source,
request.getActualLocationOfNode(),
expTime,
request.getProperties(),
request.getChildren());
contributions.add(contribution);
}
}
// Otherwise, we can do it by path and projections ...
Path path = location.getPath();
for (Projection projection : this.sourceProjections) {
final String source = projection.getSourceName();
if (sourceNames != null && !sourceNames.contains(source)) continue;
final RepositoryConnection sourceConnection = getConnection(projection);
if (sourceConnection == null) continue; // No source exists by this name
// Get the cached information ...
CachePolicy cachePolicy = sourceConnection.getDefaultCachePolicy();
if (cachePolicy == null) cachePolicy = this.defaultCachePolicy;
DateTime expirationTime = null;
if (cachePolicy != null) {
expirationTime = getCurrentTimeInUtc().plus(cachePolicy.getTimeToLive(), TimeUnit.MILLISECONDS);
}
// Get the paths-in-source where we should fetch node contributions ...
Set<Path> pathsInSource = projection.getPathsInSource(path, pathFactory);
if (pathsInSource.isEmpty()) {
// The source has no contributions, but see whether the project exists BELOW this path.