FileUtils.moveFile(sourceFile, destinationFile);
}
catch (IOException e)
{
// move didn't work - bail out (will attempt rollback)
throw new DefaultMuleException(FileMessages.failedToMoveFile(
sourceFile.getAbsolutePath(), destinationFile.getAbsolutePath()));
}
// create new Message for destinationFile
message = createMuleMessage(destinationFile, endpoint.getEncoding());
message.setOutboundProperty(FileConnector.PROPERTY_FILENAME, destinationFile.getName());
message.setOutboundProperty(FileConnector.PROPERTY_ORIGINAL_FILENAME, sourceFileOriginalName);
}
// finally deliver the file message
this.routeMessage(message);
// at this point msgAdapter either points to the old sourceFile
// or the new destinationFile.
if (((FileConnector) connector).isAutoDelete())
{
// no moveTo directory
if (destinationFile == null)
{
// delete source
if (!sourceFile.delete())
{
throw new DefaultMuleException(FileMessages.failedToDeleteFile(sourceFile));
}
}
else
{
// nothing to do here since moveFile() should have deleted