use of org.commonjava.indy.core.content.group.GroupMergeHelper.GROUP_METADATA_GENERATED 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 {
if (!indexCfg.isEnabled()) {
return delegate.retrieve(store, path, eventMetadata);
}
if (store == null) {
return null;
}
logger.trace("Looking for indexed path: {} in: {}", path, store.getKey());
Transfer transfer = getIndexedTransfer(store.getKey(), null, path, TransferOperation.DOWNLOAD, eventMetadata);
if (transfer != null) {
logger.debug("Found indexed transfer: {}. Returning.", transfer);
return transfer;
} else if (isAuthoritativelyMissing(store)) {
logger.debug("Not found indexed transfer: {} and authoritative index switched on. Considering not found and return null.", transfer);
return null;
}
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()) {
if (PathMaskChecker.checkMask(store, path)) {
transfer = getTransferFromConstituents(((Group) store).getConstituents(), resource, path, store, memberKey -> {
try {
ArtifactStore member = storeDataManager.getArtifactStore(memberKey);
if (member == null) {
logger.trace("Cannot find store for key: {}", memberKey);
} else {
return retrieve(member, path, eventMetadata);
}
} catch (IndyDataException e) {
logger.error(String.format("Failed to lookup store: %s (in membership of: %s). Reason: %s", memberKey, store.getKey(), e.getMessage()), e);
}
return null;
});
nfcForGroup(store, transfer, resource);
return transfer;
} else {
return null;
}
} else {
logger.debug("Merged content. Delegating to main content manager for: {} in: {}", path, store);
transfer = delegate.retrieve(store, path, eventMetadata);
if (!exists(transfer)) {
Boolean metadataGenerated = (Boolean) eventMetadata.get(GROUP_METADATA_GENERATED);
Boolean metadataExists = (Boolean) eventMetadata.get(GROUP_METADATA_EXISTS);
if (Boolean.TRUE.equals(metadataGenerated) || Boolean.TRUE.equals(metadataExists)) {
// metadata generated/exists but missing due to membership change, not add to nfc so next req can retry
;
} else // don't track NFC for hosted repos
{
nfc.addMissing(resource);
}
}
return transfer;
}
}
logger.trace("Delegating retrieve call for concrete repository: {}/{}", store, path);
transfer = delegate.retrieve(store, path, eventMetadata);
if (exists(transfer) && indexCfg.isEnabled()) {
logger.debug("Got transfer from delegate: {} (will index)", transfer);
indexManager.indexTransferIn(transfer, store.getKey());
}
logger.debug("Returning transfer: {}", transfer);
return transfer;
}
Aggregations