// status is OPEN
try {
outputStream.close();
} catch (IOException e) {
throw new LocalMailSystemException(e,
EnhancedStatus.TRANSIENT_LOCAL_ERROR_IN_PROCESSING);
}
Message message = new Message();
message.id = uid;
message.length = tempFile.length();
if (message.length == 0)
throw new LocalMailSystemException(
"Cannot retrieve file length " + tempFile,
EnhancedStatus.TRANSIENT_LOCAL_ERROR_IN_PROCESSING);
boolean success = tempFile.renameTo(finalFile);
if (!success) {
if (tempFile.delete()) {
throw new LocalMailSystemException(
"Cannot move temporary file to final "
+ "destination, but at least it could be deleted "
+ tempFile,
EnhancedStatus.TRANSIENT_LOCAL_ERROR_IN_PROCESSING);
} else {
throw new LocalMailSystemException(
"Cannot move temporary file to final destination, nor it can be deleted "
+ tempFile,
EnhancedStatus.TRANSIENT_LOCAL_ERROR_IN_PROCESSING);
}
}