All Packages Class Hierarchy This Package Previous Next Index
Class ProtocolLayer.FTPThread
Abstract.Connection
|
+----Abstract.ReceiverThread
|
+----BaseLayer.BRecvThread
|
+----ProtocolLayer.IPThread
|
+----ProtocolLayer.FTPThread
- public class FTPThread
- extends IPThread
Example class of extending IPThread(Internet protocol thread). FTPThread will be created
for data transfer using File Transfer Protocol(FTP).
Current implementation performs a minamal set of command procedure - connect to
FTP server, change remote site directory, set transfer mode(ASCII or binary) and
GET/PUT/APPEND. List command is not implemented.
-
FTPThread()
- Default Constructor.
-
FTPThread(FTPCon, int, ThreadGroup)
- Can be used both for applets and stand-alone agents, but for efficiency, normally
used for applets.
-
FTPThread(IPRouterClientAction, Address, FTPCon, int, ThreadGroup)
-
For applet data transfer using FTP.
-
FTPThread(IPRouterClientAction, Address, String, String, String, int, String, String, String, String[], int, int, ThreadGroup)
-
For applet data transfer using FTP.
-
FTPThread(String)
- Create ReceiverThread with specific thread name
-
FTPThread(String, String, String, int, String, String, String, String[], int, int, ThreadGroup)
- For stand-alone agent file transfer.
-
FTPThread(ThreadGroup, String)
- Create FTPThread with specific thread name and Thread group.
-
append(String)
- Append file to a remote FTP server.
-
appletDataTransfer(String)
- File names will be given from command and the file is already opened and waiting for
data.
-
appletPort()
- Execute 'port' command for applets.
-
closePortSocket()
- Close port socket if not already closed
-
endConn()
- Close port socket and stop.
-
makeSimpleCommandList(String[], boolean)
- Make the simplest FTP command list from given data transfer information.
-
notifyError(String)
- Notify error if _ipAgentAction(class IPRouterClientAction) is not null
-
notifyMessage()
- Notify message(FTPCon itself) if _ipAgentAction(class IPRouterClientAction) is not null
_ipAgentAction will invoke processMessage(String,Object) where String is "FTP" and
Object is _ftpCon.
-
port()
- Execute 'port' command
-
processCommands()
- processCommands implementation.
-
processErrorMsg(String)
- According to the response from mail server, return false if the error message
can not be managed.
-
retrieve(String)
- Retrieve file from a remote FTP server.
-
setMode(int)
- Set file transfer mode if different from default mode.
-
store(String)
- Save file to a remote FTP server.
FTPThread
public FTPThread()
- Default Constructor.
FTPThread
public FTPThread(String name)
- Create ReceiverThread with specific thread name
- Parameters:
- name - Agent name
FTPThread
public FTPThread(ThreadGroup tg,
String name)
- Create FTPThread with specific thread name and Thread group.
Passing thread group is essential when you will create the receiver thread for an applet
because of security issue.
- Parameters:
- tg - Thread group to which this thread will be owned to
- name - Agent name
FTPThread
public FTPThread(FTPCon con,
int priority,
ThreadGroup tg) throws ConnectionException
- Can be used both for applets and stand-alone agents, but for efficiency, normally
used for applets. Router will create a connector which connects an applet and SMTP
server. Through the connector, email will be sent as if the applet is a stand-aloone
agent.
- Parameters:
- con - FTPCon object
- priority - Thread priority. Default is NORM_PRIORITY
- tg - Thread group, the thread will be grouped.
- Throws: Throws
- ConnectionException if connection error occurs.
- See Also:
- FTPCon
FTPThread
public FTPThread(String conID,
String remotePath,
String host,
int port,
String userName,
String password,
String localPath,
String files[],
int mode,
int priority,
ThreadGroup tg) throws ConnectionException
- For stand-alone agent file transfer.
- Parameters:
- remotePath - Remote site initial path
- remotePath - FTP site initial directory
- host - FTP server host name
- port - 21. Otherwiser, you need to set
- userName - FTP server login user name
- password - FTP server login password
- localPath - Local machine initial directory
- files - Files to put or get
- mode - Mode definition
- priority - Thread priority
- tg - Thread group
- Throws: Throws
- ConnectionException if connection error occurs.
FTPThread
public FTPThread(IPRouterClientAction agentAction,
Address serveraddress,
FTPCon con,
int priority,
ThreadGroup tg) throws ConnectionException
- For applet data transfer using FTP. agentAction(class IPRouterClientAction) should
be passed for receiving callback. By creating a FTPThread from an applet,
FTPThread will prepare FTPPortThread. FTPPortThread will create
InputStream/OutputStream for the agentAction.
Then FTPPortThread will execute FTPStore/FTPAppend/FTPRetrieve. From the applet side,
it should implement above three abstract methods for actual behavior from given
InputStream/OutputStream which connects FTPServer through router.
- Parameters:
- agentAction - IPRouterClientAction, which implements FTPStore/FTPAppend/FTPRetrieve.
- serveraddress - Router FTP proxy address
- priority - The priority of the thread.
- tg - Thread group
- Throws: ConnectionException
- if error occurs
FTPThread
public FTPThread(IPRouterClientAction agentAction,
Address serveraddress,
String conid,
String remotePath,
String host,
int port,
String userName,
String password,
String localPath,
String files[],
int mode,
int priority,
ThreadGroup tg) throws ConnectionException
- For applet data transfer using FTP. agentAction(class IPRouterClientAction) should
be passed for receiving callback. By creating a FTPThread from an applet,
FTPThread will prepare FTPPortThread. FTPPortThread will create
InputStream/OutputStream for the agentAction.
Then FTPPortThread will execute FTPStore/FTPAppend/FTPRetrieve. From the applet side,
it should implement above three abstract methods for actual behavior from given
InputStream/OutputStream which connects FTPServer through router.
- Parameters:
- agentAction - IPRouterClientAction, which implements FTPStore/FTPAppend/FTPRetrieve.
- serveraddress - Router FTP proxy address
- remotePath - Remote site initial path
- remotePath - FTP site initial directory
- host - FTP server host name
- port - 21. Otherwiser, you need to set
- userName - FTP server login user name
- password - FTP server login password
- localPath - Local machine initial directory
- files - Files to put or get
- mode - Mode definition
- priority - The priority of the thread.
- tg - Thread group
- Throws: ConnectionException
- if error occurs
makeSimpleCommandList
public void makeSimpleCommandList(String files[],
boolean getOrPut)
- Make the simplest FTP command list from given data transfer information.
Typical command list is :
type a
port
appe file1
appe file2
stor file3
for appending file1, file2 and storing file3 with ASCII mode.
- Parameters:
- files - String list of files to put/get/append
- getOrPut - Get mode is true.
setMode
public void setMode(int mode)
- Set file transfer mode if different from default mode.
Default mode is binary transfer, no directory creation, no append.
Modes are defined :
public static final int NORMALMODE = 0; // default mode
public static final int APPEND = 1; // file append mode
public static final int CREATEDIR = 2; // create directory
public static final int ASCIITYPE = 3; // true for ascii.
- Parameters:
- mode - FTP mode.
processCommands
public void processCommands()
- processCommands implementation. Send predefined command to mail server and manage received
response.
- Overrides:
- processCommands in class IPThread
port
public void port() throws ConnectionException
- Execute 'port' command
- Throws: ConnectionException
- If server socket can not be opened,Connection
exception will be thrown
retrieve
public void retrieve(String cmd) throws ConnectionException
- Retrieve file from a remote FTP server. Create FTPPortThread and start it.
- Parameters:
- cmd - 'retr fileName'
- Throws: ConnectionException
- If FTPPort can not be created or
receiving file can not be created.
store
public void store(String cmd) throws ConnectionException
- Save file to a remote FTP server. Create FTPPortThread and start it.
- Parameters:
- cmd - 'stor fileName'
- Throws: ConnectionException
- If FTPPort can not be created or
receiving file can not be created.
append
public void append(String cmd) throws ConnectionException
- Append file to a remote FTP server. Create FTPPortThread and start it.
- Parameters:
- cmd - 'appe fileName'
- Throws: ConnectionException
- If FTPPort can not be created or
receiving file can not be created.
appletPort
public void appletPort() throws ConnectionException
- Execute 'port' command for applets. The router will response 'port' message
and provide a proxy port with '299 port-number'.
- Throws: ConnectionException
- If can not connect to the proxy socket
closePortSocket
protected void closePortSocket()
- Close port socket if not already closed
appletDataTransfer
public void appletDataTransfer(String command) throws ConnectionException
- File names will be given from command and the file is already opened and waiting for
data. You should implement FTPStore(String remoteFilePath,PrintWriter) callback in
IPRouterClientAction.
- Parameters:
- command - Simple command list created by default.
processErrorMsg
protected String processErrorMsg(String msg)
- According to the response from mail server, return false if the error message
can not be managed. Return true if the response from server is success or
the error can be fully managed.
202 Command not implemented, superfluous at this site.
221 Service closing control connection. Logged out if appropriate.
226 Closing data connection.
350 Requested file action pending further information.
421 Service not available, closing control connection.
425 Can't open data connection.
426 Connection closed; transfer aborted.
450 Requested file action not taken.File unavailable (e.g., file busy).
451 Requested action aborted: local error in processing.
452 Requested action not taken. Insufficient storage space in system
500 Syntax error, command unrecognized.
501 Syntax error in parameters or arguments.
502 Command not implemented.
503 Bad sequence of commands.
504 Command not implemented for that parameter.
530 Not logged in.
532 Need account for storing files.
550 Requested action not taken. File unavailable (e.g., file not found, no access).
551 Requested action aborted: page type unknown.
552 Requested file action aborted.Exceeded storage allocation (for current directory or dataset).
553 Requested action not taken. File name not allowed.
- Parameters:
- msg - Returned message from email server
endConn
public void endConn()
- Close port socket and stop.
- Overrides:
- endConn in class BRecvThread
notifyError
public void notifyError(String msg)
- Notify error if _ipAgentAction(class IPRouterClientAction) is not null
- Parameters:
- msg - Message to be notified to _ipAgentAction
notifyMessage
public void notifyMessage()
- Notify message(FTPCon itself) if _ipAgentAction(class IPRouterClientAction) is not null
_ipAgentAction will invoke processMessage(String,Object) where String is "FTP" and
Object is _ftpCon.
All Packages Class Hierarchy This Package Previous Next Index