com.tivoli.twg.filetransfer
Class FSConsole

java.lang.Object
  extended bycom.tivoli.twg.filetransfer.FileSource
      extended bycom.tivoli.twg.filetransfer.FSConsole
All Implemented Interfaces:
FTConstants

public class FSConsole
extends FileSource

Console or Local implementation of FileSource. This is a generic wrapper for local file accesses.


Field Summary
 
Fields inherited from class com.tivoli.twg.filetransfer.FileSource
FSServiceNode
 
Fields inherited from interface com.tivoli.twg.filetransfer.FTConstants
ADDRESS_DELIMITER, AGENT, AMBIGUOUS, ATSET_ERR, ATTRIBUTE_ERR, BASE_DEAD, BC_TYPE_BEST_COMPRESSION, BC_TYPE_BEST_SPEED, BC_TYPE_DEFAULT_COMPRESSION, BC_TYPE_UNCOMP, CANCEL_TRANSFER_FAILED, CLEANUP, COMMUNICATION_EXCEPTION, COMPRESSION_FAILED, CONSOLE, DECOMPRESSION_FAILED, DEFAULT_BUFFER_SIZE, DEFAULT_DRIVE_DELIMITER, DEFAULT_MAXIMUM_BUFFER_SIZE, DEFAULT_NAME_DELIMITER, DEFAULT_PATH_DELIMITER, DEFAULT_ROOT, DEFAULT_SEARCH_STRING, DEFAULT_TIMEOUT, DIR_DELETE_ERROR, DIRECTORY_SYSTEM, DISK_ACCESS, DOSCLOSE_ERR, DOSCREATEDIR_FAIL, DOSDELETE_FAIL, DOSFINDDIRS_FAIL, DOSOPENS_ERR, DOSOPENS_FAIL, DOSOPENT_ERR, DOSOPENT_FAIL, DOSREAD_ERR, DOSREAD_FAIL, DOSREADONLY_ERR, D OSSETCURRENT_FAIL, DOSWRITE_ERR, DOSWRITE_FAIL, DRIVE_SIZE, DRIVE_SYSTEM, FILE_DELETE_ERROR, FILE_NOT_FOUND, FILE_PTR_ERR, FILE_QUERY_FAIL, FILE_SET_FAIL, FILE_SIZE_MISMATCH, FILE_SOURCE_READY, FILE_SOURCE_UNAVAILABLE, FILE_TRANSFER_BASE_DIRECTORY_ALREADY_EXISTS, FILE_TRANSFER_BASE_DIRECTORY_DOES_NOT_EXIST, FILE_TRANSFER_BASE_DIRECTORY_NOT_EMPTY, FILE_TRANSFER_BASE_FILE_NOT_FOUND, FILE_TRANSFER_BASE_INSUFFICIENT_STORAGE, FILE_TRANSFER_BASE_INVALID_PARAMETER, FILE_TRANSFER_BASE_MKDIR_FAILED, FILE_TRANSFER_BASE_NOT_AUTHORIZED, FILE_TRANSFER_BASE_OPEN_FAILED, FILE_TRANSFER_BASE_RMDIR_FAILED, FILE_TRANSFER_BASE_SUCCESS, FILE_TRANSFER_BASE_SYSTEM_NOT_AVAILABLE, FILE_TRANSFER_BASE_TIME_OUT, FILE_TRANSFER_BASE_UNEXPECTED_ERROR, FIRST_CHUNK, FS_QUERY_FAIL, GENERAL_EXCEPTION, GENERIC_FAILURE, INIT_FAIL, INITIALIZING_FILE_SOURCE, INSUFFICIENT_INPUT_PARMS, INTERRUPTED_EXCEPTION, INVALID_COMMAND, INVALID_DIR_QUERY1, INVALID_DIR_QUERY2, INVALID_DIR_QUERY3, INVALID_DIR_QUERY4, INVALID_DIR_SET1, INVALID_DIR_SET2, INVALID_DIR_SET3, INVALID_DIR_SET4, INVALID_DIR_SET5, INVALID_DIR_SET6, INVALID_INPUT_PARM, INVALID_PARM_EXCEPTION, IO_EXCEPTION, LAST_CHUNK, MAXIMUM_BUFFER_SIZE, MEMORY_CONSTRAINED, MIDDLE_CHUNK, MKDIR_FAILED, NEED_MORE_INFO, NO_FILESIZE, NO_FILESIZE_FAIL, NOT_ENOUGH_ROOM, NUMBER_SEND_RETRIES, ONLY_CHUNK, OPEN_FAILED, POSTATTRIBUTE_ERR, PREATTRIBUTE_ERR, QUERY_DISK_FAIL, RECEIVE_DIR_ERR, REG_BINARY, REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_DWORD_LITTLE_ENDIAN, REG_EXPAND_SZ, REG_NONE, REG_SZ, REMOVE_FILE_FAILED, REMXCOPY_FAIL, REQUEST_ACCESS, RESULT_BAD_PWD_LEN, RESULT_FAILED, RESULT_NOT_ACCESSABLE, RESULT_NOT_AUTHORIZED, RESULT_NOT_AVAIL, RESULT_OK, RESULT_UNSUPPORTED, RMDIR_FAILED, SECURITY_EXCEPTION, SEEK_FAILED, SEM_FAIL, SEM_TIMEOUT, SERVER, SERVICE_ACTIVATION_EXCEPTION, SERVICENODE_EXCEPTION, SET_DISK_FAIL, SORRY_IN_USE, START_AGENT_TASK_NAME, STATELESS_CANCEL_DIRECTED, STATELESS_CLEANUP_SCAN, STATELESS_CLEANUP_SCAN2, STATELESS_DELETE_FILE, STATELESS_DIR_LIST, STATELESS_DIRECTED_GET, STATELESS_DIRECTED_GET_SIZE, STATELESS_DIRECTED_GET_SIZE2, STATELESS_DIRECTED_GET2, STATELESS_DIRECTED_SEND, STATELESS_DIRECTED_SEND2, STATELESS_FILE_LIST, STATELESS_GET_ATTRIBS, STATELESS_GET_ATTRIBS2, STATELESS_GET_DRIVE_INFO, STATELESS_GET_ENV, STATELESS_GET_REG, STATELESS_INIT, STATELESS_MKDIR, STATELESS_NEGOTIATE, STATELESS_RECV_FILE, STATELESS_RECV_FILE2, STATELESS_RENAME_FILE, STATELESS_RMDIR, STATELESS_SEND_FILE, STATELESS_SEND_FILE2, SUB_DELETE_ERROR, SYSTEM_SECURED, TASK_ID, TIMEOUT, TOO_MANY, TRANSFER_SIZE_MISMATCH, TWG_FILE_TRANSFER_BASE, TWG_SERVICE_MANAGER, UNINITIALIZED_FILE_SOURCE, V1_CAN_WRITE, V1_CLIENT_SN_NAME, V1_DELETE_LOCAL_FILES, V1_DOES_DIR_EXIST, V1_DOES_FILE_EXIST, V1_FAILURE, V1_FILE_NOT_FOUND, V1_FILE_TOO_LARGE, V1_FILL_DIRECTORY, V1_GET_DRIVES, V1_GET_LOCAL_PROPERTIES, V1_GET_REMOTE_FILES, V1_IO_EXCEPTION, V1_IS_ABSOLUTE, V1_IS_DIRECTORY, V1_IS_DRIVE_SYSTEM, V1_MAKE_LOCAL_DIRECTORY, V1_MAX_READ_WRITE_FILE_SIZE, V1_PUT_LOCAL_FILES, V1_READ_FILE, V1_REGISTRY_ ERROR, V1_SERVER, V1_SERVER_SN_NAME, V1_SOURCE_IS_DRIVE_SYSTEM, V1_SOURCE_NOT_DRIVE_SYSTEM, V1_SUCCESS, V1_WRITE_FILE, VERSION_121
 
