Search in sources :

Example 1 with SchedulerTriggerEvent

use of org.commonjava.indy.core.expire.SchedulerTriggerEvent in project indy by Commonjava.

the class StoreEnablementManager method onDisableTimeout.

public void onDisableTimeout(@Observes SchedulerEvent evt) {
    Logger logger = LoggerFactory.getLogger(getClass());
    logger.debug("Checking for store-reenable event in: {} (trigger? {} Disable-Timeout? {})", evt, evt instanceof SchedulerTriggerEvent, DISABLE_TIMEOUT.equals(evt.getJobType()));
    if ((evt instanceof SchedulerTriggerEvent) && DISABLE_TIMEOUT.equals(evt.getJobType())) {
        String keystr = evt.getPayload();
        StoreKey key = null;
        try {
            key = objectMapper.readValue(keystr, StoreKey.class);
        } catch (IOException e) {
            logger.warn("Failed to read StoreKey from JSON string: '{}' in event payload.", keystr);
        }
        logger.debug("Read key: {} from JSON string: '{}' in event payload.", key, keystr);
        if (key != null) {
            try {
                ArtifactStore store = storeDataManager.getArtifactStore(key);
                if (store.isDisabled()) {
                    store.setDisabled(false);
                    storeDataManager.storeArtifactStore(store, new ChangeSummary(ChangeSummary.SYSTEM_USER, "Re-enabling " + key), false, true, new EventMetadata());
                    cancelReEnablementTimeout(key);
                }
            } catch (IndyDataException e) {
                logger.error(String.format("Failed to re-enable %s", key), e);
            } catch (IndySchedulerException e) {
                logger.error(String.format("Failed to delete re-enablement job for %s.", key), e);
            }
        }
    }
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) SchedulerTriggerEvent(org.commonjava.indy.core.expire.SchedulerTriggerEvent) IOException(java.io.IOException) Logger(org.slf4j.Logger) ChangeSummary(org.commonjava.indy.audit.ChangeSummary) StoreKey(org.commonjava.indy.model.core.StoreKey) IndySchedulerException(org.commonjava.indy.core.expire.IndySchedulerException) EventMetadata(org.commonjava.maven.galley.event.EventMetadata)

Aggregations

IOException (java.io.IOException)1 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)1 IndySchedulerException (org.commonjava.indy.core.expire.IndySchedulerException)1 SchedulerTriggerEvent (org.commonjava.indy.core.expire.SchedulerTriggerEvent)1 IndyDataException (org.commonjava.indy.data.IndyDataException)1 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)1 StoreKey (org.commonjava.indy.model.core.StoreKey)1 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)1 Logger (org.slf4j.Logger)1