session.closeOnFlush().awaitUninterruptibly(10000);
return;
}
// get file object
FileObject file = null;
try {
file = session.getFileSystemView().getFileObject(fileName);
}
catch(Exception ex) {
LOG.debug("Exception getting file object", ex);
}
if(file == null) {
session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD.invalid", fileName));
return;
}
// check permission
fileName = file.getFullName();
if( !file.hasWritePermission() ) {
session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD.permission", fileName));
return;
}
// check file existance
if(file.doesExist()) {
session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "MKD.exists", fileName));
return;
}
// now create directory
if(file.mkdir()) {
session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_257_PATHNAME_CREATED, "MKD", fileName));
// write log message
String userName = session.getUser().getName();
LOG.info("Directory create : " + userName + " - " + fileName);