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);
}
}
}
}
Aggregations