|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
org.globus.io.ftp
Class FTPCommon
java.lang.Object | +--org.globus.io.ftp.FTPCommon
- Direct Known Subclasses:
- FTPClient
- public class FTPCommon
- extends java.lang.Object
This class provides the basics for writting a simple ftp client. Provides support for passive data transfers and more.
| Field Summary | |
static int |
ASCII
|
static int |
BINARY
|
protected java.io.InputStream |
ftpin
|
protected java.io.OutputStream |
ftpout
|
protected java.lang.String |
host
|
static java.lang.String |
NLST
|
static int |
PERMANENT_NEGATIVE_REPLY
|
protected int |
port
|
static int |
POSITIVE_COMPLETION_REPLY
|
static int |
POSITIVE_INTERMEDIATE_REPLY
|
static int |
POSITIVE_PRELIMINARY_REPLY
|
protected RequestThread |
requestThread
|
static java.lang.String |
RETR
|
protected java.net.Socket |
socket
|
static int |
TIMEOUT
|
static int |
TRANSIENT_NEGATIVE_REPLY
|
| Constructor Summary | |
FTPCommon(java.lang.String host,
int port)
Connects to the ftp server on given host and port number. |
|
| Method Summary | |
void |
abort()
|
void |
authenticate()
Performs anonymous authentication. |
void |
authenticate(java.lang.String user,
java.lang.String pwd)
Performs user authentication with specified user and password. |
static void |
checkResponse(java.lang.String reply)
|
void |
close()
Closes the control channel connection |
protected void |
closeSocket()
|
void |
connect()
Establishes connection to the ftp server |
void |
disconnect()
|
java.lang.String |
doCmd(java.lang.String cmd)
Sends a simple command to the ftp server and returns the response. |
java.lang.String |
doCmd(java.lang.String cmd,
java.lang.String args)
Sends a simple command to the ftp server with an argument. |
void |
executeCommand(java.lang.String cmd,
java.lang.String arg)
Executes a ftp command and checks the reply for positive completion reply. |
java.net.Socket |
getControlSocket()
|
java.lang.String |
getReply()
|
RequestThread |
getRequestThread()
|
static int |
getResponse(java.lang.String reply)
|
static boolean |
isPositiveComplete(java.lang.String reply)
|
static boolean |
isPositivePreliminary(java.lang.String reply)
|
static boolean |
isReplyType(java.lang.String reply,
int type)
|
protected java.lang.String |
readLine()
|
void |
sendFileCommand(java.lang.String cmd,
java.lang.String arg)
Executes a ftp command and checks the reply for positive preliminary reply. |
HostPort |
setPassiveMode()
|
void |
setPort(HostPort hostPort)
|
java.net.ServerSocket |
startDataChannel()
Starts local server for data channel. |
java.net.ServerSocket |
startDataChannel(int port)
Starts local server for data channel on a given port. |
java.net.Socket |
startPassiveDataChannel()
Start passvide data channel on the ftp server and returns socket connected to it. |
protected void |
write(java.lang.String msg)
|
protected void |
writeln(java.lang.String msg)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
TIMEOUT
public static final int TIMEOUT
RETR
public static final java.lang.String RETR
NLST
public static final java.lang.String NLST
BINARY
public static final int BINARY
ASCII
public static final int ASCII
POSITIVE_PRELIMINARY_REPLY
public static final int POSITIVE_PRELIMINARY_REPLY
POSITIVE_COMPLETION_REPLY
public static final int POSITIVE_COMPLETION_REPLY
POSITIVE_INTERMEDIATE_REPLY
public static final int POSITIVE_INTERMEDIATE_REPLY
TRANSIENT_NEGATIVE_REPLY
public static final int TRANSIENT_NEGATIVE_REPLY
PERMANENT_NEGATIVE_REPLY
public static final int PERMANENT_NEGATIVE_REPLY
socket
protected java.net.Socket socket
ftpout
protected java.io.OutputStream ftpout
ftpin
protected java.io.InputStream ftpin
host
protected java.lang.String host
port
protected int port
requestThread
protected RequestThread requestThread
| Constructor Detail |
FTPCommon
public FTPCommon(java.lang.String host,
int port)
throws java.io.IOException,
FTPException
- Connects to the ftp server on given host
and port number.
- Parameters:
host- hostname of the ftp serverport- port number of the ftp server
| Method Detail |
connect
public void connect()
throws java.io.IOException,
FTPException
- Establishes connection to the ftp server
authenticate
public void authenticate()
throws java.io.IOException,
FTPException
- Performs anonymous authentication.
authenticate
public void authenticate(java.lang.String user,
java.lang.String pwd)
throws java.io.IOException,
FTPException
- Performs user authentication with specified
user and password.
- Parameters:
user- usernamepwd- user password
startDataChannel
public java.net.ServerSocket startDataChannel()
throws java.io.IOException,
FTPException
- Starts local server for data channel.
The port number is automatically assigned.
The information about the local server are
sent to the ftp server (via PORT command)
- Returns:
- ServerSocket server
startDataChannel
public java.net.ServerSocket startDataChannel(int port)
throws java.io.IOException,
FTPException
- Starts local server for data channel on
a given port. The information about the local
server are sent to the ftp server (via PORT
command)
- Parameters:
port- port number- Returns:
- ServerSocket server
startPassiveDataChannel
public java.net.Socket startPassiveDataChannel()
throws java.io.IOException,
FTPException
- Start passvide data channel on the ftp server
and returns socket connected to it.
Issues PASV command on the ftp server.
- Returns:
- socket data channel socket
close
public void close()
- Closes the control channel connection
closeSocket
protected void closeSocket()
doCmd
public java.lang.String doCmd(java.lang.String cmd)
throws java.io.IOException
- Sends a simple command to the ftp server
and returns the response.
- Parameters:
cmd- ftp command- Returns:
- reply reply string
doCmd
public java.lang.String doCmd(java.lang.String cmd,
java.lang.String args)
throws java.io.IOException
- Sends a simple command to the ftp server
with an argument. Returns the reply to the
user.
- Parameters:
cmd- ftp commandargs- arguments- Returns:
- reply reply string
readLine
protected java.lang.String readLine()
throws java.io.IOException
getReply
public java.lang.String getReply()
throws java.io.IOException
writeln
protected void writeln(java.lang.String msg)
throws java.io.IOException
write
protected void write(java.lang.String msg)
throws java.io.IOException
executeCommand
public void executeCommand(java.lang.String cmd,
java.lang.String arg)
throws java.io.IOException,
FTPException
- Executes a ftp command and checks the reply
for positive completion reply.
- Parameters:
cmd- ftp commandarg- arguments- Throws:
FTPException- if command was not executed correctly (error response different from POSITIVE_COMPLETEION_REPLY)
sendFileCommand
public void sendFileCommand(java.lang.String cmd,
java.lang.String arg)
throws java.io.IOException,
FTPException
- Executes a ftp command and checks the reply
for positive preliminary reply.
- Parameters:
cmd- ftp commandarg- arguments- Throws:
FTPException- if command was not executed correctly (error response different from POSITIVE_PRELIMINARY_REPLY)
isPositiveComplete
public static boolean isPositiveComplete(java.lang.String reply)
isPositivePreliminary
public static boolean isPositivePreliminary(java.lang.String reply)
isReplyType
public static boolean isReplyType(java.lang.String reply,
int type)
getResponse
public static int getResponse(java.lang.String reply)
checkResponse
public static void checkResponse(java.lang.String reply)
throws FTPException
getControlSocket
public java.net.Socket getControlSocket()
getRequestThread
public RequestThread getRequestThread()
disconnect
public void disconnect()
throws java.io.IOException,
FTPException
abort
public void abort()
throws java.io.IOException,
FTPException
setPassiveMode
public HostPort setPassiveMode() throws java.io.IOException, FTPException
setPort
public void setPort(HostPort hostPort) throws java.io.IOException, FTPException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||