Sun Adapter for Batch/FTP

com.stc.connector.ssl.ftp.client.impl
Class FTPOverSSLClientImpl

java.lang.Object
  extended by com.stc.connector.ssl.ftp.client.impl.FTPOverSSLClientImpl
All Implemented Interfaces:
DirectoryProvider, FTPOverSSLClient

public class FTPOverSSLClientImpl
extends java.lang.Object
implements FTPOverSSLClient

jim.fu@sun.com TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates


Constructor Summary
FTPOverSSLClientImpl(FTPOverSSL intf, java.util.Map aParams)
           
 
Method Summary
 void append()
          need to handle pattern as dir and file name
 void connect()
          connect to the remote FTP server;
 java.lang.String currentDir()
           
 void deleteDir(java.lang.String dir)
          delete a remote directory specified by dir
 void deleteFile(java.lang.String path)
          delete a remote file specified by path
 void disconnect()
          disconnect the client from the remote FTP server;
 void doRawCommands(java.lang.String commands)
           
 void download()
          need to handle pattern in dir and file name
 void get()
          need to handle pattern as dir and file name;
 void GET()
          get data from remote and apply pre and post operations if there are any configured;
 DirectoryEntry getEntry(int index)
          get the index(th) entry in the current entry list Note, current entry list is populated by calling listDir() or listDirLong();
 int getEntryCount()
          return the number of entries in the current entry list;
 java.lang.String getLastReply()
          get the FTP response code as String;
 java.lang.String getLocalDirNameStub()
          return the current name stub for local directory - when local directory name is a pattern this stub is used to substitute %f in a name pattern;
 java.lang.String getLocalFileNameStub()
          return the current name stub for local file - when local file name is a pattern this stub is used to substitute %f in a name pattern;
 byte[] getPayload()
          return the payload buffer - byte array;
 java.lang.String getRemoteDirNameStub()
          return the current name stub for remote directory - when remote directory name is a pattern this stub is used to substitute %f in a name pattern;
 java.lang.String getRemoteFileNameStub()
          return the current name stub for remote file - when remote file name is a pattern this stub is used to substitute %f in a name pattern;
 java.lang.String getResolvedLocalDirectory()
          Return the resolved local directory name;
 java.lang.String getResolvedLocalFile()
          Return the current resolved local file name;
 java.lang.String getResolvedRemoteDirectory()
          Return the current resolved remote directory name;
 java.lang.String getResolvedRemoteFile()
          Return the current resolved remote file name;
 boolean hasEntry()
          test if current entry list has entries;
 boolean isConnected()
          test if the client is connected to a remote FTP server;
 void listDir()
          list the entries under remote path specified by configuration parameters RemoteDirectory and RemoteFile only file name is available - use listDirLong() for time tamp and size information; use methods: hasEntry(), getEntry(index), nextEntry(), getEntryCount(), resetEntries() to access the entries;
 GenericDirectoryEntry[] listDir(java.lang.String path)
           
 void listDirLong()
          list the entries under remote path specified by configuration parameters RemoteDirectory and RemoteFile file name, is directory flag and time stamp and size information is available - use listDir() for name only entries; use methods: hasEntry(), getEntry(index), nextEntry(), getEntryCount(), resetEntries() to access the entries;
