"MKD", null, null));
return;
}
// get file object
FtpFile file = null;
try {
file = session.getFileSystemView().getFile(fileName);
} catch (Exception ex) {
LOG.debug("Exception getting file object", ex);
}
if (file == null) {
session.write(LocalizedFileActionFtpReply.translate(session, request, context,
FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,
"MKD.invalid", fileName, file));
return;
}
// check permission
fileName = file.getAbsolutePath();
if (!file.isWritable()) {
session.write(LocalizedFileActionFtpReply.translate(session, request, context,
FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,
"MKD.permission", fileName, file));
return;
}
// check file existance
if (file.doesExist()) {
session.write(LocalizedFileActionFtpReply.translate(session, request, context,
FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,
"MKD.exists", fileName, file));
return;
}
// now create directory
if (file.mkdir()) {
session.write(LocalizedFileActionFtpReply.translate(session, request, context,
FtpReply.REPLY_257_PATHNAME_CREATED, "MKD", fileName, file));
// write log message
String userName = session.getUser().getName();