rheise.jftpd
Class ServerDTP

java.lang.Object
  |
  +--rheise.jftpd.ServerDTP

public class ServerDTP
extends java.lang.Object

This is the server data transfer process. It is responsible for transferring files to and from the client. A separate data socket is created to transfer the data.


Field Summary
private  java.lang.String dataHost
          The host of the data socket.
private  int dataPort
          The port of the data socket.
private  Representation representation
          The representation being used for transmission.
private  ServerPI serverPI
          The ServerPI that uses this DTP.
private  TransmissionMode transmissionMode
          The transmission mode to be used.
 
Constructor Summary
ServerDTP(ServerPI serverPI)
          Creates a server data transfer process for the specified ServerPI.
 
Method Summary
 Representation getRepresentation()
           
private  void listFile(java.io.File file, java.io.PrintWriter writer)
          Lists a single file in long format (including file sizes and modification dates etc.).
private static java.lang.String pad(int length)
           
 int receiveFile(java.lang.String path)
          Opens the data connection, reads the data according to the current transmission mode, representation type and structure, and writes it into the local file "path".
 int sendFile(java.lang.String path)
          Opens the data connection reads the specified local file and writes it to the data socket using the current transmission mode, representation type and structure.
 int sendList(java.lang.String path)
          Sends a list of files in the specified directory to the User DTP.
 int sendNameList(java.lang.String path)
          Sends a list of file names to the User DTP.
 void setDataPort(java.lang.String host, int port)
          Sets the data port for an active transmission.
 void setDataStructure(char stru)
          Sets the structure.
 void setRepresentation(Representation representation)
          Sets the representation type used for transmission.
 void setTransmissionMode(TransmissionMode transmissionMode)
          Sets the transmission mode.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

serverPI

private ServerPI serverPI
The ServerPI that uses this DTP.

dataHost

private java.lang.String dataHost
The host of the data socket.

dataPort

private int dataPort
The port of the data socket.

transmissionMode

private TransmissionMode transmissionMode
The transmission mode to be used. The initial transmission mode is STREAM mode.

representation

private Representation representation
The representation being used for transmission. The initial representation type is ASCII.
Constructor Detail

ServerDTP

public ServerDTP(ServerPI serverPI)
Creates a server data transfer process for the specified ServerPI.
Method Detail

setTransmissionMode

public void setTransmissionMode(TransmissionMode transmissionMode)
Sets the transmission mode.

setDataStructure

public void setDataStructure(char stru)
Sets the structure.

getRepresentation

public Representation getRepresentation()
Returns:
the representation type used for transmission.

setRepresentation

public void setRepresentation(Representation representation)
Sets the representation type used for transmission.

setDataPort

public void setDataPort(java.lang.String host,
                        int port)
Sets the data port for an active transmission.
Parameters:
host - the host name to connect to.
port - the port number to connect to.

receiveFile

public int receiveFile(java.lang.String path)
                throws CommandException
Opens the data connection, reads the data according to the current transmission mode, representation type and structure, and writes it into the local file "path".

sendFile

public int sendFile(java.lang.String path)
             throws CommandException
Opens the data connection reads the specified local file and writes it to the data socket using the current transmission mode, representation type and structure.

sendNameList

public int sendNameList(java.lang.String path)
                 throws CommandException
Sends a list of file names to the User DTP. Each line contains only the file name, not modification dates and file sizes (see sendList).
Parameters:
path - the path of the directory to list.

sendList

public int sendList(java.lang.String path)
             throws CommandException
Sends a list of files in the specified directory to the User DTP. Each line contains the file name, modification date, file size and other information.
Parameters:
path - the path of the directory to list.

listFile

private void listFile(java.io.File file,
                      java.io.PrintWriter writer)
Lists a single file in long format (including file sizes and modification dates etc.).
Parameters:
file - the file to list.
writer - the writer to print to.

pad

private static java.lang.String pad(int length)