protected  void logon()
           
 void mkdir(java.lang.String dir)
          create a remote directory as specified by parameter dir;
 void mkdirs(java.lang.String dirs)
          create remote directories as specified by parameter dirs, dirs can have more than one path components, which can be relative or absolute;
 DirectoryEntry nextEntry()
          return the next entry in the current entry list;
 void put()
          this is delegeted to a upload when local and remote are specified need to handle dir and file name as pattern
 void PUT()
          put the data to the remote and apply pre and post operations if there is any configured;
 void renameFile(java.lang.String path)
          when path is absolute, the source file represented by : Remote Directory / Remote File will be moved to the destination file, when it is relative, it is relative to the login home directory if the destination directory does not exist, it is created.
 boolean reset()
          internal life cycle methods reset the ftp client such as discard payload buffer
 void resetEntries()
          reset the current entry list so that next call to nextEntry() will return the first entry in the list;
 void resolveLocalAsDestination()
          before introduce a user configurable root name for replacing %f - use a fixed one REMOTE_DEST_DIR_STUB, REMOTE_DEST_FILE_STUB, LOCAL_DEST_DIR_STUB, LOCAL_DEST_FILE_STUB if the local dir or file is a pattern, then treat it as a name pattern (not regex - SeeBeyond propriatory patterns) such as %f, %M, %# etc.
 void resolveLocalAsSource()
          if the local dir or file is pattern, then treat them as regex (used to match existing entries from source), otherwise, use as literal;
 void resolveRemoteAsDestination()
          before introduce a user configurable root name for replacing %f - use a fixed one REMOTE_DEST_DIR_STUB, REMOTE_DEST_FILE_STUB, LOCAL_DEST_DIR_STUB, LOCAL_DEST_FILE_STUB if the remote dir or file is a pattern, then treat it as a name pattern (not regex - SeeBeyond propriatory patterns) such as %f, %M, %# etc.
 void resolveRemoteAsSource()
          if the remote dir or file is pattern, then treat them as regex (used to match existing entries from source), otherwise, use as literal;
 void setLocalDirNameStub(java.lang.String s)
          set the current name stub for local directory - when local directory name is a pattern this stub is used to substitute %f in a name pattern;
 void setLocalFileNameStub(java.lang.String s)
          set the current name stub for local file - when local file name is a pattern this stub is used to substitute %f in a name pattern;
 void setPayload(byte[] newPayload)
          set the payload buffer with newPayload
 void setRemoteDirNameStub(java.lang.String s)
          set the current name stub for remote directory - when remote directory name is a pattern this stub is used to substitute %f in a name pattern;
 void setRemoteFileNameStub(java.lang.String s)
          set the current name stub for remote file - when remote file name is a pattern this stub is used to substitute %f in a name pattern;
 void setResolvedLocalDirectory(java.lang.String s)
          Set the current resolved local directory name, should not be invoked directly from user collaboration;
 void setResolvedLocalFile(java.lang.String s)
          Set the current local file name to s, should not be invoked directly from user collaboration;
 void setResolvedRemoteDirectory(java.lang.String s)
          Set the current resolved remote directory name, should not be invoked directly from user collaboration;
 void setResolvedRemoteFile(java.lang.String s)
          Set the current resolved remote file name, should not be invoked directly from user collaboration;;
 void terminate()
          internal life cycle method;
 void upload()
          need to handle pattern in dir and file name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FTPOverSSLClientImpl

public FTPOverSSLClientImpl(FTPOverSSL intf,
                            java.util.Map aParams)
                     throws FTPSException
Throws:
FTPSException
Method Detail

logon

protected void logon()
              throws FTPSException
Throws:
FTPSException

listDir

public GenericDirectoryEntry[] listDir(java.lang.String path)
                                throws java.lang.Exception
Specified by:
listDir in interface DirectoryProvider
Throws:
java.lang.Exception

currentDir

public java.lang.String currentDir()
                            throws java.lang.Exception
Specified by:
currentDir in interface DirectoryProvider
Throws:
java.lang.Exception

reset

public boolean reset()
              throws FTPSException
Description copied from interface: FTPOverSSLClient
internal life cycle methods reset the ftp client such as discard payload buffer

Specified by:
reset in interface FTPOverSSLClient
Returns:
Throws:
FTPSException

terminate

public void terminate()
               throws FTPSException
Description copied from interface: FTPOverSSLClient
internal life cycle method;

Specified by:
terminate in interface FTPOverSSLClient
Throws:
FTPSException

getPayload

public byte[] getPayload()
Description copied from interface: FTPOverSSLClient
return the payload buffer - byte array;

Specified by:
getPayload in interface FTPOverSSLClient
Returns:
payload buffer;

setPayload

public void setPayload(byte[] newPayload)
Description copied from interface: FTPOverSSLClient
set the payload buffer with newPayload

Specified by:
setPayload in interface FTPOverSSLClient

connect

public void connect()
             throws FTPSException
Description copied from interface: FTPOverSSLClient
connect to the remote FTP server;

Specified by:
connect in interface FTPOverSSLClient
Throws:
FTPSException

disconnect

public void disconnect()
                throws FTPSException
