Search in sources :

Example 1 with KOJI_ORIGIN

use of org.commonjava.indy.koji.model.IndyKojiConstants.KOJI_ORIGIN 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);
            }
        }
    }
}
Also used : Logger(org.slf4j.Logger) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) StoreType(org.commonjava.indy.model.core.StoreType) Set(java.util.Set) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) ArtifactStorePostRescanEvent(org.commonjava.indy.change.event.ArtifactStorePostRescanEvent) Collectors(java.util.stream.Collectors) Group(org.commonjava.indy.model.core.Group) KOJI_ORIGIN(org.commonjava.indy.koji.model.IndyKojiConstants.KOJI_ORIGIN) Inject(javax.inject.Inject) ArtifactStorePreRescanEvent(org.commonjava.indy.change.event.ArtifactStorePreRescanEvent) IndyWorkflowException(org.commonjava.indy.IndyWorkflowException) ContentIndexRescanManager(org.commonjava.indy.content.index.ContentIndexRescanManager) Observes(javax.enterprise.event.Observes) ContentIndexManager(org.commonjava.indy.content.index.ContentIndexManager) ApplicationScoped(javax.enterprise.context.ApplicationScoped) IndyDataException(org.commonjava.indy.data.IndyDataException) StoreDataManager(org.commonjava.indy.data.StoreDataManager) StoreKey(org.commonjava.indy.model.core.StoreKey) IndyDataException(org.commonjava.indy.data.IndyDataException) Group(org.commonjava.indy.model.core.Group) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) StoreKey(org.commonjava.indy.model.core.StoreKey)

Aggregations

Collection (java.util.Collection)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Observes (javax.enterprise.event.Observes)1 Inject (javax.inject.Inject)1 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)1 ArtifactStorePostRescanEvent (org.commonjava.indy.change.event.ArtifactStorePostRescanEvent)1 ArtifactStorePreRescanEvent (org.commonjava.indy.change.event.ArtifactStorePreRescanEvent)1 ContentIndexManager (org.commonjava.indy.content.index.ContentIndexManager)1 ContentIndexRescanManager (org.commonjava.indy.content.index.ContentIndexRescanManager)1 IndyDataException (org.commonjava.indy.data.IndyDataException)1 StoreDataManager (org.commonjava.indy.data.StoreDataManager)1 KOJI_ORIGIN (org.commonjava.indy.koji.model.IndyKojiConstants.KOJI_ORIGIN)1 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)1 Group (org.commonjava.indy.model.core.Group)1 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)1 StoreKey (org.commonjava.indy.model.core.StoreKey)1 StoreType (org.commonjava.indy.model.core.StoreType)1 Logger (org.slf4j.Logger)1