Constructor Summary
FSConsole()
          Default Constructor.
 
Method Summary
 boolean canRead(FSTObject file)
          Determines whether the specified filename can be read.
 boolean canRead(java.lang.String filename)
          Determines whether the specified filename can be read.
 boolean canWrite(FSTObject file)
          Determines whether the filename can be written to.
 boolean canWrite(java.lang.String filename)
          Determines whether the filename can be written to.
 void cleanup()
          Do all neccessary clean up here.
 boolean deleteFile(FSTObject file)
          Deletes the specified file.
 boolean deleteFile(java.lang.String filename)
          Deletes the specified file.
 boolean exists(java.lang.String filename)
          Determines if the specified filename exists on the File Source.
 java.lang.String getDefaultEncoding()
          Returns the default codepage to use for file streams.
 boolean getDirectoryTree(FSTObject parent)
          Returns an updated FSTObject for a directory.
 java.lang.String getDriveDelimiter()
          Get the default drive delimiter of this file source.
 java.lang.String getEnvironmentVariable(java.lang.String varName)
          Get an environment variable from the file source.
 FileAttrs getFileAttributes(FSTObject file)
          Get a FileAttrs object populated with the attributes of the specified file.
 FileAttrs getFileAttributes(java.lang.String filename)
          Get a FileAttrs object populated with the attributes of the specified file.
 long getFileSize(FSTObject file)
          Retrieves the file size of the specified file.
 long getFileSize(java.lang.String filename)
          Retrieves the file size of the specified file.
 int getFileSourceState()
          Get the state of filesource initialization.
 java.lang.String getHostname()
          Get the hostname.
 java.io.InputStream getInputStream(FSTObject file)
          Returns an InputStream for the specified file.
 java.io.InputStream getInputStream(java.lang.String filename)
          Returns an InputStream for the specified file.
 java.lang.String getNameDelimiter()
          Get the default name delimiter of this file source.
 java.io.OutputStream getOutputStream(FSTObject file)
          Returns an OutputStream for the specified file.
 java.io.OutputStream getOutputStream(java.lang.String filename)
          Returns an OutputStream for the specified file.
 java.lang.String getPathDelimiter()
          Get the default path delimiter of this file source.
 byte[] getRegBytesValue(java.lang.String keyName, java.lang.String valueName)
          Get a registry value of type byte[] from the file source.
 int getRegIntValue(java.lang.String keyName, java.lang.String valueName)
          Get a registry value of type int from the file source.
 java.lang.String getRegStringValue(java.lang.String keyName, java.lang.String valueName)
          Get a registry value of type String from the file source.
 java.lang.String getRootDelimiter()
          Get the default root delimiter of this file source.
 FSTObject[] getRootLevel()
          Get the root level of the file source (e.g.
 java.lang.String getSearchString()
          Get the default search string of this file source.
 boolean isAbsolute(java.lang.String filename)
          Determines whether the filename is an absolute path.
 boolean isDirectory(java.lang.String filename)
          Determines if the specified filename exists, and is a DIRECTORY, rather than a FILE.
 boolean isFile(java.lang.String filename)
          Determines if the specified filename exists, and is a FILE, rather than a DIRECTORY.
 boolean mkdir(FSTObject directory)
          Creates the specified directory.
 boolean mkdir(java.lang.String directoryName)
          Creates the specified directory.
 boolean mkdir(java.lang.String directoryName, FileAttrs attrs)
          Creates the specified directory.
 void refresh()
          Refreshes the file source drive list.
 boolean renameFile(FSTObject file, java.lang.String newFilename)
          Renames the specified file to newFilename.
 boolean renameFile(java.lang.String originalFilename, java.lang.String newFilename)
          Renames the specified file to newFilename.
 boolean rmdir(FSTObject directory)
          Delete the specified directory.
 boolean rmdir(java.lang.String directoryName)
          Delete the specified directory.
static boolean setFileAttributes(java.lang.String filename, FileAttrs attributes)
          Set attributes on the local file source.
static boolean setFileAttributes(java.lang.String filename, FileAttrs attributes, boolean setDate)
          Set attributes on the local file source.
 void setHostname(java.lang.String host)
          Set the hostname.
 
Methods inherited from class com.tivoli.twg.filetransfer.FileSource
getFiletransferVersion, hasServerFSAccess, removeFSServiceNodeUse
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FSConsole

public FSConsole()
          throws FTException
Default Constructor.

Method Detail

setHostname

public void setHostname(java.lang.String host)
Set the hostname.

Specified by:
setHostname in class FileSource

getHostname

public java.lang.String getHostname()
Get the hostname.

Specified by:
getHostname in class FileSource

getFileSourceState

public int getFileSourceState()
Get the state of filesource initialization.

Specified by:
getFileSourceState in class FileSource
Returns:
int - one of: FTConstants.UNINITIALIZED_FILE_SOURCE FTConstants.INITIALIZING_FILE_SOURCE FTConstants.FILE_SOURCE_READY FTConstants.FILE_SOURCE_UNAVAILABLE

refresh

public void refresh()
             throws FTException
Refreshes the file source drive list.

Specified by:
refresh in class FileSource
Throws:
FTException

getDirectoryTree

public boolean getDirectoryTree(FSTObject parent)
                         throws FTException
Returns an updated FSTObject for a directory.

Specified by:
getDirectoryTree in class FileSource
Parameters:
parent - the node to get file system info for
Returns:
boolean - true if direcotory has children.
Throws:
FTException

getRootLevel

public FSTObject[] getRootLevel()
                         throws FTException
Get the root level of the file source (e.g. list of drives).

Specified by:
getRootLevel in class FileSource
Returns:
FSTObject[] - array of FSTObjects representing the root directory directory. It should be populated with direct children (files and dirs).
Throws:
FTException

exists

public boolean exists(java.lang.String filename)
               throws FTException
Determines if the specified filename exists on the File Source.

Specified by:
exists in class FileSource
Returns:
boolean - true if the file exists.
Throws:
FTException

isFile

public boolean isFile(java.lang.String filename)
               throws FTException
Determines if the specified filename exists, and is a FILE, rather than a DIRECTORY.

Specified by:
isFile in class FileSource
Returns:
boolean - true if the file exists and is a file.
Throws:
FTException

isDirectory

public boolean isDirectory(java.lang.String filename)
                    throws FTException
Determines if the specified filename exists, and is a DIRECTORY, rather than a FILE.

Specified by:
isDirectory in class FileSource
Returns:
boolean - true if the directory exists and is a directory.
Throws:
FTException

isAbsolute

public boolean isAbsolute(java.lang.String filename)
Determines whether the filename is an absolute path.

Specified by:
isAbsolute in class FileSource
Returns:
boolean - true if filename is an absolute path.

canWrite

public boolean canWrite(java.lang.String filename)
                 throws FTException
Determines whether the filename can be written to.

Specified by:
canWrite in class FileSource
Returns:
boolean - true if filename is writeable.
Throws:
FTException

canWrite

public boolean canWrite(FSTObject file)
                 throws FTException
Determines whether the filename can be written to.

Specified by:
canWrite in class FileSource
Returns:
boolean - true if filename is writeable.
Throws:
FTException

canRead

public boolean canRead(java.lang.String filename)
                throws FTException
Determines whether the specified filename can be read.

Specified by:
canRead in class FileSource
Returns:
boolean - true if filename is readable.
Throws:
FTException

canRead

public boolean canRead(FSTObject file)
                throws FTException
Determines whether the specified filename can be read.

Specified by:
canRead in class FileSource
Returns:
boolean - true if filename is readable.
Throws:
FTException

deleteFile

public boolean deleteFile(java.lang.String filename)
                   throws FTException
Deletes the specified file.

Specified by:
deleteFile in class FileSource
Returns:
boolean - true if the file was deleted.
Throws:
FTException

deleteFile

public boolean deleteFile(FSTObject file)
                   throws FTException
Deletes the specified file. This one is faster, so if you've got an FSTObject, use it.

Specified by:
deleteFile in class FileSource
Returns:
boolean - true if the file was deleted.
Throws:
FTException

getFileSize

public long getFileSize(java.lang.String filename)
                 throws FTException
Retrieves the file size of the specified file.

Specified by:
getFileSize in class FileSource
Returns:
long - size of the file, in bytes.
Throws:
FTException

getFileSize

public long getFileSize(FSTObject file)
                 throws FTException
Retrieves the file size of the specified file.

Specified by:
getFileSize in class FileSource
Returns:
long - size of the file, in bytes.
Throws:
FTException

mkdir

public boolean mkdir(java.lang.String directoryName)
              throws FTException
Creates the specified directory.

Specified by:
mkdir in class FileSource
Returns:
boolean - true if directory creation was successful.
Throws:
FTException

mkdir

public boolean mkdir(java.lang.String directoryName,
                     FileAttrs attrs)
              throws FTException
Creates the specified directory.

Specified by:
mkdir in class FileSource
Returns:
boolean - true if directory creation was successful.
Throws:
FTException

mkdir

public boolean mkdir(FSTObject directory)
              throws FTException
Creates the specified directory.

Specified by:
mkdir in class FileSource
Returns:
boolean - true if directory creation was successful.
Throws:
FTException

renameFile

public boolean renameFile(java.lang.String originalFilename,
                          java.lang.String newFilename)
                   throws FTException
Renames the specified file to newFilename.

Specified by:
renameFile in class FileSource
Returns:
boolean - true if rename was successful.
Throws:
FTException

renameFile

public boolean renameFile(FSTObject file,
                          java.lang.String newFilename)
                   throws FTException
Renames the specified file to newFilename.

Specified by:
renameFile in class FileSource
Returns:
boolean - true if rename was successful.
Throws:
FTException

getInputStream

public java.io.InputStream getInputStream(java.lang.String filename)
                                   throws FTException
Returns an InputStream for the specified file.

Specified by:
getInputStream in class FileSource
Returns:
InputStream - stream from the specified file.
Throws:
FTException

getInputStream

public java.io.InputStream getInputStream(FSTObject file)
                                   throws FTException
Returns an InputStream for the specified file.

Specified by:
getInputStream in class FileSource
Returns:
InputStream - stream from the specified file.
Throws:
FTException

getOutputStream

public java.io.OutputStream getOutputStream(java.lang.String filename)
                                     throws FTException
Returns an OutputStream for the specified file.

Specified by:
getOutputStream in class FileSource
Returns:
OutputStream - stream to the specified file.
Throws:
FTException

getOutputStream

public java.io.OutputStream getOutputStream(FSTObject file)
                                     throws FTException
Returns an OutputStream for the specified file.

Specified by:
getOutputStream in class FileSource
Returns:
OutputStream - stream to the specified file.
Throws:
FTException

getFileAttributes

public FileAttrs getFileAttributes(java.lang.String filename)
                            throws FTException
Get a FileAttrs object populated with the attributes of the specified file.

Specified by:
getFileAttributes in class FileSource
Returns:
FileAttrs - File Attributes of the specified file.
Throws:
FTException

getFileAttributes

public FileAttrs getFileAttributes(FSTObject file)
                            throws FTException
Get a FileAttrs object populated with the attributes of the specified file.

Specified by:
getFileAttributes in class FileSource
Returns:
FileAttrs - File Attributes of the specified file.
Throws:
FTException

getDriveDelimiter

public java.lang.String getDriveDelimiter()
Get the default drive delimiter of this file source.

Specified by:
getDriveDelimiter in class FileSource
Returns:
String - the default drive delimiter.

getPathDelimiter

public java.lang.String getPathDelimiter()
Get the default path delimiter of this file source.

Specified by:
getPathDelimiter in class FileSource
Returns:
String - the path drive delimiter.

getNameDelimiter

public java.lang.String getNameDelimiter()
Get the default name delimiter of this file source.

Specified by:
getNameDelimiter in class FileSource
Returns:
String - the default name delimiter.

getRootDelimiter

public java.lang.String getRootDelimiter()
Get the default root delimiter of this file source.

Specified by:
getRootDelimiter in class FileSource
Returns:
String - the default root delimiter.

getSearchString

public java.lang.String getSearchString()
Get the default search string of this file source.

Specified by:
getSearchString in class FileSource
Returns:
String - the default search string.

getDefaultEncoding

public java.lang.String getDefaultEncoding()
Returns the default codepage to use for file streams.

Specified by:
getDefaultEncoding in class FileSource
Returns:
String - codepage string in the java format.

cleanup

public void cleanup()
             throws FTException
Do all neccessary clean up here.

Specified by:
cleanup in class FileSource
Throws:
FTException

getRegStringValue

public java.lang.String getRegStringValue(java.lang.String keyName,
                                          java.lang.String valueName)
                                   throws FTException
Get a registry value of type String from the file source.

Specified by:
getRegStringValue in class FileSource
Returns:
String - registry value.
Throws:
FTException

getRegBytesValue

public byte[] getRegBytesValue(java.lang.String keyName,
                               java.lang.String valueName)
                        throws FTException
Get a registry value of type byte[] from the file source.

Specified by:
getRegBytesValue in class FileSource
Returns:
byte[] - registry value.
Throws:
FTException

getRegIntValue

public int getRegIntValue(java.lang.String keyName,
                          java.lang.String valueName)
                   throws FTException
Get a registry value of type int from the file source.

Specified by:
getRegIntValue in class FileSource
Returns:
int - registry value.
Throws:
FTException

getEnvironmentVariable

public java.lang.String getEnvironmentVariable(java.lang.String varName)
                                        throws FTException
Get an environment variable from the file source.

Specified by:
getEnvironmentVariable in class FileSource
Returns:
String - environment variable value.
Throws:
FTException

rmdir

public boolean rmdir(java.lang.String directoryName)
              throws FTException
Delete the specified directory.

Returns:
boolean - true if the directory remove worked.
Throws:
FTException

rmdir

public boolean rmdir(FSTObject directory)
              throws FTException
Delete the specified directory.

Returns:
boolean - true if the directory remove worked.
Throws:
FTException

setFileAttributes

public static boolean setFileAttributes(java.lang.String filename,
                                        FileAttrs attributes)
Set attributes on the local file source.


setFileAttributes

public static boolean setFileAttributes(java.lang.String filename,
                                        FileAttrs attributes,
                                        boolean setDate)
Set attributes on the local file source.

Parameters:
setDate - - if true, set the date, otherwise ignore the date and only set the attributes.