"RNTO", null));
return;
}
// get the "rename from" file object
FileObject frFile = session.getRenameFrom();
if (frFile == null) {
session.write(FtpReplyUtil.translate(session, request, context,
FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "RNTO",
null));
return;
}
// get target file
FileObject toFile = null;
try {
toFile = session.getFileSystemView().getFileObject(toFileStr);
} catch (Exception ex) {
LOG.debug("Exception getting file object", ex);
}
if (toFile == null) {
session
.write(FtpReplyUtil
.translate(
session,
request,
context,
FtpReply.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED,
"RNTO.invalid", null));
return;
}
toFileStr = toFile.getFullName();
// check permission
if (!toFile.hasWritePermission()) {
session
.write(FtpReplyUtil
.translate(
session,
request,
context,
FtpReply.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED,
"RNTO.permission", null));
return;
}
// check file existance
if (!frFile.doesExist()) {
session
.write(FtpReplyUtil
.translate(
session,
request,
context,
FtpReply.REPLY_553_REQUESTED_ACTION_NOT_TAKEN_FILE_NAME_NOT_ALLOWED,
"RNTO.missing", null));
return;
}
// now rename
if (frFile.move(toFile)) {
session.write(FtpReplyUtil.translate(session, request, context,
FtpReply.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "RNTO",
toFileStr));
LOG.info("File rename (" + session.getUser().getName() + ") "
+ frFile.getFullName() + " -> " + toFile.getFullName());
} else {
session
.write(FtpReplyUtil
.translate(