public final class IndirectFileCreateFileTransaction
extends java.lang.Object
Constructor and Description |
---|
IndirectFileCreateFileTransaction(java.io.File p_fileDst,
java.io.File p_fileSrc,
boolean p_bOverwriteExisting) |
Modifier and Type | Method and Description |
---|---|
void |
commit()
Commit the transaction.
|
java.io.File |
getBackup() |
java.io.File |
getDestinationFile()
Get the destination file.
|
java.lang.Throwable |
getLastError() |
java.io.File |
getSourceFile()
Get the source file.
|
boolean |
hasBackup() |
boolean |
requestCommit()
Request a file system transaction.
|
boolean |
rollback()
Try to rollback the file transaction.
|
java.lang.String |
toString() |
public IndirectFileCreateFileTransaction(java.io.File p_fileDst, java.io.File p_fileSrc, boolean p_bOverwriteExisting) throws java.io.IOException
p_fileDst
- The destination file.p_fileSrc
- The file used for create (must be a temporary file, because it
will always be deleted after rollback or commit).p_bOverwriteExisting
- true
if an existing file should be
overwritten, or false
otherwise.java.io.IOException
- If p_fileDst
or p_fileSrc
is not a file.public void commit()
ITwoPhaseTransaction
commit
in interface ITwoPhaseTransaction
public boolean rollback()
rollback
in interface ITwoPhaseTransaction
true
if the rollback was successful, or false
otherwise. In the latter case ITwoPhaseTransaction.getLastError()
may give additional
information about why the rollback failed, and a backup file may exist then.public boolean requestCommit()
ITwoPhaseTransaction
When this method returns true
it has sucessfully moved the source
file to it's new location, and has successfully created a backup copy of the
destination file, if it existed before.
requestCommit
in interface ITwoPhaseTransaction
public final java.io.File getDestinationFile()
p_fileDst
that was passed to the contructor.public final java.io.File getSourceFile()
p_fileSrc
that was passed to the contructor.public final boolean hasBackup()
hasBackup
in interface ITwoPhaseIOTransaction
true
if the transaction has left a backup file,
or false
otherwise (e.g. if the destination file
did not exist before the transaction).public final java.io.File getBackup()
getBackup
in interface ITwoPhaseIOTransaction
null
if none was created (e.g. if the destination
file did not exist before the transaction).public final java.lang.Throwable getLastError()
getLastError
in interface ITwoPhaseTransaction
null
if no error occurred;public java.lang.String toString()
toString
in class java.lang.Object