Search in sources :

Example 1 with StoreEventDispatcher

use of org.commonjava.indy.data.StoreEventDispatcher in project indy by Commonjava.

the class AbstractStoreDataManager method postDelete.

protected void postDelete(final ArtifactStore store, final ChangeSummary summary, final boolean fireEvents, final EventMetadata eventMetadata) throws IndyDataException {
    StoreEventDispatcher dispatcher = getStoreEventDispatcher();
    if (dispatcher != null && isStarted() && fireEvents) {
        dispatcher.deleted(eventMetadata, store);
    }
    refreshAffectedBy(store, null, DELETE);
}
Also used : StoreEventDispatcher(org.commonjava.indy.data.StoreEventDispatcher)

Example 2 with StoreEventDispatcher

use of org.commonjava.indy.data.StoreEventDispatcher in project indy by Commonjava.

the class AbstractStoreDataManager method postStore.

protected void postStore(final ArtifactStore store, final ArtifactStore original, final ChangeSummary summary, final boolean exists, final boolean fireEvents, final EventMetadata eventMetadata) throws IndyDataException {
    StoreEventDispatcher dispatcher = getStoreEventDispatcher();
    if (dispatcher != null && isStarted() && fireEvents) {
        logger.debug("Firing store post-update event for: {} (originally: {})", store, original);
        dispatcher.updated(exists ? ArtifactStoreUpdateType.UPDATE : ArtifactStoreUpdateType.ADD, eventMetadata, Collections.singletonMap(store, original));
        if (exists) {
            if (store.isDisabled() && !original.isDisabled()) {
                dispatcher.disabled(eventMetadata, store);
            } else if (!store.isDisabled() && original.isDisabled()) {
                dispatcher.enabled(eventMetadata, store);
            }
        }
    }
    // Hosted or Remote update does not change affectedBy relationships
    if (store instanceof Group) {
        refreshAffectedBy(store, original, STORE);
    }
}
Also used : StoreEventDispatcher(org.commonjava.indy.data.StoreEventDispatcher) Group(org.commonjava.indy.model.core.Group)

Example 3 with StoreEventDispatcher

use of org.commonjava.indy.data.StoreEventDispatcher in project indy by Commonjava.

the class AbstractStoreDataManager method preDelete.

protected void preDelete(final ArtifactStore store, final ChangeSummary summary, final boolean fireEvents, final EventMetadata eventMetadata) throws IndyDataException {
    StoreEventDispatcher dispatcher = getStoreEventDispatcher();
    if (dispatcher != null && isStarted() && fireEvents) {
        eventMetadata.set(StoreDataManager.CHANGE_SUMMARY, summary);
        dispatcher.deleting(eventMetadata, store);
    }
}
Also used : StoreEventDispatcher(org.commonjava.indy.data.StoreEventDispatcher)

Example 4 with StoreEventDispatcher

use of org.commonjava.indy.data.StoreEventDispatcher in project indy by Commonjava.

the class AbstractStoreDataManager method preStore.

protected void preStore(final ArtifactStore store, final ArtifactStore original, final ChangeSummary summary, final boolean exists, final boolean fireEvents, final EventMetadata eventMetadata) throws IndyDataException {
    StoreEventDispatcher dispatcher = getStoreEventDispatcher();
    if (dispatcher != null && isStarted() && fireEvents) {
        logger.debug("Firing store pre-update event for: {} (originally: {})", store, original);
        dispatcher.updating(exists ? ArtifactStoreUpdateType.UPDATE : ArtifactStoreUpdateType.ADD, eventMetadata, Collections.singletonMap(store, original));
        if (exists) {
            if (store.isDisabled() && !original.isDisabled()) {
                dispatcher.disabling(eventMetadata, store);
            } else if (!store.isDisabled() && original.isDisabled()) {
                dispatcher.enabling(eventMetadata, store);
            }
        }
    }
}
Also used : StoreEventDispatcher(org.commonjava.indy.data.StoreEventDispatcher)

Example 5 with StoreEventDispatcher

use of org.commonjava.indy.data.StoreEventDispatcher in project indy by Commonjava.

the class LegacyDataMigrationActionTest method setup.

@Before
public void setup() throws Exception {
    dfm = new DataFileManager(temp.newFolder("stores"), new DataFileEventManager());
    IndyObjectMapper mapper = new IndyObjectMapper(true);
    final StoreEventDispatcher sed = new StoreEventDispatcherStub();
    action = new LegacyDataMigrationAction(dfm, new DataFileStoreDataManager(dfm, mapper, sed), mapper);
}
Also used : StoreEventDispatcher(org.commonjava.indy.data.StoreEventDispatcher) IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) DataFileEventManager(org.commonjava.indy.subsys.datafile.change.DataFileEventManager) DataFileManager(org.commonjava.indy.subsys.datafile.DataFileManager) StoreEventDispatcherStub(org.commonjava.indy.core.data.testutil.StoreEventDispatcherStub) Before(org.junit.Before)

Aggregations

StoreEventDispatcher (org.commonjava.indy.data.StoreEventDispatcher)5 StoreEventDispatcherStub (org.commonjava.indy.core.data.testutil.StoreEventDispatcherStub)1 Group (org.commonjava.indy.model.core.Group)1 IndyObjectMapper (org.commonjava.indy.model.core.io.IndyObjectMapper)1 DataFileManager (org.commonjava.indy.subsys.datafile.DataFileManager)1 DataFileEventManager (org.commonjava.indy.subsys.datafile.change.DataFileEventManager)1 Before (org.junit.Before)1