Search in sources :

Example 1 with FileSaveTransactionRunnable

use of org.xwiki.store.FileSaveTransactionRunnable in project xwiki-platform by xwiki.

the class FilesystemRecycleBinContentStore method save.

@Override
public void save(XWikiDocument document, long index, boolean bTransaction) throws XWikiException {
    final XWikiContext xcontext = this.xcontextProvider.get();
    final XWikiHibernateTransaction transaction = new XWikiHibernateTransaction(xcontext);
    final File contentFile = this.fileTools.getDeletedDocumentFileProvider(document.getDocumentReferenceWithLocale(), index).getDeletedDocumentContentFile();
    FileSerializer serializer = new DeletedDocumentContentFileSerializer(document, StandardCharsets.UTF_8.name());
    new FileSaveTransactionRunnable(contentFile, fileTools.getTempFile(contentFile), fileTools.getBackupFile(contentFile), fileTools.getLockForFile(contentFile), serializer).runIn(transaction);
    try {
        transaction.start();
    } catch (Exception e) {
        throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_HIBERNATE_SAVING_ATTACHMENT, "Exception while saving deleted document content.", e);
    }
}
Also used : FileSerializer(org.xwiki.store.FileSerializer) XWikiContext(com.xpn.xwiki.XWikiContext) FileSaveTransactionRunnable(org.xwiki.store.FileSaveTransactionRunnable) File(java.io.File) XWikiException(com.xpn.xwiki.XWikiException) XWikiException(com.xpn.xwiki.XWikiException)

Aggregations

XWikiContext (com.xpn.xwiki.XWikiContext)1 XWikiException (com.xpn.xwiki.XWikiException)1 File (java.io.File)1 FileSaveTransactionRunnable (org.xwiki.store.FileSaveTransactionRunnable)1 FileSerializer (org.xwiki.store.FileSerializer)1