You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ng...@apache.org on 2008/08/17 21:52:49 UTC
svn commit: r686637 [2/16] - in /mina/ftpserver/trunk:
core/src/main/java/org/apache/ftpserver/
core/src/main/java/org/apache/ftpserver/command/
core/src/main/java/org/apache/ftpserver/config/spring/
core/src/main/java/org/apache/ftpserver/filesystem/ ...
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/FtpSessionImpl.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/FtpSessionImpl.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/FtpSessionImpl.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/FtpSessionImpl.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver;
@@ -37,25 +37,28 @@
/**
* FTP session
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public class FtpSessionImpl implements FtpSession {
- private FtpIoSession ioSession;
-
+ private FtpIoSession ioSession;
+
/**
* Default constructor.
*/
public FtpSessionImpl(final FtpIoSession ioSession) {
this.ioSession = ioSession;
- }
-
+ }
+
/**
* Is logged-in
*/
public boolean isLoggedIn() {
return ioSession.isLoggedIn();
}
-
+
/**
* Get FTP data connection.
*/
@@ -69,42 +72,42 @@
public FileSystemView getFileSystemView() {
return ioSession.getFileSystemView();
}
-
+
/**
* Get connection time.
*/
public Date getConnectionTime() {
return new Date(ioSession.getCreationTime());
}
-
+
/**
* Get the login time.
*/
public Date getLoginTime() {
return ioSession.getLoginTime();
}
-
+
/**
* Get last access time.
*/
public Date getLastAccessTime() {
return ioSession.getLastAccessTime();
}
-
+
/**
* Get file offset.
*/
public long getFileOffset() {
return ioSession.getFileOffset();
}
-
+
/**
* Get rename from file object.
*/
public FileObject getRenameFrom() {
return ioSession.getRenameFrom();
}
-
+
/**
* Returns user name entered in USER command
*
@@ -120,49 +123,50 @@
public String getLanguage() {
return ioSession.getLanguage();
}
-
+
/**
* Get user.
*/
public User getUser() {
return ioSession.getUser();
}
-
+
/**
* Get remote address
*/
public InetAddress getClientAddress() {
- if(ioSession.getRemoteAddress() instanceof InetSocketAddress) {
- return ((InetSocketAddress)ioSession.getRemoteAddress()).getAddress();
+ if (ioSession.getRemoteAddress() instanceof InetSocketAddress) {
+ return ((InetSocketAddress) ioSession.getRemoteAddress())
+ .getAddress();
} else {
- return null;
+ return null;
}
}
-
-
/**
* Get attribute
*/
public Object getAttribute(final String name) {
- if(name.startsWith(FtpIoSession.ATTRIBUTE_PREFIX)) {
- throw new IllegalArgumentException("Illegal lookup of internal attribute");
- }
-
+ if (name.startsWith(FtpIoSession.ATTRIBUTE_PREFIX)) {
+ throw new IllegalArgumentException(
+ "Illegal lookup of internal attribute");
+ }
+
return ioSession.getAttribute(name);
}
-
+
/**
* Set attribute.
*/
public void setAttribute(final String name, final Object value) {
- if(name.startsWith(FtpIoSession.ATTRIBUTE_PREFIX)) {
- throw new IllegalArgumentException("Illegal setting of internal attribute");
- }
+ if (name.startsWith(FtpIoSession.ATTRIBUTE_PREFIX)) {
+ throw new IllegalArgumentException(
+ "Illegal setting of internal attribute");
+ }
- ioSession.setAttribute(name, value);
+ ioSession.setAttribute(name, value);
}
-
+
public int getMaxIdleTime() {
return ioSession.getMaxIdleTime();
}
@@ -177,31 +181,32 @@
public DataType getDataType() {
return ioSession.getDataType();
}
-
+
/**
* Get structure.
*/
public Structure getStructure() {
return ioSession.getStructure();
}
-
+
public Certificate[] getClientCertificates() {
return ioSession.getClientCertificates();
}
-
+
public InetAddress getServerAddress() {
- if(ioSession.getLocalAddress() instanceof InetSocketAddress) {
- return ((InetSocketAddress)ioSession.getLocalAddress()).getAddress();
+ if (ioSession.getLocalAddress() instanceof InetSocketAddress) {
+ return ((InetSocketAddress) ioSession.getLocalAddress())
+ .getAddress();
} else {
- return null;
+ return null;
}
}
public int getServerPort() {
- if(ioSession.getLocalAddress() instanceof InetSocketAddress) {
- return ((InetSocketAddress)ioSession.getLocalAddress()).getPort();
+ if (ioSession.getLocalAddress() instanceof InetSocketAddress) {
+ return ((InetSocketAddress) ioSession.getLocalAddress()).getPort();
} else {
- return 0;
+ return 0;
}
}
@@ -209,22 +214,22 @@
return ioSession.getFailedLogins();
}
- public void removeAttribute(final String name) {
- if(name.startsWith(FtpIoSession.ATTRIBUTE_PREFIX)) {
- throw new IllegalArgumentException("Illegal removal of internal attribute");
- }
-
- ioSession.removeAttribute(name);
- }
+ public void removeAttribute(final String name) {
+ if (name.startsWith(FtpIoSession.ATTRIBUTE_PREFIX)) {
+ throw new IllegalArgumentException(
+ "Illegal removal of internal attribute");
+ }
+
+ ioSession.removeAttribute(name);
+ }
public void write(FtpReply reply) throws FtpException {
- ioSession.write(reply);
+ ioSession.write(reply);
}
public boolean isSecure() {
// TODO Auto-generated method stub
return ioSession.isSecure();
}
-
-
+
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/FtpStatisticsImpl.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/FtpStatisticsImpl.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/FtpStatisticsImpl.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/FtpStatisticsImpl.java Sun Aug 17 12:52:42 2008
@@ -37,34 +37,46 @@
/**
* This is FTP statistics implementation.
*
- * TODO revisit concurrency, right now we're a bit zealous with both Atomix* counters
- * and synchronization
+ * TODO revisit concurrency, right now we're a bit over zealous with both Atomic*
+ * counters and synchronization
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public class FtpStatisticsImpl implements ServerFtpStatistics {
private StatisticsObserver observer = null;
+
private FileObserver fileObserver = null;
private Date startTime = new Date();
private AtomicInteger uploadCount = new AtomicInteger(0);
+
private AtomicInteger downloadCount = new AtomicInteger(0);
+
private AtomicInteger deleteCount = new AtomicInteger(0);
private AtomicInteger mkdirCount = new AtomicInteger(0);
+
private AtomicInteger rmdirCount = new AtomicInteger(0);
private AtomicInteger currLogins = new AtomicInteger(0);
+
private AtomicInteger totalLogins = new AtomicInteger(0);
+
private AtomicInteger totalFailedLogins = new AtomicInteger(0);
private AtomicInteger currAnonLogins = new AtomicInteger(0);
+
private AtomicInteger totalAnonLogins = new AtomicInteger(0);
private AtomicInteger currConnections = new AtomicInteger(0);
+
private AtomicInteger totalConnections = new AtomicInteger(0);
private AtomicLong bytesUpload = new AtomicLong(0L);
+
private AtomicLong bytesDownload = new AtomicLong(0L);
private static class UserLogins {
@@ -75,7 +87,7 @@
totalLogins = new AtomicInteger(1);
perAddress.put(address, new AtomicInteger(1));
}
-
+
public AtomicInteger loginsFromInetAddress(InetAddress address) {
AtomicInteger logins = perAddress.get(address);
if (logins == null) {
@@ -115,7 +127,7 @@
* Get server start time.
*/
public Date getStartTime() {
- if(startTime != null) {
+ if (startTime != null) {
return (Date) startTime.clone();
} else {
return null;
@@ -240,7 +252,8 @@
* @param ipAddress
* the ip address of the remote user
*/
- public synchronized int getCurrentUserLoginNumber(final User user, final InetAddress ipAddress) {
+ public synchronized int getCurrentUserLoginNumber(final User user,
+ final InetAddress ipAddress) {
UserLogins userLogins = userLoginTable.get(user.getName());
if (userLogins == null) {// not found the login user's statistics info
return 0;
@@ -254,7 +267,8 @@
/**
* Increment upload count.
*/
- public synchronized void setUpload(final FtpIoSession session, final FileObject file, final long size) {
+ public synchronized void setUpload(final FtpIoSession session,
+ final FileObject file, final long size) {
uploadCount.incrementAndGet();
bytesUpload.addAndGet(size);
notifyUpload(session, file, size);
@@ -263,7 +277,8 @@
/**
* Increment download count.
*/
- public synchronized void setDownload(final FtpIoSession session, final FileObject file, final long size) {
+ public synchronized void setDownload(final FtpIoSession session,
+ final FileObject file, final long size) {
downloadCount.incrementAndGet();
bytesDownload.addAndGet(size);
notifyDownload(session, file, size);
@@ -272,7 +287,8 @@
/**
* Increment delete count.
*/
- public synchronized void setDelete(final FtpIoSession session, final FileObject file) {
+ public synchronized void setDelete(final FtpIoSession session,
+ final FileObject file) {
deleteCount.incrementAndGet();
notifyDelete(session, file);
}
@@ -280,7 +296,8 @@
/**
* Increment make directory count.
*/
- public synchronized void setMkdir(final FtpIoSession session, final FileObject file) {
+ public synchronized void setMkdir(final FtpIoSession session,
+ final FileObject file) {
mkdirCount.incrementAndGet();
notifyMkdir(session, file);
}
@@ -288,7 +305,8 @@
/**
* Increment remove directory count.
*/
- public synchronized void setRmdir(final FtpIoSession session, final FileObject file) {
+ public synchronized void setRmdir(final FtpIoSession session,
+ final FileObject file) {
rmdirCount.incrementAndGet();
notifyRmdir(session, file);
}
@@ -325,15 +343,16 @@
}
synchronized (user) {// thread safety is needed. Since the login occurrs
- // at low frequency, this overhead is endurable
+ // at low frequency, this overhead is endurable
UserLogins statisticsTable = userLoginTable.get(user.getName());
if (statisticsTable == null) {
// the hash table that records the login information of the user
// and its ip address.
-
+
InetAddress address = null;
if (session.getRemoteAddress() instanceof InetSocketAddress) {
- address = ((InetSocketAddress) session.getRemoteAddress()).getAddress();
+ address = ((InetSocketAddress) session.getRemoteAddress())
+ .getAddress();
}
statisticsTable = new UserLogins(address);
userLoginTable.put(user.getName(), statisticsTable);
@@ -341,8 +360,10 @@
statisticsTable.totalLogins.incrementAndGet();
if (session.getRemoteAddress() instanceof InetSocketAddress) {
- InetAddress address = ((InetSocketAddress) session.getRemoteAddress()).getAddress();
- statisticsTable.loginsFromInetAddress(address).incrementAndGet();
+ InetAddress address = ((InetSocketAddress) session
+ .getRemoteAddress()).getAddress();
+ statisticsTable.loginsFromInetAddress(address)
+ .incrementAndGet();
}
}
@@ -380,7 +401,8 @@
if (userLogins != null) {
userLogins.totalLogins.decrementAndGet();
if (session.getRemoteAddress() instanceof InetSocketAddress) {
- InetAddress address = ((InetSocketAddress) session.getRemoteAddress()).getAddress();
+ InetAddress address = ((InetSocketAddress) session
+ .getRemoteAddress()).getAddress();
userLogins.loginsFromInetAddress(address).decrementAndGet();
}
}
@@ -395,7 +417,8 @@
/**
* Observer upload notification.
*/
- private void notifyUpload(final FtpIoSession session, final FileObject file, long size) {
+ private void notifyUpload(final FtpIoSession session,
+ final FileObject file, long size) {
StatisticsObserver observer = this.observer;
if (observer != null) {
observer.notifyUpload();
@@ -410,7 +433,8 @@
/**
* Observer download notification.
*/
- private void notifyDownload(final FtpIoSession session, final FileObject file, final long size) {
+ private void notifyDownload(final FtpIoSession session,
+ final FileObject file, final long size) {
StatisticsObserver observer = this.observer;
if (observer != null) {
observer.notifyDownload();
@@ -512,7 +536,8 @@
StatisticsObserver observer = this.observer;
if (observer != null) {
if (session.getRemoteAddress() instanceof InetSocketAddress) {
- observer.notifyLoginFail(((InetSocketAddress) session.getRemoteAddress()).getAddress());
+ observer.notifyLoginFail(((InetSocketAddress) session
+ .getRemoteAddress()).getAddress());
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/IODataConnection.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/IODataConnection.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/IODataConnection.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/IODataConnection.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver;
@@ -36,86 +36,92 @@
import org.apache.ftpserver.usermanager.TransferRateRequest;
import org.apache.ftpserver.util.IoUtils;
-
/**
- * An active open data connection, used for transfering data over the
- * data connection.
+ * An active open data connection, used for transfering data over the data
+ * connection.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class IODataConnection implements DataConnection {
-
+public class IODataConnection implements DataConnection {
+
private FtpIoSession session;
+
private Socket socket;
+
private ServerDataConnectionFactory factory;
-
- public IODataConnection(final Socket socket, final FtpIoSession session, final ServerDataConnectionFactory factory) {
+
+ public IODataConnection(final Socket socket, final FtpIoSession session,
+ final ServerDataConnectionFactory factory) {
this.session = session;
this.socket = socket;
this.factory = factory;
}
-
/**
* Get data input stream. The return value will never be null.
*/
private InputStream getDataInputStream() throws IOException {
try {
-
+
// get data socket
Socket dataSoc = socket;
- if(dataSoc == null) {
+ if (dataSoc == null) {
throw new IOException("Cannot open data connection.");
}
-
+
// create input stream
InputStream is = dataSoc.getInputStream();
- if(factory.isZipMode()) {
+ if (factory.isZipMode()) {
is = new InflaterInputStream(is);
}
return is;
- }
- catch(IOException ex) {
+ } catch (IOException ex) {
factory.closeDataConnection();
throw ex;
}
}
-
+
/**
* Get data output stream. The return value will never be null.
*/
private OutputStream getDataOutputStream() throws IOException {
try {
-
+
// get data socket
Socket dataSoc = socket;
- if(dataSoc == null) {
+ if (dataSoc == null) {
throw new IOException("Cannot open data connection.");
}
-
+
// create output stream
OutputStream os = dataSoc.getOutputStream();
- if(factory.isZipMode()) {
+ if (factory.isZipMode()) {
os = new DeflaterOutputStream(os);
}
return os;
- }
- catch(IOException ex) {
+ } catch (IOException ex) {
factory.closeDataConnection();
throw ex;
}
}
-
- /* (non-Javadoc)
- * @see org.apache.ftpserver.FtpDataConnection2#transferFromClient(java.io.OutputStream)
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.apache.ftpserver.FtpDataConnection2#transferFromClient(java.io.
+ * OutputStream)
*/
- public final long transferFromClient(final OutputStream out) throws IOException {
+ public final long transferFromClient(final OutputStream out)
+ throws IOException {
TransferRateRequest transferRateRequest = new TransferRateRequest();
- transferRateRequest = (TransferRateRequest) session.getUser().authorize(transferRateRequest);
+ transferRateRequest = (TransferRateRequest) session.getUser()
+ .authorize(transferRateRequest);
int maxRate = 0;
- if(transferRateRequest != null) {
+ if (transferRateRequest != null) {
maxRate = transferRateRequest.getMaxUploadRate();
}
-
+
InputStream is = getDataInputStream();
try {
return transfer(is, out, maxRate);
@@ -124,17 +130,22 @@
}
}
- /* (non-Javadoc)
- * @see org.apache.ftpserver.FtpDataConnection2#transferToClient(java.io.InputStream)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.ftpserver.FtpDataConnection2#transferToClient(java.io.InputStream
+ * )
*/
public final long transferToClient(final InputStream in) throws IOException {
TransferRateRequest transferRateRequest = new TransferRateRequest();
- transferRateRequest = (TransferRateRequest) session.getUser().authorize(transferRateRequest);
+ transferRateRequest = (TransferRateRequest) session.getUser()
+ .authorize(transferRateRequest);
int maxRate = 0;
- if(transferRateRequest != null) {
+ if (transferRateRequest != null) {
maxRate = transferRateRequest.getMaxDownloadRate();
}
-
+
OutputStream out = getDataOutputStream();
try {
return transfer(in, out, maxRate);
@@ -142,9 +153,13 @@
IoUtils.close(out);
}
}
-
- /* (non-Javadoc)
- * @see org.apache.ftpserver.FtpDataConnection2#transferToClient(java.lang.String)
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.ftpserver.FtpDataConnection2#transferToClient(java.lang.String
+ * )
*/
public final void transferToClient(final String str) throws IOException {
OutputStream out = getDataOutputStream();
@@ -153,98 +168,102 @@
writer = new OutputStreamWriter(out, "UTF-8");
writer.write(str);
} finally {
- if(writer != null) {
+ if (writer != null) {
writer.flush();
}
IoUtils.close(writer);
}
-
+
}
-
- private final long transfer(final InputStream in, final OutputStream out, final int maxRate) throws IOException {
+
+ private final long transfer(final InputStream in, final OutputStream out,
+ final int maxRate) throws IOException {
long transferredSize = 0L;
boolean isAscii = session.getDataType() == DataType.ASCII;
long startTime = System.currentTimeMillis();
byte[] buff = new byte[4096];
-
+
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
bis = IoUtils.getBufferedInputStream(in);
-
- bos = IoUtils.getBufferedOutputStream( out );
-
+
+ bos = IoUtils.getBufferedOutputStream(out);
+
boolean lastWasCR = false;
- while(true) {
-
- // if current rate exceeds the max rate, sleep for 50ms
+ while (true) {
+
+ // if current rate exceeds the max rate, sleep for 50ms
// and again check the current transfer rate
- if(maxRate > 0) {
-
+ if (maxRate > 0) {
+
// prevent "divide by zero" exception
long interval = System.currentTimeMillis() - startTime;
- if(interval == 0) {
+ if (interval == 0) {
interval = 1;
}
-
+
// check current rate
- long currRate = (transferredSize*1000L)/interval;
- if(currRate > maxRate) {
- try { Thread.sleep(50); } catch(InterruptedException ex) {break;}
+ long currRate = (transferredSize * 1000L) / interval;
+ if (currRate > maxRate) {
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException ex) {
+ break;
+ }
continue;
}
}
-
+
// read data
int count = bis.read(buff);
-
- if(count == -1) {
+
+ if (count == -1) {
break;
}
-
+
// write data
// if ascii, replace \n by \r\n
- if(isAscii) {
- for(int i=0; i<count; ++i) {
+ if (isAscii) {
+ for (int i = 0; i < count; ++i) {
byte b = buff[i];
- if(b == '\n' && !lastWasCR) {
+ if (b == '\n' && !lastWasCR) {
bos.write('\r');
- }
-
- if(b == '\r') {
+ }
+
+ if (b == '\r') {
lastWasCR = true;
} else {
lastWasCR = false;
}
bos.write(b);
}
- }
- else {
+ } else {
bos.write(buff, 0, count);
}
-
+
transferredSize += count;
-
+
notifyObserver();
}
} finally {
- if(bos != null) {
+ if (bos != null) {
bos.flush();
}
}
return transferredSize;
}
-
+
/**
* Notify connection manager observer.
*/
protected void notifyObserver() {
session.updateLastAccessTime();
-
- // TODO this has been moved from AbstractConnection, do we need to keep it?
+
+ // TODO this has been moved from AbstractConnection, do we need to keep
+ // it?
// serverContext.getConnectionManager().updateConnection(this);
}
}
-
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/IODataConnectionFactory.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/IODataConnectionFactory.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/IODataConnectionFactory.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/IODataConnectionFactory.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver;
@@ -42,201 +42,234 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
/**
- * We can get the ftp data connection using this class.
- * It uses either PORT or PASV command.
+ * We can get the FTP data connection using this class. It uses either PORT or
+ * PASV command.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public class IODataConnectionFactory implements ServerDataConnectionFactory {
-
- private final Logger LOG = LoggerFactory.getLogger(IODataConnectionFactory.class);
-
- private FtpServerContext serverContext;
- private Socket dataSoc;
- ServerSocket servSoc;
-
- InetAddress address;
- int port = 0;
-
+
+ private final Logger LOG = LoggerFactory
+ .getLogger(IODataConnectionFactory.class);
+
+ private FtpServerContext serverContext;
+
+ private Socket dataSoc;
+
+ ServerSocket servSoc;
+
+ InetAddress address;
+
+ int port = 0;
+
long requestTime = 0L;
-
- boolean passive = false;
-
- boolean secure = false;
- private boolean isZip = false;
+
+ boolean passive = false;
+
+ boolean secure = false;
+
+ private boolean isZip = false;
InetAddress serverControlAddress;
FtpIoSession session;
-
- public IODataConnectionFactory(final FtpServerContext serverContext, final FtpIoSession session) {
+
+ public IODataConnectionFactory(final FtpServerContext serverContext,
+ final FtpIoSession session) {
this.session = session;
this.serverContext = serverContext;
-
+
}
-
/**
* Close data socket.
*/
public synchronized void closeDataConnection() {
-
+
// close client socket if any
- if(dataSoc != null) {
+ if (dataSoc != null) {
try {
- dataSoc.close();
- }
- catch(Exception ex) {
+ dataSoc.close();
+ } catch (Exception ex) {
LOG.warn("FtpDataConnection.closeDataSocket()", ex);
}
dataSoc = null;
}
-
+
// close server socket if any
if (servSoc != null) {
try {
- servSoc.close();
- }
- catch(Exception ex) {
+ servSoc.close();
+ } catch (Exception ex) {
LOG.warn("FtpDataConnection.closeDataSocket()", ex);
}
-
+
FtpServerContext ctx = serverContext;
-
- if(ctx != null) {
- DataConnectionConfiguration dcc = session.getListener().getDataConnectionConfiguration();
- if(dcc != null) {
+
+ if (ctx != null) {
+ DataConnectionConfiguration dcc = session.getListener()
+ .getDataConnectionConfiguration();
+ if (dcc != null) {
dcc.releasePassivePort(port);
}
}
-
+
servSoc = null;
}
-
+
// reset request time
requestTime = 0L;
}
-
+
/**
* Port command.
*/
- public synchronized void initActiveDataConnection(final InetSocketAddress address) {
-
+ public synchronized void initActiveDataConnection(
+ final InetSocketAddress address) {
+
// close old sockets if any
closeDataConnection();
-
+
// set variables
passive = false;
this.address = address.getAddress();
port = address.getPort();
requestTime = System.currentTimeMillis();
- }
-
+ }
+
/**
- * Initiate a data connection in passive mode (server listening).
- * It returns the success flag.
+ * Initiate a data connection in passive mode (server listening). It returns
+ * the success flag.
*/
- public synchronized InetSocketAddress initPassiveDataConnection() throws DataConnectionException {
+ public synchronized InetSocketAddress initPassiveDataConnection()
+ throws DataConnectionException {
LOG.debug("Initiating passive data connection");
// close old sockets if any
- closeDataConnection();
-
+ closeDataConnection();
+
// get the passive port
- int passivePort = session.getListener().getDataConnectionConfiguration().requestPassivePort();
- if(passivePort == -1) {
+ int passivePort = session.getListener()
+ .getDataConnectionConfiguration().requestPassivePort();
+ if (passivePort == -1) {
servSoc = null;
- throw new DataConnectionException("Cannot find an available passive port.");
+ throw new DataConnectionException(
+ "Cannot find an available passive port.");
}
-
+
// open passive server socket and get parameters
try {
- DataConnectionConfiguration dataCfg = session.getListener().getDataConnectionConfiguration();
+ DataConnectionConfiguration dataCfg = session.getListener()
+ .getDataConnectionConfiguration();
address = dataCfg.getPassiveAddress();
- if(address == null) {
+ if (address == null) {
address = serverControlAddress;
}
- if(secure) {
- LOG.debug("Opening SSL passive data connection on address \"{}\" and port {}", address, passivePort);
+ if (secure) {
+ LOG
+ .debug(
+ "Opening SSL passive data connection on address \"{}\" and port {}",
+ address, passivePort);
SslConfiguration ssl = dataCfg.getSslConfiguration();
- if(ssl == null) {
- throw new DataConnectionException("Data connection SSL required but not configured.");
+ if (ssl == null) {
+ throw new DataConnectionException(
+ "Data connection SSL required but not configured.");
}
servSoc = createServerSocket(ssl, address, passivePort);
port = servSoc.getLocalPort();
- LOG.debug("SSL Passive data connection created on address \"{}\" and port {}", address, passivePort);
- }
- else {
- LOG.debug("Opening passive data connection on address \"{}\" and port {}", address, passivePort);
+ LOG
+ .debug(
+ "SSL Passive data connection created on address \"{}\" and port {}",
+ address, passivePort);
+ } else {
+ LOG
+ .debug(
+ "Opening passive data connection on address \"{}\" and port {}",
+ address, passivePort);
servSoc = new ServerSocket(passivePort, 0, address);
port = servSoc.getLocalPort();
- LOG.debug("Passive data connection created on address \"{}\" and port {}", address, passivePort);
+ LOG
+ .debug(
+ "Passive data connection created on address \"{}\" and port {}",
+ address, passivePort);
}
servSoc.setSoTimeout(dataCfg.getIdleTime() * 1000);
// set different state variables
passive = true;
requestTime = System.currentTimeMillis();
-
+
return new InetSocketAddress(address, port);
- }
- catch(Exception ex) {
+ } catch (Exception ex) {
servSoc = null;
closeDataConnection();
- throw new DataConnectionException("Failed to initate passive data connection: " + ex.getMessage(), ex);
+ throw new DataConnectionException(
+ "Failed to initate passive data connection: "
+ + ex.getMessage(), ex);
}
}
-
- private ServerSocket createServerSocket(final SslConfiguration ssl, final InetAddress address2, final int passivePort) throws IOException, GeneralSecurityException {
+
+ private ServerSocket createServerSocket(final SslConfiguration ssl,
+ final InetAddress address2, final int passivePort)
+ throws IOException, GeneralSecurityException {
// get server socket factory
SSLContext ctx = ssl.getSSLContext();
SSLServerSocketFactory ssocketFactory = ctx.getServerSocketFactory();
-
+
// create server socket
SSLServerSocket sslServerSocket = null;
- if(address2 == null) {
- sslServerSocket = (SSLServerSocket) ssocketFactory.createServerSocket(passivePort, 100);
+ if (address2 == null) {
+ sslServerSocket = (SSLServerSocket) ssocketFactory
+ .createServerSocket(passivePort, 100);
} else {
- sslServerSocket = (SSLServerSocket) ssocketFactory.createServerSocket(passivePort, 100, address2);
+ sslServerSocket = (SSLServerSocket) ssocketFactory
+ .createServerSocket(passivePort, 100, address2);
}
-
+
// initialize server socket
- if(ssl.getClientAuth() == ClientAuth.NEED) {
+ if (ssl.getClientAuth() == ClientAuth.NEED) {
sslServerSocket.setNeedClientAuth(true);
- } else if(ssl.getClientAuth() == ClientAuth.WANT) {
+ } else if (ssl.getClientAuth() == ClientAuth.WANT) {
sslServerSocket.setWantClientAuth(true);
}
-
- if(ssl.getEnabledCipherSuites() != null) {
- sslServerSocket.setEnabledCipherSuites(ssl.getEnabledCipherSuites());
+ if (ssl.getEnabledCipherSuites() != null) {
+ sslServerSocket
+ .setEnabledCipherSuites(ssl.getEnabledCipherSuites());
}
return sslServerSocket;
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ftpserver.FtpDataConnectionFactory2#getInetAddress()
*/
public InetAddress getInetAddress() {
return address;
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ftpserver.FtpDataConnectionFactory2#getPort()
*/
public int getPort() {
return port;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ftpserver.FtpDataConnectionFactory2#openConnection()
*/
public DataConnection openConnection() throws Exception {
return new IODataConnection(createDataSocket(), session, this);
}
-
+
/**
* Get the data socket. In case of error returns null.
*/
@@ -244,30 +277,34 @@
// get socket depending on the selection
dataSoc = null;
- DataConnectionConfiguration dataConfig = session.getListener().getDataConnectionConfiguration();
+ DataConnectionConfiguration dataConfig = session.getListener()
+ .getDataConnectionConfiguration();
try {
- if(!passive) {
+ if (!passive) {
int localPort = dataConfig.getActiveLocalPort();
- if(secure) {
+ if (secure) {
SslConfiguration ssl = dataConfig.getSslConfiguration();
- if(ssl == null) {
- throw new FtpException("Data connection SSL not configured");
+ if (ssl == null) {
+ throw new FtpException(
+ "Data connection SSL not configured");
}
- if(localPort == 0) {
- dataSoc = createSocket(ssl, address, port, null, localPort, false);
+ if (localPort == 0) {
+ dataSoc = createSocket(ssl, address, port, null,
+ localPort, false);
+ } else {
+ InetAddress localAddr = dataConfig
+ .getActiveLocalAddress();
+ dataSoc = createSocket(ssl, address, port, localAddr,
+ localPort, false);
}
- else {
- InetAddress localAddr = dataConfig.getActiveLocalAddress();
- dataSoc = createSocket(ssl, address, port, localAddr, localPort, false);
- }
- }
- else {
- if(localPort == 0) {
- dataSoc = new Socket(address, port);
- }
- else {
- InetAddress localAddr = dataConfig.getActiveLocalAddress();
- dataSoc = new Socket(address, port, localAddr, localPort);
+ } else {
+ if (localPort == 0) {
+ dataSoc = new Socket(address, port);
+ } else {
+ InetAddress localAddr = dataConfig
+ .getActiveLocalAddress();
+ dataSoc = new Socket(address, port, localAddr,
+ localPort);
}
}
} else {
@@ -275,117 +312,122 @@
dataSoc = servSoc.accept();
LOG.debug("Passive data connection opened");
}
- }
- catch(Exception ex) {
+ } catch (Exception ex) {
closeDataConnection();
LOG.warn("FtpDataConnection.getDataSocket()", ex);
throw ex;
}
-
+
// Make sure we initate the SSL handshake, or we'll
// get an error if we turn out not to send any data
// e.g. during the listing of an empty dir
- if(dataSoc instanceof SSLSocket) {
- ((SSLSocket)dataSoc).startHandshake();
+ if (dataSoc instanceof SSLSocket) {
+ ((SSLSocket) dataSoc).startHandshake();
}
-
+
return dataSoc;
}
-
- private Socket createSocket(final SslConfiguration ssl, final InetAddress address2,
- final int port2, final InetAddress localAddress, final int localPort, final boolean clientMode) throws IOException, GeneralSecurityException {
-
+
+ private Socket createSocket(final SslConfiguration ssl,
+ final InetAddress address2, final int port2,
+ final InetAddress localAddress, final int localPort,
+ final boolean clientMode) throws IOException,
+ GeneralSecurityException {
+
// get socket factory
SSLContext ctx = ssl.getSSLContext();
SSLSocketFactory socFactory = ctx.getSocketFactory();
-
+
// create socket
SSLSocket ssoc;
- if(localPort != 0) {
- ssoc = (SSLSocket)socFactory.createSocket(address2, port2);
+ if (localPort != 0) {
+ ssoc = (SSLSocket) socFactory.createSocket(address2, port2);
} else {
- ssoc = (SSLSocket)socFactory.createSocket(address2, port2, localAddress, localPort);
+ ssoc = (SSLSocket) socFactory.createSocket(address2, port2,
+ localAddress, localPort);
}
ssoc.setUseClientMode(clientMode);
-
-
+
// initialize socket
- if(ssl.getEnabledCipherSuites() != null) {
+ if (ssl.getEnabledCipherSuites() != null) {
ssoc.setEnabledCipherSuites(ssl.getEnabledCipherSuites());
}
return ssoc;
}
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ftpserver.DataConnectionFactory#isSecure()
*/
public boolean isSecure() {
return secure;
}
-
+
/**
* Set the security protocol.
*/
public void setSecure(final boolean secure) {
this.secure = secure;
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.apache.ftpserver.DataConnectionFactory#isZipMode()
*/
public boolean isZipMode() {
return isZip;
}
-
+
/**
* Set zip mode.
*/
public void setZipMode(final boolean zip) {
isZip = zip;
}
-
+
/**
* Check the data connection idle status.
*/
public synchronized boolean isTimeout(final long currTime) {
-
+
// data connection not requested - not a timeout
- if(requestTime == 0L) {
+ if (requestTime == 0L) {
return false;
}
-
+
// data connection active - not a timeout
- if(dataSoc != null) {
+ if (dataSoc != null) {
return false;
}
-
+
// no idle time limit - not a timeout
- int maxIdleTime = session.getListener().getDataConnectionConfiguration().getIdleTime() * 1000;
- if(maxIdleTime == 0) {
+ int maxIdleTime = session.getListener()
+ .getDataConnectionConfiguration().getIdleTime() * 1000;
+ if (maxIdleTime == 0) {
return false;
}
-
+
// idle time is within limit - not a timeout
- if( (currTime - requestTime) < maxIdleTime ) {
+ if ((currTime - requestTime) < maxIdleTime) {
return false;
}
-
+
return true;
}
-
+
/**
* Dispose data connection - close all the sockets.
- */
+ */
public void dispose() {
closeDataConnection();
}
/**
- * Sets the server's control address.
+ * Sets the server's control address.
*/
public void setServerControlAddress(final InetAddress serverControlAddress) {
this.serverControlAddress = serverControlAddress;
}
}
-
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/PassivePorts.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/PassivePorts.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/PassivePorts.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/PassivePorts.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver;
@@ -24,90 +24,100 @@
import java.util.List;
import java.util.StringTokenizer;
-
/**
- * Provides support for parsing a passive ports string as well as
- * keeping track of reserved passive ports.
+ * Provides support for parsing a passive ports string as well as keeping track
+ * of reserved passive ports.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public class PassivePorts {
private static final int MAX_PORT = 65535;
+
private int[] passivePorts;
+
private boolean[] reservedPorts;
+
private String passivePortsString;
-
+
/**
* Parse a string containing passive ports
- * @param portsString A string of passive ports, can contain a single
- * port (as an integer), multiple ports seperated by commas (e.g. 123,124,125)
- * or ranges of ports, including open ended ranges (e.g. 123-125, 30000-, -1023).
- * Combinations for single ports and ranges is also supported.
+ *
+ * @param portsString
+ * A string of passive ports, can contain a single port (as an
+ * integer), multiple ports seperated by commas (e.g.
+ * 123,124,125) or ranges of ports, including open ended ranges
+ * (e.g. 123-125, 30000-, -1023). Combinations for single ports
+ * and ranges is also supported.
* @return An instance of {@link PassivePorts} based on the parsed string
- * @throws IllegalArgumentException If any of of the ports in the string is
- * invalid (e.g. not an integer or too large for a port number)
+ * @throws IllegalArgumentException
+ * If any of of the ports in the string is invalid (e.g. not an
+ * integer or too large for a port number)
*/
private static int[] parse(final String portsString) {
List<Integer> passivePortsList = new ArrayList<Integer>();
-
+
boolean inRange = false;
Integer lastPort = 1;
StringTokenizer st = new StringTokenizer(portsString, ",;-", true);
- while(st.hasMoreTokens()) {
+ while (st.hasMoreTokens()) {
String token = st.nextToken().trim();
- if(",".equals(token) || ";".equals(token)) {
- if(inRange) {
+ if (",".equals(token) || ";".equals(token)) {
+ if (inRange) {
fillRange(passivePortsList, lastPort, MAX_PORT);
}
-
+
// reset state
lastPort = 1;
inRange = false;
- } else if("-".equals(token)) {
+ } else if ("-".equals(token)) {
inRange = true;
- } else if(token.length() == 0) {
+ } else if (token.length() == 0) {
// ignore whitespace
} else {
Integer port = Integer.valueOf(token);
-
+
verifyPort(port.intValue());
-
- if(inRange) {
+
+ if (inRange) {
// add all numbers from last int
fillRange(passivePortsList, lastPort, port);
-
+
inRange = false;
}
-
+
addPort(passivePortsList, port);
-
+
lastPort = port;
}
}
-
- if(inRange) {
+
+ if (inRange) {
fillRange(passivePortsList, lastPort, MAX_PORT);
}
-
+
int[] passivePorts = new int[passivePortsList.size()];
-
+
Iterator<Integer> iter = passivePortsList.iterator();
-
+
int counter = 0;
while (iter.hasNext()) {
Integer port = iter.next();
passivePorts[counter] = port.intValue();
counter++;
}
-
+
return passivePorts;
}
/**
* Fill a range of ports
*/
- private static void fillRange(final List<Integer> passivePortsList, final Integer beginPort, final Integer endPort) {
- for(int i = beginPort.intValue(); i<=endPort.intValue(); i++ ) {
+ private static void fillRange(final List<Integer> passivePortsList,
+ final Integer beginPort, final Integer endPort) {
+ for (int i = beginPort.intValue(); i <= endPort.intValue(); i++) {
addPort(passivePortsList, i);
}
}
@@ -115,56 +125,58 @@
/**
* Add a single port if not already in list
*/
- private static void addPort(final List<Integer> passivePortsList, final Integer rangePort) {
- if(!passivePortsList.contains(rangePort)) {
+ private static void addPort(final List<Integer> passivePortsList,
+ final Integer rangePort) {
+ if (!passivePortsList.contains(rangePort)) {
passivePortsList.add(rangePort);
}
}
-
+
/**
* Verify that the port is within the range of allowed ports
*/
private static void verifyPort(final int port) {
- if(port < 0) {
- throw new IllegalArgumentException("Port can not be negative: " + port);
- } else if(port > MAX_PORT) {
+ if (port < 0) {
+ throw new IllegalArgumentException("Port can not be negative: "
+ + port);
+ } else if (port > MAX_PORT) {
throw new IllegalArgumentException("Port too large: " + port);
}
}
-
+
public PassivePorts(final String passivePorts) {
this(parse(passivePorts));
-
+
this.passivePortsString = passivePorts;
}
public PassivePorts(final int[] passivePorts) {
- if(passivePorts != null) {
+ if (passivePorts != null) {
this.passivePorts = passivePorts.clone();
} else {
this.passivePorts = null;
}
-
+
reservedPorts = new boolean[passivePorts.length];
}
-
+
public int reserveNextPort() {
- // search for a free port
- for(int i=0; i<passivePorts.length; i++) {
- if(!reservedPorts[i]) {
- if(passivePorts[i] != 0) {
+ // search for a free port
+ for (int i = 0; i < passivePorts.length; i++) {
+ if (!reservedPorts[i]) {
+ if (passivePorts[i] != 0) {
reservedPorts[i] = true;
}
return passivePorts[i];
}
}
-
+
return -1;
}
-
+
public void releasePort(final int port) {
- for(int i=0; i<passivePorts.length; i++) {
- if(passivePorts[i] == port) {
+ for (int i = 0; i < passivePorts.length; i++) {
+ if (passivePorts[i] == port) {
reservedPorts[i] = false;
break;
}
@@ -173,12 +185,12 @@
@Override
public String toString() {
- if(passivePortsString != null) {
+ if (passivePortsString != null) {
return passivePortsString;
} else {
StringBuffer sb = new StringBuffer();
-
- for(int port : passivePorts) {
+
+ for (int port : passivePorts) {
sb.append(port);
sb.append(",");
}
@@ -188,6 +200,4 @@
}
}
-
-
}
\ No newline at end of file
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ServerDataConnectionFactory.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ServerDataConnectionFactory.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ServerDataConnectionFactory.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/ServerDataConnectionFactory.java Sun Aug 17 12:52:42 2008
@@ -24,6 +24,13 @@
import org.apache.ftpserver.ftplet.DataConnectionFactory;
+/**
+ *
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
+ *
+ */
public interface ServerDataConnectionFactory extends DataConnectionFactory {
/**
@@ -32,11 +39,13 @@
void initActiveDataConnection(InetSocketAddress address);
/**
- * Initate the passive data connection.
- * @return The {@link InetSocketAddress} on which the data connection
- * if bound.
+ * Initate the passive data connection.
+ *
+ * @return The {@link InetSocketAddress} on which the data connection if
+ * bound.
*/
- InetSocketAddress initPassiveDataConnection() throws DataConnectionException;
+ InetSocketAddress initPassiveDataConnection()
+ throws DataConnectionException;
/**
* Set the security protocol.
@@ -44,7 +53,7 @@
void setSecure(boolean secure);
/**
- * Sets the server's control address.
+ * Sets the server's control address.
*/
void setServerControlAddress(InetAddress serverControlAddress);
@@ -54,12 +63,11 @@
* Check the data connection idle status.
*/
boolean isTimeout(long currTime);
-
+
/**
* Dispose data connection - close all the sockets.
*/
void dispose();
-
/**
* Is secure?
@@ -70,7 +78,6 @@
* Is zip mode?
*/
boolean isZipMode();
-
/**
* Get client address.
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/ABOR.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/ABOR.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/ABOR.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/ABOR.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -29,31 +29,32 @@
/**
* <code>ABOR <CRLF></code><br>
+ *
+ * This command tells the server to abort the previous FTP service command and
+ * any associated transfer of data. No action is to be taken if the previous
+ * command has been completed (including data transfer). The control connection
+ * is not to be closed by the server, but the data connection must be closed.
+ * Current implementation does not do anything. As here data transfers are not
+ * multi-threaded.
*
- * This command tells the server to abort the previous FTP
- * service command and any associated transfer of data.
- * No action is to be taken if the previous command
- * has been completed (including data transfer). The control
- * connection is not to be closed by the server, but the data
- * connection must be closed.
- * Current implementation does not do anything. As here data
- * transfers are not multi-threaded.
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class ABOR extends AbstractCommand {
+public class ABOR extends AbstractCommand {
/**
* Execute command
*/
- public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException {
-
+ public void execute(final FtpIoSession session,
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException {
+
// reset state variables
session.resetState();
-
+
// and abort any data connection
session.getDataConnection().closeDataConnection();
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "ABOR", null));
- }
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "ABOR", null));
+ }
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/ACCT.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/ACCT.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/ACCT.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/ACCT.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -29,25 +29,27 @@
/**
* <code>ACCT <CRLF></code><br>
+ *
+ * Acknowledges the ACCT (account) command with a 202 reply. The command however
+ * is irrelevant to any workings.
*
- * Acknowledges the ACCT (account) command with a 202 reply.
- * The command however is irrelevant to any workings.
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class ACCT extends AbstractCommand {
+public class ACCT extends AbstractCommand {
/**
* Execute command.
*/
public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException {
-
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException {
+
// reset state variables
session.resetState();
-
+
// and abort any data connection
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_202_COMMAND_NOT_IMPLEMENTED, "ACCT", null));
- }
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_202_COMMAND_NOT_IMPLEMENTED, "ACCT", null));
+ }
}
-
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/APPE.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/APPE.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/APPE.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/APPE.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -42,132 +42,160 @@
/**
* <code>APPE <SP> <pathname> <CRLF></code><br>
+ *
+ * This command causes the server-DTP to accept the data transferred via the
+ * data connection and to store the data in a file at the server site. If the
+ * file specified in the pathname exists at the server site, then the data shall
+ * be appended to that file; otherwise the file specified in the pathname shall
+ * be created at the server site.
*
- * This command causes the server-DTP to accept the data
- * transferred via the data connection and to store the data in
- * a file at the server site. If the file specified in the
- * pathname exists at the server site, then the data shall be
- * appended to that file; otherwise the file specified in the
- * pathname shall be created at the server site.
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class APPE extends AbstractCommand {
-
+public class APPE extends AbstractCommand {
+
private final Logger LOG = LoggerFactory.getLogger(APPE.class);
-
+
/**
* Execute command.
*/
public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException, FtpException {
-
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException, FtpException {
+
try {
-
+
// reset state variables
session.resetState();
-
+
// argument check
String fileName = request.getArgument();
- if(fileName == null) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "APPE", null));
- return;
+ if (fileName == null) {
+ session
+ .write(FtpReplyUtil
+ .translate(
+ session,
+ request,
+ context,
+ FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,
+ "APPE", null));
+ return;
}
-
- // 24-10-2007 - added check if PORT or PASV is issued, see https://issues.apache.org/jira/browse/FTPSERVER-110
+
+ // 24-10-2007 - added check if PORT or PASV is issued, see
+ // https://issues.apache.org/jira/browse/FTPSERVER-110
DataConnectionFactory connFactory = session.getDataConnection();
if (connFactory instanceof IODataConnectionFactory) {
- InetAddress address = ((IODataConnectionFactory)connFactory).getInetAddress();
+ InetAddress address = ((IODataConnectionFactory) connFactory)
+ .getInetAddress();
if (address == null) {
- session.write(new DefaultFtpReply(FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS, "PORT or PASV must be issued first"));
+ session.write(new DefaultFtpReply(
+ FtpReply.REPLY_503_BAD_SEQUENCE_OF_COMMANDS,
+ "PORT or PASV must be issued first"));
return;
}
}
-
+
// get filenames
FileObject file = null;
try {
file = session.getFileSystemView().getFileObject(fileName);
- }
- catch(Exception e) {
+ } catch (Exception e) {
LOG.debug("File system threw exception", e);
}
- if(file == null) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "APPE.invalid", fileName));
+ if (file == null) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,
+ "APPE.invalid", fileName));
return;
}
fileName = file.getFullName();
-
+
// check file existance
- if(file.doesExist() && !file.isFile()) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "APPE.invalid", fileName));
+ if (file.doesExist() && !file.isFile()) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,
+ "APPE.invalid", fileName));
return;
}
-
+
// check permission
- if( !file.hasWritePermission()) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "APPE.permission", fileName));
+ if (!file.hasWritePermission()) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,
+ "APPE.permission", fileName));
return;
}
-
+
// get data connection
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_150_FILE_STATUS_OKAY, "APPE", fileName));
-
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_150_FILE_STATUS_OKAY, "APPE", fileName));
+
DataConnection dataConnection;
try {
dataConnection = session.getDataConnection().openConnection();
} catch (Exception e) {
LOG.debug("Exception when getting data input stream", e);
- session.write(FtpReplyUtil.translate(session,request, context, FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "APPE", fileName));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_425_CANT_OPEN_DATA_CONNECTION, "APPE",
+ fileName));
return;
}
-
+
// get data from client
boolean failure = false;
OutputStream os = null;
try {
-
- // find offset
- long offset = 0L;
- if(file.doesExist()) {
- offset = file.getSize();
- }
-
+
+ // find offset
+ long offset = 0L;
+ if (file.doesExist()) {
+ offset = file.getSize();
+ }
+
// open streams
os = file.createOutputStream(offset);
-
+
// transfer data
long transSz = dataConnection.transferFromClient(os);
-
+
// log message
String userName = session.getUser().getName();
LOG.info("File upload : " + userName + " - " + fileName);
-
+
// notify the statistics component
- ServerFtpStatistics ftpStat = (ServerFtpStatistics)context.getFtpStatistics();
+ ServerFtpStatistics ftpStat = (ServerFtpStatistics) context
+ .getFtpStatistics();
ftpStat.setUpload(session, file, transSz);
- }
- catch(SocketException e) {
+ } catch (SocketException e) {
LOG.debug("SocketException during file upload", e);
failure = true;
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED, "APPE", fileName));
- }
- catch(IOException e) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_426_CONNECTION_CLOSED_TRANSFER_ABORTED,
+ "APPE", fileName));
+ } catch (IOException e) {
LOG.debug("IOException during file upload", e);
failure = true;
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN, "APPE", fileName));
- }
- finally {
+ session
+ .write(FtpReplyUtil
+ .translate(
+ session,
+ request,
+ context,
+ FtpReply.REPLY_551_REQUESTED_ACTION_ABORTED_PAGE_TYPE_UNKNOWN,
+ "APPE", fileName));
+ } finally {
IoUtils.close(os);
}
-
+
// if data transfer ok - send transfer complete message
- if(!failure) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "APPE", fileName));
+ if (!failure) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_226_CLOSING_DATA_CONNECTION, "APPE",
+ fileName));
}
- }
- finally {
+ } finally {
session.getDataConnection().closeDataConnection();
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/AUTH.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/AUTH.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/AUTH.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/AUTH.java Sun Aug 17 12:52:42 2008
@@ -36,16 +36,21 @@
/**
* This server supports explicit SSL support.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public class AUTH extends AbstractCommand {
private static final String SSL_SESSION_FILTER_NAME = "sslSessionFilter";
+
private final Logger LOG = LoggerFactory.getLogger(AUTH.class);
/**
* Execute command
*/
- public void execute(final FtpIoSession session, final FtpServerContext context, final FtpRequest request)
+ public void execute(final FtpIoSession session,
+ final FtpServerContext context, final FtpRequest request)
throws IOException, FtpException {
// reset state variables
@@ -54,13 +59,15 @@
// argument check
if (!request.hasArgument()) {
session.write(FtpReplyUtil.translate(session, request, context,
- FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "AUTH", null));
+ FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,
+ "AUTH", null));
return;
}
// check SSL configuration
if (session.getListener().getSslConfiguration() == null) {
- session.write(FtpReplyUtil.translate(session, request, context, 431, "AUTH", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ 431, "AUTH", null));
return;
}
@@ -79,7 +86,8 @@
// Here we choose not to support reissued AUTH
if (session.getFilterChain().contains(SslFilter.class)) {
- session.write(FtpReplyUtil.translate(session, request, context, 534, "AUTH", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ 534, "AUTH", null));
return;
}
@@ -88,7 +96,8 @@
if (authType.equals("SSL")) {
try {
secureSession(session, "SSL");
- session.write(FtpReplyUtil.translate(session, request, context, 234, "AUTH.SSL", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ 234, "AUTH.SSL", null));
} catch (FtpException ex) {
throw ex;
} catch (Exception ex) {
@@ -98,7 +107,8 @@
} else if (authType.equals("TLS")) {
try {
secureSession(session, "TLS");
- session.write(FtpReplyUtil.translate(session, request, context, 234, "AUTH.TLS", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ 234, "AUTH.TLS", null));
} catch (FtpException ex) {
throw ex;
} catch (Exception ex) {
@@ -106,13 +116,13 @@
throw new FtpException("AUTH.execute()", ex);
}
} else {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED,
- "AUTH", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_502_COMMAND_NOT_IMPLEMENTED, "AUTH", null));
}
}
- private void secureSession(final FtpIoSession session, final String type) throws GeneralSecurityException,
- FtpException {
+ private void secureSession(final FtpIoSession session, final String type)
+ throws GeneralSecurityException, FtpException {
SslConfiguration ssl = session.getListener().getSslConfiguration();
if (ssl != null) {
@@ -133,7 +143,8 @@
sslFilter.setEnabledCipherSuites(ssl.getEnabledCipherSuites());
}
- session.getFilterChain().addFirst(SSL_SESSION_FILTER_NAME, sslFilter);
+ session.getFilterChain().addFirst(SSL_SESSION_FILTER_NAME,
+ sslFilter);
} else {
throw new FtpException("Socket factory SSL not configured");
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/AbstractCommand.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/AbstractCommand.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/AbstractCommand.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/AbstractCommand.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -23,8 +23,10 @@
/**
* Common base class recommended for {@link Command} implementations
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public abstract class AbstractCommand implements Command {
-
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/CDUP.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/CDUP.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/CDUP.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/CDUP.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -33,43 +33,47 @@
/**
* <code>CDUP <CRLF></code><br>
+ *
+ * This command is a special case of CWD, and is included to simplify the
+ * implementation of programs for transferring directory trees between operating
+ * systems having different syntaxes for naming the parent directory. The reply
+ * codes shall be identical to the reply codes of CWD.
*
- * This command is a special case of CWD, and is included to
- * simplify the implementation of programs for transferring
- * directory trees between operating systems having different
- * syntaxes for naming the parent directory. The reply codes
- * shall be identical to the reply codes of CWD.
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class CDUP extends AbstractCommand {
+public class CDUP extends AbstractCommand {
private final Logger LOG = LoggerFactory.getLogger(CDUP.class);
-
+
/**
* Execute command.
*/
- public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException, FtpException {
-
+ public void execute(final FtpIoSession session,
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException, FtpException {
+
// reset state variables
session.resetState();
-
+
// change directory
FileSystemView fsview = session.getFileSystemView();
boolean success = false;
try {
success = fsview.changeDirectory("..");
- }
- catch(Exception ex) {
+ } catch (Exception ex) {
LOG.debug("Failed to change directory in file system", ex);
}
- if(success) {
+ if (success) {
String dirName = fsview.getCurrentDirectory().getFullName();
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "CDUP", dirName));
- }
- else {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "CDUP", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "CDUP",
+ dirName));
+ } else {
+ session.write(FtpReplyUtil
+ .translate(session, request, context,
+ FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,
+ "CDUP", null));
}
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/CWD.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/CWD.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/CWD.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/CWD.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -33,49 +33,53 @@
/**
* <code>CWD <SP> <pathname> <CRLF></code><br>
+ *
+ * This command allows the user to work with a different directory for file
+ * storage or retrieval without altering his login or accounting information.
+ * Transfer parameters are similarly unchanged. The argument is a pathname
+ * specifying a directory.
*
- * This command allows the user to work with a different
- * directory for file storage or retrieval without
- * altering his login or accounting information. Transfer
- * parameters are similarly unchanged. The argument is a
- * pathname specifying a directory.
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class CWD extends AbstractCommand {
+public class CWD extends AbstractCommand {
private final Logger LOG = LoggerFactory.getLogger(CWD.class);
-
+
/**
* Execute command
*/
- public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException, FtpException {
-
+ public void execute(final FtpIoSession session,
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException, FtpException {
+
// reset state variables
session.resetState();
-
+
// get new directory name
String dirName = "/";
if (request.hasArgument()) {
dirName = request.getArgument();
- }
-
+ }
+
// change directory
FileSystemView fsview = session.getFileSystemView();
boolean success = false;
try {
success = fsview.changeDirectory(dirName);
- }
- catch(Exception ex) {
+ } catch (Exception ex) {
LOG.debug("Failed to change directory in file system", ex);
}
- if(success) {
+ if (success) {
dirName = fsview.getCurrentDirectory().getFullName();
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "CWD", dirName));
- }
- else {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "CWD", null));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "CWD",
+ dirName));
+ } else {
+ session
+ .write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,
+ "CWD", null));
}
}
}
Modified: mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/DELE.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/DELE.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/DELE.java (original)
+++ mina/ftpserver/trunk/core/src/main/java/org/apache/ftpserver/command/DELE.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.command;
@@ -34,68 +34,80 @@
/**
* <code>DELE <SP> <pathname> <CRLF></code><br>
+ *
+ * This command causes the file specified in the pathname to be deleted at the
+ * server site.
*
- * This command causes the file specified in the pathname to be
- * deleted at the server site.
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class DELE extends AbstractCommand {
-
+public class DELE extends AbstractCommand {
+
private final Logger LOG = LoggerFactory.getLogger(DELE.class);
-
+
/**
* Execute command.
*/
public void execute(final FtpIoSession session,
- final FtpServerContext context,
- final FtpRequest request) throws IOException, FtpException {
-
+ final FtpServerContext context, final FtpRequest request)
+ throws IOException, FtpException {
+
// reset state variables
- session.resetState();
-
+ session.resetState();
+
// argument check
String fileName = request.getArgument();
- if(fileName == null) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS, "DELE", null));
- return;
+ if (fileName == null) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_501_SYNTAX_ERROR_IN_PARAMETERS_OR_ARGUMENTS,
+ "DELE", null));
+ return;
}
-
+
// get file object
FileObject file = null;
-
+
try {
file = session.getFileSystemView().getFileObject(fileName);
- }
- catch(Exception ex) {
+ } catch (Exception ex) {
LOG.debug("Could not get file " + fileName, ex);
}
- if(file == null) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "DELE.invalid", fileName));
+ if (file == null) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN,
+ "DELE.invalid", fileName));
return;
}
// check file
fileName = file.getFullName();
- if( !file.hasDeletePermission() ) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN, "DELE.permission", fileName));
+ if (!file.hasDeletePermission()) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN,
+ "DELE.permission", fileName));
return;
}
-
+
// now delete
- if(file.delete()) {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "DELE", fileName));
-
+ if (file.delete()) {
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "DELE",
+ fileName));
+
// log message
String userName = session.getUser().getName();
-
+
LOG.info("File delete : " + userName + " - " + fileName);
-
+
// notify statistics object
- ServerFtpStatistics ftpStat = (ServerFtpStatistics)context.getFtpStatistics();
+ ServerFtpStatistics ftpStat = (ServerFtpStatistics) context
+ .getFtpStatistics();
ftpStat.setDelete(session, file);
} else {
- session.write(FtpReplyUtil.translate(session, request, context, FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN, "DELE", fileName));
+ session.write(FtpReplyUtil.translate(session, request, context,
+ FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN, "DELE",
+ fileName));
}
}