Description copied from interface: FTPOverSSLClient
disconnect the client from the remote FTP server;

Specified by:
disconnect in interface FTPOverSSLClient
Throws:
FTPSException

isConnected

public boolean isConnected()
                    throws FTPSException
Description copied from interface: FTPOverSSLClient
test if the client is connected to a remote FTP server;

Specified by:
isConnected in interface FTPOverSSLClient
Returns:
true if connected false otherwise;
Throws:
FTPSException

PUT

public void PUT()
         throws FTPSException
put the data to the remote and apply pre and post operations if there is any configured;

Specified by:
PUT in interface FTPOverSSLClient
Throws:
FTPSException

put

public void put()
         throws FTPSException
this is delegeted to a upload when local and remote are specified need to handle dir and file name as pattern

Specified by:
put in interface FTPOverSSLClient
Throws:
FTPSException

doRawCommands

public void doRawCommands(java.lang.String commands)
                   throws FTPSException
Specified by:
doRawCommands in interface FTPOverSSLClient
Throws:
FTPSException

GET

public void GET()
         throws FTPSException
get data from remote and apply pre and post operations if there are any configured;

Specified by:
GET in interface FTPOverSSLClient
Throws:
FTPSException

get

public void get()
         throws FTPSException
need to handle pattern as dir and file name;

Specified by:
get in interface FTPOverSSLClient
Throws:
FTPSException

mkdir

public void mkdir(java.lang.String dir)
           throws FTPSException
Description copied from interface: FTPOverSSLClient
create a remote directory as specified by parameter dir;

Specified by:
mkdir in interface FTPOverSSLClient
Throws:
FTPSException

mkdirs

public void mkdirs(java.lang.String dirs)
            throws FTPSException
Description copied from interface: FTPOverSSLClient
create remote directories as specified by parameter dirs, dirs can have more than one path components, which can be relative or absolute;

Specified by:
mkdirs in interface FTPOverSSLClient
Throws:
FTPSException

deleteDir

public void deleteDir(java.lang.String dir)
               throws FTPSException
Description copied from interface: FTPOverSSLClient
delete a remote directory specified by dir

Specified by:
deleteDir in interface FTPOverSSLClient
Parameters:
dir - - the path to the directory to be deleted;
Throws:
FTPSException

deleteFile

public void deleteFile(java.lang.String path)
                throws FTPSException
Description copied from interface: FTPOverSSLClient
delete a remote file specified by path

Specified by:
deleteFile in interface FTPOverSSLClient
Parameters:
path - - the path to the file to be deleted;
Throws:
FTPSException

renameFile

public void renameFile(java.lang.String path)
                throws FTPSException
when path is absolute, the source file represented by : Remote Directory / Remote File will be moved to the destination file, when it is relative, it is relative to the login home directory if the destination directory does not exist, it is created.

Specified by:
renameFile in interface FTPOverSSLClient
Parameters:
path -
Throws:
FTPSException

listDir

public void listDir()
             throws FTPSException
Description copied from interface: FTPOverSSLClient
list the entries under remote path specified by configuration parameters RemoteDirectory and RemoteFile only file name is available - use listDirLong() for time tamp and size information; use methods: hasEntry(), getEntry(index), nextEntry(), getEntryCount(), resetEntries() to access the entries;

Specified by:
listDir in interface FTPOverSSLClient
Throws:
FTPSException

listDirLong

public void listDirLong()
                 throws FTPSException
Description copied from interface: FTPOverSSLClient
list the entries under remote path specified by configuration parameters RemoteDirectory and RemoteFile file name, is directory flag and time stamp and size information is available - use listDir() for name only entries; use methods: hasEntry(), getEntry(index), nextEntry(), getEntryCount(), resetEntries() to access the entries;

Specified by:
listDirLong in interface FTPOverSSLClient
Throws:
FTPSException

append

public void append()
            throws FTPSException
need to handle pattern as dir and file name

Specified by:
append in interface FTPOverSSLClient
Throws:
FTPSException

upload

public void upload()
            throws FTPSException
need to handle pattern in dir and file name

Specified by:
upload in interface FTPOverSSLClient
Throws:
FTPSException

download

public void download()
              throws FTPSException
need to handle pattern in dir and file name

