}
public void deleteChainState(ChainState state) throws DotDataException, DotCacheException {
ChainCache cache = CacheLocator.getChainCache();
Chain chain = findChain(state.getChainId());
state = findChainState(state.getId());
HibernateUtil.delete(state);
// Making sure the remaining states got the right order
// Removing gaps that could happen on deleting the state
List<ChainState> states = findChainStates(chain);
int order = 0;
for (ChainState stateIt : states) {
if (stateIt.getOrder() != order) {
stateIt.setOrder(order);
saveChainState(stateIt);
}
}
// Getting rid of the cache entries forcing to lazily load later
try {
cache.removeChainStates(chain.getId());
} catch (DotCacheException e) {
Logger.warn(this, "deleteChain: Couldn't remove the key from cache", e);
}
}