incubator-ftpserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r491945 - in /incubator/ftpserver/trunk: core/src/java/org/apache/ftpserver/ core/src/java/org/apache/ftpserver/command/ core/src/java/org/apache/ftpserver/interfaces/ ftplet-api/src/java/org/apache/ftpserver/ftplet/
Date Tue, 02 Jan 2007 22:21:19 GMT
Author: ngn
Date: Tue Jan  2 14:21:18 2007
New Revision: 491945

URL: http://svn.apache.org/viewvc?view=rev&rev=491945
Log:
Moved some additional methods into FtpSession, RequestHandler is looking cleaner and cleaner.

Modified:
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpSessionImpl.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/RequestHandler.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLSD.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLST.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS_MLST.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/RETR.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STRU.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/TYPE.java
    incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/interfaces/Connection.java
    incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/FtpSession.java

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpSessionImpl.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpSessionImpl.java?view=diff&rev=491945&r1=491944&r2=491945
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpSessionImpl.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/FtpSessionImpl.java Tue Jan
 2 14:21:18 2007
@@ -29,10 +29,12 @@
 import java.util.zip.DeflaterOutputStream;
 import java.util.zip.InflaterInputStream;
 
+import org.apache.ftpserver.ftplet.DataType;
 import org.apache.ftpserver.ftplet.FileObject;
 import org.apache.ftpserver.ftplet.FileSystemView;
 import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.FtpSession;
+import org.apache.ftpserver.ftplet.Structure;
 import org.apache.ftpserver.ftplet.User;
 import org.apache.ftpserver.interfaces.ConnectionObserver;
 
@@ -64,6 +66,9 @@
     private long fileOffset;
     private FtpRequest request;
     
+    private DataType dataType    = DataType.ASCII;
+    private Structure structure  = Structure.FILE;
+    
     /**
      * Default constructor.
      */
@@ -380,5 +385,34 @@
     
     public void setCurrentRequest(FtpRequest request) {
         this.request = request;
+    }
+    
+    
+    /**
+     * Get the data type.
+     */
+    public DataType getDataType() {
+        return dataType;
+    }
+    
+    /**
+     * Set the data type.
+     */
+    public void setDataType(DataType type) {
+        dataType = type;
+    }
+
+    /**
+     * Get structure.
+     */
+    public Structure getStructure() {
+        return structure;
+    }
+    
+    /**
+     * Set structure
+     */
+    public void setStructure(Structure stru) {
+        structure = stru;
     }
 }

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/RequestHandler.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/RequestHandler.java?view=diff&rev=491945&r1=491944&r2=491945
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/RequestHandler.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/RequestHandler.java Tue Jan
 2 14:21:18 2007
@@ -27,8 +27,6 @@
 import java.net.InetAddress;
 import java.net.Socket;
 import java.net.SocketException;
-import java.util.HashMap;
-import java.util.Map;
 
 import javax.net.ssl.SSLException;
 
@@ -40,7 +38,6 @@
 import org.apache.ftpserver.ftplet.FtpSession;
 import org.apache.ftpserver.ftplet.Ftplet;
 import org.apache.ftpserver.ftplet.FtpletEnum;
-import org.apache.ftpserver.ftplet.Structure;
 import org.apache.ftpserver.ftplet.User;
 import org.apache.ftpserver.interfaces.Command;
 import org.apache.ftpserver.interfaces.CommandFactory;
@@ -72,10 +69,6 @@
     private BufferedReader reader;
     private boolean isConnectionClosed;
     
-    private DataType dataType    = DataType.ASCII;
-    private Structure structure  = Structure.FILE;
-    private Map attributes = new HashMap();
-    
     
     /**
      * Constructor - set the control socket.
@@ -126,53 +119,7 @@
     public FtpServerContext getServerContext() {
         return serverContext;
     }
-                
-    /**
-     * Get the data type.
-     */
-    public DataType getDataType() {
-        return dataType;
-    }
-    
-    /**
-     * Set the data type.
-     */
-    public void setDataType(DataType type) {
-        dataType = type;
-    }
 