Specified by:
download in interface FTPOverSSLClient
Throws:
FTPSException

getEntry

public DirectoryEntry getEntry(int index)
                        throws FTPSException
Description copied from interface: FTPOverSSLClient
get the index(th) entry in the current entry list Note, current entry list is populated by calling listDir() or listDirLong();

Specified by:
getEntry in interface FTPOverSSLClient
Returns:
entry - the index(th) entry;
Throws:
FTPSException

nextEntry

public DirectoryEntry nextEntry()
                         throws FTPSException
Description copied from interface: FTPOverSSLClient
return the next entry in the current entry list;

Specified by:
nextEntry in interface FTPOverSSLClient
Returns:
Throws:
FTPSException

hasEntry

public boolean hasEntry()
Description copied from interface: FTPOverSSLClient
test if current entry list has entries;

Specified by:
hasEntry in interface FTPOverSSLClient
Returns:
true - has entries false otherwise;

getEntryCount

public int getEntryCount()
Description copied from interface: FTPOverSSLClient
return the number of entries in the current entry list;

Specified by:
getEntryCount in interface FTPOverSSLClient
Returns:

resetEntries

public void resetEntries()
Description copied from interface: FTPOverSSLClient
reset the current entry list so that next call to nextEntry() will return the first entry in the list;

Specified by:
resetEntries in interface FTPOverSSLClient

getLastReply

public java.lang.String getLastReply()
                              throws FTPSException
Description copied from interface: FTPOverSSLClient
get the FTP response code as String;

Specified by:
getLastReply in interface FTPOverSSLClient
Returns:
- response for last FTP command sent;
Throws:
FTPSException

getResolvedRemoteDirectory

public java.lang.String getResolvedRemoteDirectory()
Description copied from interface: FTPOverSSLClient
Return the current resolved remote directory name;

Specified by:
getResolvedRemoteDirectory in interface FTPOverSSLClient
Returns:
the resolved remote directory name

setResolvedRemoteDirectory

public void setResolvedRemoteDirectory(java.lang.String s)
Description copied from interface: FTPOverSSLClient
Set the current resolved remote directory name, should not be invoked directly from user collaboration;

Specified by:
setResolvedRemoteDirectory in interface FTPOverSSLClient
Parameters:
s - - the remote directory path;

getResolvedRemoteFile

public java.lang.String getResolvedRemoteFile()
Description copied from interface: FTPOverSSLClient
Return the current resolved remote file name;

Specified by:
getResolvedRemoteFile in interface FTPOverSSLClient
Returns:
the resolved name;

setResolvedRemoteFile

public void setResolvedRemoteFile(java.lang.String s)
Description copied from interface: FTPOverSSLClient
Set the current resolved remote file name, should not be invoked directly from user collaboration;;

Specified by:
setResolvedRemoteFile in interface FTPOverSSLClient
Parameters:
s - - the file name;

getResolvedLocalDirectory

public java.lang.String getResolvedLocalDirectory()
Description copied from interface: FTPOverSSLClient
Return the resolved local directory name;

Specified by:
getResolvedLocalDirectory in interface FTPOverSSLClient
Returns:
the resolved name;

setResolvedLocalDirectory

public void setResolvedLocalDirectory(java.lang.String s)
Description copied from interface: FTPOverSSLClient
Set the current resolved local directory name, should not be invoked directly from user collaboration;

Specified by:
setResolvedLocalDirectory in interface FTPOverSSLClient

getResolvedLocalFile

public java.lang.String getResolvedLocalFile()
Description copied from interface: FTPOverSSLClient
Return the current resolved local file name;

Specified by:
getResolvedLocalFile in interface FTPOverSSLClient
Returns:
the resolved name;

setResolvedLocalFile

public void setResolvedLocalFile(java.lang.String s)
Description copied from interface: FTPOverSSLClient
Set the current local file name to s, should not be invoked directly from user collaboration;

Specified by:
setResolvedLocalFile in interface FTPOverSSLClient
Parameters:
s - - the file name to be set;

resolveRemoteAsSource

public void resolveRemoteAsSource()
                           throws FTPSException
if the remote dir or file is pattern, then treat them as regex (used to match existing entries from source), otherwise, use as literal;

