public void deleteFromCache(File file) throws DotDataException, DotStateException, DotSecurityException { fileCache.remove(file); WorkingCache.removeAssetFromCache(file); if (file.isLive()) { LiveCache.removeAssetFromCache(file); } CacheLocator.getIdentifierCache().removeFromCacheByVersionable(file); }
@SuppressWarnings("unchecked") public File saveFile( File newFile, java.io.File dataFile, Folder parentFolder, Identifier identifier) throws DotDataException { boolean localTransation = false; try { localTransation = DbConnectionFactory.getConnection().getAutoCommit(); if (localTransation) { HibernateUtil.startTransaction(); } // old working file File oldFile = null; // if new identifier if (identifier == null || !InodeUtils.isSet(identifier.getInode())) { identifier = APILocator.getIdentifierAPI().createNew(newFile, parentFolder); newFile.setIdentifier(identifier.getInode()); HibernateUtil.save(newFile); APILocator.getVersionableAPI().setWorking(newFile); saveFileData(newFile, null, dataFile); } else { APILocator.getVersionableAPI().removeLive(identifier.getId()); } if (UtilMethods.isSet(dataFile)) { HibernateUtil.save(newFile); saveFileData(newFile, null, dataFile); } if (oldFile != null && InodeUtils.isSet(oldFile.getInode())) { APILocator.getFileAPI().invalidateCache(oldFile); fileCache.remove(oldFile); WorkingCache.removeAssetFromCache(oldFile); } LiveCache.removeAssetFromCache(newFile); if (newFile.isLive()) { LiveCache.addToLiveAssetToCache(newFile); } WorkingCache.addToWorkingAssetToCache(newFile); if (localTransation) { HibernateUtil.commitTransaction(); } } catch (Exception e) { if (localTransation) { HibernateUtil.rollbackTransaction(); } throw new DotDataException(e.getMessage(), e); } return newFile; }