com.tivoli.twg.filetransfer
Class FileSource

java.lang.Object
  extended bycom.tivoli.twg.filetransfer.FileSource
All Implemented Interfaces:
FTConstants
Direct Known Subclasses:
FSAgent, FSConsole

public abstract class FileSource
extends java.lang.Object
implements FTConstants

A File Source is a generic representation of a file system and is used by the console for all file system communications. This class mimics java.io.File in use.


Field Summary
protected static ServiceNode FSServiceNode
          The ServiceNode used for all remote file source queries.
 
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
FileSource()
          Default constructor for all file source objects.
 
Method Summary
abstract  boolean canRead(FSTObject file)
          Determines whether the specified filename can be read.
abstract  boolean canRead(java.lang.String filename)
          Determines whether the specified filename can be read.
abstract  boolean canWrite(FSTObject file)
          Determines whether the filename can be written to.
abstract  boolean canWrite(java.lang.String filename)
          Determines whether the filename can be written to.
abstract  void cleanup()
          Do all neccessary clean up here.
abstract  boolean deleteFile(FSTObject file)
          Deletes the specified file.
abstract  boolean deleteFile(java.lang.String filename)
          Deletes the specified file.
abstract  boolean exists(java.lang.String filename)
          Determines if the specified filename exists on the File Source.
abstract  java.lang.String getDefaultEncoding()
          Returns the default codepage to use for file streams.
abstract  boolean getDirectoryTree(FSTObject parent)
          Returns an updated FSTObject for a directory.
abstract  java.lang.String getDriveDelimiter()
          Get the default drive delimiter of this file source.
abstract  java.lang.String getEnvironmentVariable(java.lang.String varName)
          Get an environment variable from the file source.
abstract  FileAttrs getFileAttributes(FSTObject file)
          Get a FileAttrs object populated with the attributes of the specified file.
abstract  FileAttrs getFileAttributes(java.lang.String filename)
          Get a FileAttrs object populated with the attributes of the specified file.
abstract  long getFileSize(FSTObject file)
          Retrieves the file size of the specified file.
abstract  long getFileSize(java.lang.String filename)
          Retrieves the file size of the specified file.
abstract  int getFileSourceState()
          Get the state of filesource initialization.
static float getFiletransferVersion(java.util.Locale loc, MultiLocaleBundle ourBundle)
          Returns the version of file transfer on the current server.
abstract  java.lang.String getHostname()
          Get the hostname.
abstract  java.io.InputStream getInputStream(FSTObject file)
          Returns an InputStream for the specified file.
abstract  java.io.InputStream getInputStream(java.lang.String filename)
          Returns an InputStream for the specified file.
abstract  java.lang.String getNameDelimiter()
          Get the default name delimiter of this file source.
abstract  java.io.OutputStream getOutputStream(FSTObject file)
          Returns an OutputStream for the specified file.
abstract  java.io.OutputStream getOutputStream(java.lang.String filename)
          Returns an OutputStream for the specified file.
abstract  java.lang.String getPathDelimiter()
          Get the default path delimiter of this file source.
abstract  byte[] getRegBytesValue(java.lang.String keyName, java.lang.String valueName)
          Get a registry value of type byte[] from the file source.
abstract  int getRegIntValue(java.lang.String keyName, java.lang.String valueName)
          Get a registry value of type int from the file source.
abstract  java.lang.String getRegStringValue(java.lang.String keyName, java.lang.String valueName)
          Get a registry value of type String from the file source.
abstract  java.lang.String getRootDelimiter()
          Get the default root delimiter of this file source.