Specified by:
resolveRemoteAsSource in interface FTPOverSSLClient
Throws:
FTPSException

resolveLocalAsSource

public void resolveLocalAsSource()
                          throws FTPSException
if the local dir or file is pattern, then treat them as regex (used to match existing entries from source), otherwise, use as literal;

Specified by:
resolveLocalAsSource in interface FTPOverSSLClient
Throws:
FTPSException

resolveRemoteAsDestination

public void resolveRemoteAsDestination()
                                throws FTPSException
before introduce a user configurable root name for replacing %f - use a fixed one REMOTE_DEST_DIR_STUB, REMOTE_DEST_FILE_STUB, LOCAL_DEST_DIR_STUB, LOCAL_DEST_FILE_STUB if the remote dir or file is a pattern, then treat it as a name pattern (not regex - SeeBeyond propriatory patterns) such as %f, %M, %# etc.

Specified by:
resolveRemoteAsDestination in interface FTPOverSSLClient
Throws:
FTPSException

resolveLocalAsDestination

public void resolveLocalAsDestination()
                               throws FTPSException
before introduce a user configurable root name for replacing %f - use a fixed one REMOTE_DEST_DIR_STUB, REMOTE_DEST_FILE_STUB, LOCAL_DEST_DIR_STUB, LOCAL_DEST_FILE_STUB if the local dir or file is a pattern, then treat it as a name pattern (not regex - SeeBeyond propriatory patterns) such as %f, %M, %# etc.

Specified by:
resolveLocalAsDestination in interface FTPOverSSLClient
Throws:
FTPSException

getLocalFileNameStub

public java.lang.String getLocalFileNameStub()
Description copied from interface: FTPOverSSLClient
return the current name stub for local file - when local file name is a pattern this stub is used to substitute %f in a name pattern;

Specified by:
getLocalFileNameStub in interface FTPOverSSLClient
Returns:
current name stub for local file;

setLocalFileNameStub

public void setLocalFileNameStub(java.lang.String s)
Description copied from interface: FTPOverSSLClient
set the current name stub for local file - when local file name is a pattern this stub is used to substitute %f in a name pattern;

Specified by:
setLocalFileNameStub in interface FTPOverSSLClient

getLocalDirNameStub

public java.lang.String getLocalDirNameStub()
Description copied from interface: FTPOverSSLClient
return the current name stub for local directory - when local directory name is a pattern this stub is used to substitute %f in a name pattern;

Specified by:
getLocalDirNameStub in interface FTPOverSSLClient
Returns:
current name stub for local directory;

setLocalDirNameStub

public void setLocalDirNameStub(java.lang.String s)
Description copied from interface: FTPOverSSLClient
set the current name stub for local directory - when local directory name is a pattern this stub is used to substitute %f in a name pattern;

Specified by:
setLocalDirNameStub in interface FTPOverSSLClient

getRemoteFileNameStub

public java.lang.String getRemoteFileNameStub()
Description copied from interface: FTPOverSSLClient
return the current name stub for remote file - when remote file name is a pattern this stub is used to substitute %f in a name pattern;

Specified by:
getRemoteFileNameStub in interface FTPOverSSLClient
Returns:
current name stub for remote file;

setRemoteFileNameStub

public void setRemoteFileNameStub(java.lang.String s)
Description copied from interface: FTPOverSSLClient
set the current name stub for remote file - when remote file name is a pattern this stub is used to substitute %f in a name pattern;

Specified by:
setRemoteFileNameStub in interface FTPOverSSLClient

getRemoteDirNameStub

public java.lang.String getRemoteDirNameStub()
Description copied from interface: FTPOverSSLClient
return the current name stub for remote directory - when remote directory name is a pattern this stub is used to substitute %f in a name pattern;

Specified by:
getRemoteDirNameStub in interface FTPOverSSLClient
Returns:
current name stub for remote directory;

setRemoteDirNameStub

public void setRemoteDirNameStub(java.lang.String s)
Description copied from interface: FTPOverSSLClient
set the current name stub for remote directory - when remote directory name is a pattern this stub is used to substitute %f in a name pattern;

Specified by:
setRemoteDirNameStub in interface FTPOverSSLClient

Sun Adapter for Batch/FTP