use of org.xwiki.store.StartableTransactionRunnable 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.StartableTransactionRunnable in project xwiki-platform by xwiki.
the class FilesystemAttachmentRecycleBinContentStore method delete.
@Override
public void delete(AttachmentReference reference, Date deleteDate, long index, boolean bTransaction) throws XWikiException {
DeletedAttachmentFileProvider provider = this.fileTools.getDeletedAttachmentFileProvider(reference, index);
StartableTransactionRunnable tr = getDeletedAttachmentPurgeRunnable(provider);
try {
tr.start();
} catch (Exception e) {
throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.MODULE_XWIKI, "Failed to delete deleted attachment [" + reference + "]", e);
}
}
use of org.xwiki.store.StartableTransactionRunnable in project xwiki-platform by xwiki.
the class FilesystemAttachmentRecycleBinContentStore method save.
@Override
public void save(XWikiAttachment attachment, Date deleteDate, long index, boolean bTransaction) throws XWikiException {
XWikiContext xcontext = this.xcontextProvider.get();
final StartableTransactionRunnable tr = getSaveTrashAttachmentRunnable(attachment, index, xcontext);
new StartableTransactionRunnable().runIn(tr);
try {
tr.start();
} catch (Exception e) {
throw new XWikiException(XWikiException.MODULE_XWIKI_STORE, XWikiException.MODULE_XWIKI, "Failed to store deleted attachment [" + attachment.getReference() + "]", e);
}
}
Aggregations