Search in sources :

Example 1 with ArtifactStorePostUpdateEvent

use of org.commonjava.indy.change.event.ArtifactStorePostUpdateEvent in project indy by Commonjava.

the class AuthoritativeIndexSettingManager method setAuthoritativeManager.

public void setAuthoritativeManager(@Observes final ArtifactStorePostUpdateEvent event) {
    if (indexCfg == null || !indexCfg.isAuthoritativeIndex()) {
        return;
    }
    final Collection<ArtifactStore> stores = event.getChanges();
    stores.stream().filter(store -> store.getKey().getType() == StoreType.hosted).forEach(store -> {
        final HostedRepository hosted = (HostedRepository) store;
        if (hosted.isReadonly()) {
            hosted.setAuthoritativeIndex(true);
        } else {
            hosted.setAuthoritativeIndex(false);
        }
    });
}
Also used : Inject(javax.inject.Inject) Logger(org.slf4j.Logger) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Observes(javax.enterprise.event.Observes) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) StoreType(org.commonjava.indy.model.core.StoreType) ApplicationScoped(javax.enterprise.context.ApplicationScoped) ArtifactStorePostUpdateEvent(org.commonjava.indy.change.event.ArtifactStorePostUpdateEvent) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) HostedRepository(org.commonjava.indy.model.core.HostedRepository)

Example 2 with ArtifactStorePostUpdateEvent

use of org.commonjava.indy.change.event.ArtifactStorePostUpdateEvent in project indy by Commonjava.

the class DefaultStoreEventDispatcher method updated.

@Override
public void updated(final ArtifactStoreUpdateType type, final EventMetadata eventMetadata, final Map<ArtifactStore, ArtifactStore> changeMap) {
    executor.execute(() -> {
        final ArtifactStorePostUpdateEvent event = new ArtifactStorePostUpdateEvent(type, eventMetadata, changeMap);
        fireEvent(updatePostEvent, event);
    });
}
Also used : ArtifactStorePostUpdateEvent(org.commonjava.indy.change.event.ArtifactStorePostUpdateEvent)

Aggregations

ArtifactStorePostUpdateEvent (org.commonjava.indy.change.event.ArtifactStorePostUpdateEvent)2 Collection (java.util.Collection)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Observes (javax.enterprise.event.Observes)1 Inject (javax.inject.Inject)1 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)1 HostedRepository (org.commonjava.indy.model.core.HostedRepository)1 StoreType (org.commonjava.indy.model.core.StoreType)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1