@Override
public AbstractStorageItem doCacheItem(AbstractStorageItem item)
throws LocalStorageException
{
AbstractStorageItem result = null;
try {
if (log.isDebugEnabled()) {
log.debug(
"Caching item " + item.getRepositoryItemUid().toString() + " in local storage of repository.");
}
final RepositoryItemUidLock itemLock = item.getRepositoryItemUid().getLock();
itemLock.lock(Action.create);
final Action action;
try {
action = getResultingActionOnWrite(item.getResourceStoreRequest());
getLocalStorage().storeItem(this, item);
removeFromNotFoundCache(item.getResourceStoreRequest());
// we swapped the remote item with the one from local storage
// using this method below, we ensure that we get a "wrapped"
// content locator that will keel shared-lock on the content
// until being fully read
result = doRetrieveLocalItem(item.getResourceStoreRequest());
}
finally {
itemLock.unlock();
}
result.getItemContext().setParentContext(item.getItemContext());
if (Action.create.equals(action)) {
eventBus().post(new RepositoryItemEventCacheCreate(this, result));
}
else {