use of org.commonjava.indy.change.event.ArtifactStorePostRescanEvent in project indy by Commonjava.
the class KojiRemoteContenIndexingRescanManager method indexPostRescan.
public void indexPostRescan(@Observes final ArtifactStorePostRescanEvent e) throws IndyWorkflowException {
Collection<ArtifactStore> repos = e.getStores();
for (ArtifactStore repo : repos) {
if (repo.getType() == StoreType.remote && repo.getName().startsWith(KOJI_ORIGIN)) {
LOGGER.trace("Rebuild content index for koji remote: {}", repo.getKey());
final RemoteRepository kojiRemote = (RemoteRepository) repo;
try {
Set<Group> affected = storeDataManager.query().getGroupsAffectedBy(kojiRemote.getKey());
Set<StoreKey> affetctedGroupKeys = affected.stream().map(g -> g.getKey()).collect(Collectors.toSet());
StoreKey[] gKeys = affetctedGroupKeys.toArray(new StoreKey[affetctedGroupKeys.size()]);
kojiRemote.getPathMaskPatterns().forEach(path -> contentIndexManager.indexPathInStores(path, kojiRemote.getKey(), gKeys));
} catch (IndyDataException ex) {
LOGGER.error(String.format("Can not get the affected groups for hosted repo %s due to %s", kojiRemote.getKey(), ex.getMessage()), ex);
}
}
}
}
use of org.commonjava.indy.change.event.ArtifactStorePostRescanEvent in project indy by Commonjava.
the class HostedContentIndexRescanManager method indexPostRescan.
public void indexPostRescan(@Observes final ArtifactStorePostRescanEvent e) throws IndyWorkflowException {
if (!indexConfig.isEnabled()) {
LOGGER.debug("Content index is disabled.");
return;
}
Collection<ArtifactStore> hostedStores = e.getStores();
for (ArtifactStore repo : hostedStores) {
if (repo.getType() == StoreType.hosted) {
LOGGER.trace("Rebuild content index for {}", repo.getKey());
final HostedRepository hosted = (HostedRepository) repo;
try {
List<Transfer> transfers = downloadManager.listRecursively(hosted.getKey(), DownloadManager.ROOT_PATH);
Set<Group> affected = storeDataManager.query().getGroupsAffectedBy(hosted.getKey());
Set<StoreKey> affetctedGroupKeys = affected.stream().map(g -> g.getKey()).collect(Collectors.toSet());
StoreKey[] gKeys = affetctedGroupKeys.toArray(new StoreKey[affetctedGroupKeys.size()]);
transfers.forEach(txfr -> contentIndexManager.indexPathInStores(txfr.getPath(), hosted.getKey(), gKeys));
} catch (IndyWorkflowException ex) {
LOGGER.error(String.format("Can not list resource correctly for hosted repo %s due to %s", hosted.getKey(), ex.getMessage()), ex);
} catch (IndyDataException ex) {
LOGGER.error(String.format("Can not get the affected groups for hosted repo %s due to %s", hosted.getKey(), ex.getMessage()), ex);
}
}
}
}
Aggregations