abstract  FSTObject[] getRootLevel()
          Get the root level of the file source (e.g.
abstract  java.lang.String getSearchString()
          Get the default search string of this file source.
static boolean hasServerFSAccess()
          Does the current user have access to the server?
abstract  boolean isAbsolute(java.lang.String filename)
          Determines whether the filename is an absolute path.
abstract  boolean isDirectory(java.lang.String filename)
          Determines if the specified filename exists, and is a DIRECTORY, rather than a FILE.
abstract  boolean isFile(java.lang.String filename)
          Determines if the specified filename exists, and is a FILE, rather than a DIRECTORY.
abstract  boolean mkdir(FSTObject directory)
          Creates the specified directory.
abstract  boolean mkdir(java.lang.String directoryName)
          Creates the specified directory.
abstract  boolean mkdir(java.lang.String directoryName, FileAttrs attrs)
          Creates the specified directory.
abstract  void refresh()
          Refreshes the file source drive list.
protected static void removeFSServiceNodeUse()
          This method should be called from cleanup.
abstract  boolean renameFile(FSTObject file, java.lang.String newFilename)
          Renames the specified file to newFilename.
abstract  boolean renameFile(java.lang.String originalFilename, java.lang.String newFilename)
          Renames the specified file to newFilename.
abstract  void setHostname(java.lang.String host)
          Set the hostname.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FSServiceNode

protected static ServiceNode FSServiceNode
The ServiceNode used for all remote file source queries.

Constructor Detail

FileSource

public FileSource()
           throws FTException
Default constructor for all file source objects. Initializes the static service node for the file source if it is not yet initialized.

Method Detail

removeFSServiceNodeUse

protected static void removeFSServiceNodeUse()
                                      throws FTException
This method should be called from cleanup.

Throws:
FTException

hasServerFSAccess

public static boolean hasServerFSAccess()
Does the current user have access to the server?


getFiletransferVersion

public static float getFiletransferVersion(java.util.Locale loc,
                                           MultiLocaleBundle ourBundle)
Returns the version of file transfer on the current server.

Returns:
float - returns -1 if file transfer is not present.

setHostname

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


getHostname

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


getFileSourceState

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

Returns:
int - one of: FTConstants.UNINITIALIZED_FILE_SOURCE FTConstants.INITIALIZING_FILE_SOURCE FTConstants.FILE_SOURCE_READY FTConstants.FILE_SOURCE_UNAVAILABLE

refresh

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

Throws:
FTException

getDirectoryTree

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

Parameters:
parent - the node to get file system info for
Returns:
boolean - true if direcotory has children.
Throws:
FTException

getRootLevel

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

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

exists

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

Returns:
boolean - true if the file exists.
Throws:
FTException

isFile

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

Returns:
boolean - true if the file exists and is a file.
Throws:
FTException

isDirectory

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

Returns:
boolean - true if the directory exists and is a directory.
Throws:
FTException

isAbsolute

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

Returns:
boolean - true if filename is an absolute path.

canWrite

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

Returns:
boolean - true if filename is writeable.
Throws:
FTException

canWrite

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

Returns:
boolean - true if filename is writeable.
Throws:
FTException

canRead

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

Returns:
boolean - true if filename is readable.
Throws:
FTException

canRead

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

Returns:
boolean - true if filename is readable.
Throws:
FTException

deleteFile

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

Returns:
boolean - true if the file was deleted.
Throws:
FTException

deleteFile

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

Returns:
boolean - true if the file was deleted.
Throws:
FTException

getFileSize

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

Returns:
long - size of the file, in bytes.
Throws:
FTException

getFileSize

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

Returns:
long - size of the file, in bytes.
Throws:
FTException

mkdir

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

Returns:
boolean - true if directory creation was successful.
Throws:
FTException

mkdir

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

Returns:
boolean - true if directory creation was successful.
Throws:
FTException

mkdir

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

Returns:
boolean - true if directory creation was successful.
Throws:
FTException

renameFile

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

Returns:
boolean - true if rename was successful.
Throws:
FTException

renameFile

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

Returns:
boolean - true if rename was successful.
Throws:
FTException

getInputStream

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

Returns:
InputStream - stream from the specified file.
Throws:
FTException

getInputStream

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

Returns:
InputStream - stream from the specified file.
Throws:
FTException

getOutputStream

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

Returns:
OutputStream - stream to the specified file.
Throws:
FTException

getOutputStream

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

Returns:
OutputStream - stream to the specified file.
Throws:
FTException

getRegStringValue

public abstract 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.

Returns:
String - registry value.
Throws:
FTException

getRegBytesValue

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

Returns:
byte[] - registry value.
Throws:
FTException

getRegIntValue

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

Returns:
int - registry value.
Throws:
FTException

getEnvironmentVariable

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

Returns:
String - environment variable value.
Throws:
FTException

getFileAttributes

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

Returns:
FileAttrs - File Attributes of the specified file.
Throws:
FTException

getFileAttributes

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

Returns:
FileAttrs - File Attributes of the specified file.
Throws:
FTException

getDriveDelimiter

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

Returns:
String - the default drive delimiter.

getPathDelimiter

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

Returns:
String - the path drive delimiter.

getNameDelimiter

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

Returns:
String - the default name delimiter.

getRootDelimiter

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

Returns:
String - the default root delimiter.

getSearchString

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

Returns:
String - the default search string.

getDefaultEncoding

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

Returns:
String - codepage string in the java format.

cleanup

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

Throws:
FTException