use of org.xwiki.store.FileDeleteTransactionRunnable in project xwiki-platform by xwiki.
the class FilesystemAttachmentRecycleBinContentStore method getDeletedAttachmentPurgeRunnable.
/**
* Get a TransactionRunnable for removing a deleted attachment from the filesystem entirely.
*
* @param provider the file provider for the deleted attachment to purge from the recycle bin.
* @return a StartableTransactionRunnable for removing the attachment.
*/
private StartableTransactionRunnable getDeletedAttachmentPurgeRunnable(final DeletedAttachmentFileProvider provider) {
final StartableTransactionRunnable out = new StartableTransactionRunnable();
final File deletedAttachDir = provider.getDeletedAttachmentMetaFile().getParentFile();
if (!deletedAttachDir.exists()) {
// No such dir, return a do-nothing runnable.
return out;
}
// Easy thing to do is just delete everything in the deleted-attachment directory.
for (File toDelete : deletedAttachDir.listFiles()) {
new FileDeleteTransactionRunnable(toDelete, this.fileTools.getBackupFile(toDelete), this.fileTools.getLockForFile(toDelete)).runIn(out);
}
return out;
}
use of org.xwiki.store.FileDeleteTransactionRunnable in project xwiki-platform by xwiki.
the class FilesystemRecycleBinContentStore method delete.
@Override
public void delete(DocumentReference reference, long index, boolean bTransaction) throws XWikiException {
final XWikiContext xcontext = this.xcontextProvider.get();
final XWikiHibernateTransaction transaction = new XWikiHibernateTransaction(xcontext);
final File contentFile = this.fileTools.getDeletedDocumentFileProvider(reference, index).getDeletedDocumentContentFile();
new FileDeleteTransactionRunnable(contentFile, this.fileTools.getBackupFile(contentFile), this.fileTools.getLockForFile(contentFile)).runIn(transaction);
try {
transaction.start();
} catch (Exception e) {
throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.ERROR_XWIKI_STORE_HIBERNATE_SAVING_ATTACHMENT, "Exception while deleting deleted document content.", e);
}
}
Aggregations