use of javax.decorator.Delegate in project indy by Commonjava.
the class IndexingContentManagerDecorator method retrieve.
@Override
public Transfer retrieve(final ArtifactStore store, final String path, final EventMetadata eventMetadata) throws IndyWorkflowException {
Logger logger = LoggerFactory.getLogger(getClass());
logger.trace("Looking for indexed path: {} in: {}", path, store.getKey());
Transfer transfer = getIndexedTransfer(store.getKey(), null, path, TransferOperation.DOWNLOAD);
if (transfer != null) {
logger.debug("Found indexed transfer: {}. Returning.", transfer);
return transfer;
}
StoreType type = store.getKey().getType();
if (StoreType.group == type) {
ConcreteResource resource = new ConcreteResource(LocationUtils.toLocation(store), path);
if (nfc.isMissing(resource)) {
logger.debug("{} is marked as missing. Returning null.", resource);
return null;
}
logger.debug("No group index hits. Devolving to member store indexes.");
KeyedLocation location = LocationUtils.toLocation(store);
SpecialPathInfo specialPathInfo = specialPathManager.getSpecialPathInfo(location, path, store.getPackageType());
if (specialPathInfo == null || !specialPathInfo.isMergable()) {
transfer = getIndexedMemberTransfer((Group) store, path, TransferOperation.DOWNLOAD, (member) -> {
try {
return delegate.retrieve(member, path);
} catch (IndyWorkflowException e) {
logger.error(String.format("Failed to retrieve() for member path: %s:%s. Reason: %s", member.getKey(), path, e.getMessage()), e);
}
return null;
});
if (transfer != null) {
nfc.clearMissing(resource);
return transfer;
}
logger.debug("No index hits. Delegating to main content manager for: {} in: {}", path, store);
} else {
logger.debug("Merged content. Delegating to main content manager for: {} in: {}", path, store);
transfer = delegate.retrieve(store, path, eventMetadata);
if (transfer == null) {
nfc.addMissing(resource);
}
return transfer;
}
}
transfer = delegate.retrieve(store, path, eventMetadata);
if (transfer != null) {
logger.debug("Got transfer from delegate: {} (will index)", transfer);
indexManager.indexTransferIn(transfer, store.getKey());
}
logger.debug("Returning transfer: {}", transfer);
return transfer;
}
Aggregations