public class FileDeleteTransactionRunnable extends StartableTransactionRunnable<TransactionRunnable>
Constructor and Description |
---|
FileDeleteTransactionRunnable(File toDelete,
File backupFile,
ReadWriteLock lock)
The Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
onComplete() |
protected void |
onPreRun() |
protected void |
onRollback() |
protected void |
onRun() |
start
asProvider, getProvidedContext
commit, complete, getContext, onCommit, preRun, rollback, run, runIn
public FileDeleteTransactionRunnable(File toDelete, File backupFile, ReadWriteLock lock)
toDelete
- the file to delete.backupFile
- a temporary file, this should not contain anything important as it will be deleted
and must not be altered while the operation is running. This will contain whatever
was in the toDelete file prior, just in case onRollback must be called.lock
- a ReadWriteLock whose writeLock will be locked as the beginning of the process and
unlocked when complete.protected void onPreRun() throws IOException
Obtain the lock and make sure the temporary and backup files are deleted.
onPreRun
in class TransactionRunnable<TransactionRunnable>
IOException
TransactionRunnable.onPreRun()
protected void onRun() throws IOException
onRun
in class TransactionRunnable<TransactionRunnable>
IOException
protected void onRollback()
There are a few possibilities. If preRun() has not completed then there may be an old backup from a previous delete, anyway if preRun() has not completed then we know there is nothing to rollback. Otherwise:
onRollback
in class TransactionRunnable<TransactionRunnable>
TransactionRunnable.onRollback()
protected void onComplete() throws IOException
Once this is called, there is no going back. Remove backup file and unlock the lock.
onComplete
in class TransactionRunnable<TransactionRunnable>
IOException
TransactionRunnable.onComplete()
Copyright © 2004–2019 XWiki. All rights reserved.