@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; }
/** Save a CalendarReminder to the DB */ public void saveCalendarReminder(CalendarReminder calendarReminder) { try { HibernateUtil.save(calendarReminder); } catch (DotHibernateException e) { Logger.error(CalendarReminderFactoryImpl.class, "saveCalendarReminder failed:" + e, e); } }
protected void saveInode(Inode inode) throws DotDataException { HibernateUtil.save(inode); }