-    /**
-     * Get structure.
-     */
-    public Structure getStructure() {
-        return structure;
-    }
-    
-    /**
-     * Get a session attribute.
-     * @param name The name of the attribute
-     * 
-     * @return The attribute value, or null if the attribute does not exist
-     */
-    public Object getAttribute(String name) {
-        return attributes.get(name);
-    }
-    
-    /**
-     * Set a session attribute.
-     * @param name The name of the attribute
-     * @param value The value of the attribute
-     */
-    public void setAttribute(String name, Object value) {
-        attributes.put(name, value);
-    }
-    
-    /**
-     * Set structure
-     */
-    public void setStructure(Structure stru) {
-        structure = stru;
-    }
         
     /**
      * Get request.
@@ -442,7 +389,7 @@
                                BufferedOutputStream out,
                                int maxRate) throws IOException {
         
-        boolean isAscii = dataType == DataType.ASCII;
+        boolean isAscii = session.getDataType() == DataType.ASCII;
         long startTime = System.currentTimeMillis();
         long transferredSize = 0L;
         byte[] buff = new byte[4096];

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLSD.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLSD.java?view=diff&rev=491945&r1=491944&r2=491945
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLSD.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLSD.java Tue Jan
 2 14:21:18 2007
@@ -89,7 +89,7 @@
                 // parse argument
                 ListArgument parsedArg = ListArgumentParser.parse(request.getArgument());
                 
-                FileFormater formater = new MLSTFileFormater((String[])handler.getAttribute("MLST.types"));
+                FileFormater formater = new MLSTFileFormater((String[])session.getAttribute("MLST.types"));
                 writer.write(directoryLister.listFiles(parsedArg, session.getFileSystemView(),
formater));
             }
             catch(SocketException ex) {

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLST.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLST.java?view=diff&rev=491945&r1=491944&r2=491945
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLST.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/MLST.java Tue Jan
 2 14:21:18 2007
@@ -60,7 +60,7 @@
         try {
             file = session.getFileSystemView().getFileObject(parsedArg.getFile());
             if(file != null && file.doesExist()) {
-                FileFormater formater = new MLSTFileFormater((String[])handler.getAttribute("MLST.types"));
+                FileFormater formater = new MLSTFileFormater((String[])session.getAttribute("MLST.types"));
                 out.send(250, "MLST", formater.format(file));
             } else {            
                 out.send(501, "MLST", null);

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS_MLST.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS_MLST.java?view=diff&rev=491945&r1=491944&r2=491945
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS_MLST.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/OPTS_MLST.java Tue
Jan  2 14:21:18 2007
@@ -75,7 +75,7 @@
         // set the list types
         String[] validatedTypes = validateSelectedTypes(types);
         if(validatedTypes != null) {
-            handler.setAttribute("MLST.types", validatedTypes);
+            session.setAttribute("MLST.types", validatedTypes);
             out.send(200, "OPTS.MLST", listTypes);
         }
         else {

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/RETR.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/RETR.java?view=diff&rev=491945&r1=491944&r2=491945
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/RETR.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/RETR.java Tue Jan
 2 14:21:18 2007
@@ -146,7 +146,7 @@
             try {
                 
                 // open streams
-                bis = IoUtils.getBufferedInputStream(openInputStream(handler, file, skipLen)
);
+                bis = IoUtils.getBufferedInputStream(openInputStream(handler, session, file,
skipLen) );
                 bos = IoUtils.getBufferedOutputStream(os);
                 
                 // transfer data
@@ -212,10 +212,11 @@
      * Skip length and open input stream.
      */
     public InputStream openInputStream(RequestHandler handler,
+                                       FtpSessionImpl session, 
                                        FileObject file, 
                                        long skipLen) throws IOException {
         InputStream in;
-        if(handler.getDataType() == DataType.ASCII) {
+        if(session.getDataType() == DataType.ASCII) {
             int c;
             long offset = 0L;
             in = new BufferedInputStream(file.createInputStream(0L));

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STRU.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STRU.java?view=diff&rev=491945&r1=491944&r2=491945
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STRU.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/STRU.java Tue Jan
 2 14:21:18 2007
@@ -58,7 +58,7 @@
         // set structure
         char stru = request.getArgument().charAt(0);
         try  {
-            handler.setStructure(Structure.parseArgument(stru));
+            session.setStructure(Structure.parseArgument(stru));
             out.send(200, "STRU", null);
         } 
         catch(IllegalArgumentException e) {

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/TYPE.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/TYPE.java?view=diff&rev=491945&r1=491944&r2=491945
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/TYPE.java (original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/command/TYPE.java Tue Jan
 2 14:21:18 2007
@@ -56,7 +56,7 @@
         
         // set type
         try {
-            handler.setDataType(DataType.parseArgument(type));
+            session.setDataType(DataType.parseArgument(type));
             out.send(200, "TYPE", null);
         } 
         catch(IllegalArgumentException e) {

Modified: incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/interfaces/Connection.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/interfaces/Connection.java?view=diff&rev=491945&r1=491944&r2=491945
==============================================================================
--- incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/interfaces/Connection.java
(original)
+++ incubator/ftpserver/trunk/core/src/java/org/apache/ftpserver/interfaces/Connection.java
Tue Jan  2 14:21:18 2007
@@ -19,7 +19,6 @@
 
 package org.apache.ftpserver.interfaces;
 
-import org.apache.ftpserver.ftplet.FtpRequest;
 import org.apache.ftpserver.ftplet.FtpSession;
 
 /**

Modified: incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/FtpSession.java
URL: http://svn.apache.org/viewvc/incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/FtpSession.java?view=diff&rev=491945&r1=491944&r2=491945
==============================================================================
--- incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/FtpSession.java
(original)
+++ incubator/ftpserver/trunk/ftplet-api/src/java/org/apache/ftpserver/ftplet/FtpSession.java
Tue Jan  2 14:21:18 2007
@@ -115,6 +115,16 @@
     FileObject getRenameFrom();
     
     /**
+     * Get the data type.
+     */
+    DataType getDataType();
+    
+    /**
+     * Get structure.
+     */
+    Structure getStructure();
+    
+    /**
      * Get data input stream.
      */
     InputStream getDataInputStream() throws IOException;



Mime
View raw message