wt.clients.util.http
Class HTTPUploadDownload

java.lang.Object
  extended bywt.clients.util.http.HTTPUploadDownload

public final class HTTPUploadDownload
extends Object

HTTPUploadDownload is a generic class of object used to upload or download files from client file system. HTTPUploadDownload instances work with applications and applets. HTTPUploadDownload supports Netscape, Microsoft and Java 2 plugin security models. In addition to uploading a series of files instances of HTTPUploadDownload can accumulate a set of post parameters to be submitted with the http multi-part post operation.

Supported API:false

Extendable:false


Nested Class Summary
(package private)  class HTTPUploadDownload.DownloadProgressListener
           
(package private)  class HTTPUploadDownload.HTTPUploadDownloadThread
          Inner class to provide threaded capability while not making HTTPUploadDownload implement Thread or Runnable.
(package private)  class HTTPUploadDownload.UploadProgressListener
           
 
Field Summary
private  boolean calculateChecksums
           
private static boolean DEBUG
           
static String DEFAULT_FILENAME
          Default file name property name.
private  String defaultFilename
           
private  Download download
           
static int FAILURE_FILE_NOT_FOUND
          Indicates that the file does not exist.
static int FAILURE_HTTP_ERROR
          Indicates that an httpwhile processing the request.
static int FAILURE_IO_ERROR
          Indicates that an io error occurred when accessing the file.
static int FAILURE_NONE
          Indicates that no failure has occurred.
static int FILE_OPERATION_CANCEL
          File operation cancelled by user.
static int FILE_OPERATION_CANCEL_REQUEST
          File operation cancelled requested by user.
static int FILE_OPERATION_COMPLETE
           
static int FILE_OPERATION_FAILURE
           
static int FILE_OPERATION_INACTIVE
          File operation not active.
static int FILE_OPERATION_START
          File entry process start.
static int FILE_OPERATION_TYPE_OPEN
          File operation type for application launch.
static int FILE_OPERATION_TYPE_TRANSFER
          File operation type for file transfer.
static int FILE_OPERATION_TYPE_UNKNOWN
          File operation type unknown.
static int FILE_OPERATION_UNKNOWN_FAILURE
           
private  Vector fileEntries
           
static String GLOBAL_FILE_CHANGE_PROMPT
          Global "no file change warning" property name.
static String GLOBAL_OVERWRITE_WARNING
          Global overwrite property name.
private  boolean globalFileChangePrompt
           
private  boolean globalOverwriteWarning
           
static String HOST_URL
          Host URL property name.
static int HTTP_RESPONSE_CODE_NONE
          Indicates HTTP response code not set.
private  int httpResponseCode
           
private  MultiPartPostIfc multiPartPost
           
static String NAME
          File post name property name.
private  int nextDownloadEntry
           
static int OPERATION_CANCEL
          Indicates that the file upload was cancelled by the user.
static int OPERATION_CANCEL_REQUEST
          Indicates that the application has requested that the current upload or download operation be canceled.
static int OPERATION_COMPLETE
          Indicates that the file upload operation has completed succesfully.
static int OPERATION_FAILURE
          Indicates the file upload failed.
static int OPERATION_INACTIVE
          Indicate that there is no upload/download operation active.
static int OPERATION_REQUEST
          Indicates that the user requested upload/download operation.
static int OPERATION_START
          Indicates that the operation has started.
static String OPERATION_TYPE
          Operation type indicator.
static int OPERATION_TYPE_DOWNLOAD
          Download operation indicator.
static int OPERATION_TYPE_UNKNOWN
          Unknown operation indicator.
static int OPERATION_TYPE_UPLOAD
          Upload operation indicator.
static int OPERATION_UNKNOWN_FAILURE
           
private  int operationFailureCode
           
private  int operationStatus
           
private  HTTPUploadDownload.HTTPUploadDownloadThread operationThread
           
private  int operationType
           
static String OVERWRITE_WARNING
          Indicates that an individual file overwrite warning flag has changed.
static String PATH
          File path property name.
private  Hashtable postParameters
           
private  boolean suppressFileLocator
           
static String UPLOAD_URL
          UploadURL property name.
private  Hashtable uploadDownloadListeners
           
private  String uploadImpl
           
private  MultiPartPostListener uploadListener
           
private  boolean uploadToCacheOnly
           
private  URL uploadURL
           
static String URL
          URL property name.
private static boolean VALID_EMPTY_FILE
           
 
Constructor Summary
HTTPUploadDownload()
          Initialize this upload download object, providing an initial url, file path.
 
Method Summary
 void addHTTPUploadDownloadListener(HTTPUploadDownloadListener l)
          Add listeners to upload and download events.
 boolean addPostParameter(String key, String value)
          Record a parameter to be supplied with the upload operation.
 boolean addPostParameter(String key, String value, int index)
          Record a parameter to be supplied with the upload operation for the file at the specified index.
 boolean cancelOperation()
          Request operation cancel.
private  boolean canRead(String path)
           
private  boolean canWrite(String path)
           
 boolean clear()
          Clear the post parameters and file entries.
private  void clearFileEntries()
           
 boolean clearPostParameters()
          Remove all post parameters.
private  boolean confirmFileDownload(int index)
           
private  boolean confirmFileOverwrite(FileEntry fileEntry, int index)
           
private  boolean confirmFileUpload(int index)
           
private  File createFile(String path)
           
static URL createURL(String urlString)
           
private  boolean downloadFileTransfer(FileEntry nextFileEntry, int nextEntry)
           
 void dumpFileEntries()
           
 void dumpFileEntry(int index)
           
private  void dumpPostParameters(Hashtable postParameters)
           
private  boolean fileExists(File file)
           
private  void fileOperationStatusChange(int status, String path, int count)
           
private  void fileOperationTypeUnknown(URL url, String filePath, int fileIndex)
           
 String getCacheInfo()
           
 long getChecksum(int fileIndex)
          Get the cheksum for the file at fileIndex, which will be -1 if not calculated.
 String getDefaultFilename()
          Get the file name default, e.g."c:\\temp\\*.txt".
private  FileEntry getFileEntryAt(int i)
           
 int getFileOperationStatus(int index)
           
 int getFileOperationType(int fileIndex)
          Return file operation type of:
HTTPUploadDownload.FILE_OPERATION_TYPE_UNKNOWN
HTTPUploadDownload.FILE_OPERATION_TYPE_TRANSFER
HTTPUploadDownload.FILE_OPERATION_TYPE_OPEN
 boolean getGlobalFileChangePrompt()
          Return the global no file change warning flag.
 boolean getGlobalOverwriteWarning()
          Return the global overwrite warning flag.
 String getHostURL(int i)
          Return the current value of the host URL for the file at the specified index.
 int getHTTPResponseCode()
          Return the HTTP response code returned from the post.
 int getMaxHTTPUploadDownloadCount()
          Return the maximum number of files to upload or download.
 MultiPartPostIfc getMultiPartPost()
           
 String getName(int i)
          Return the local file post name for the upload/download entry.
 int getOperationFailureCode()
           
 int getOperationStatus()
          Return operation status.
 int getOperationStatus(int i)
          Return operation status for file.
 String getOperationStatusMessage()
          Return the operation status message.
 String getOperationStatusMessage(int i)
          Return operation status message for file i.
 int getOperationType()
          Return the type of the current upload or download operation, either UPLOAD or DOWNLOAD.
 boolean getOverwriteWarning(int fileIndex)
          Return the overwrite warning flag for the individual file.
 String getPath(int i)
          Return the local file path for the upload/download entry.
 boolean getSuppressFileLocator()
           
 String getUploadImpl()
          Retrieve uploadImpl value - valid values are rmi|http|echo
 boolean getUploadToCacheOnly()
           
 String getUploadURL()
          Return the url to be used for the upload.
 String getURL(int i)
          Return the current value of the content URL for the file at the specified index.
private  void invalidFile(String filePath, int fileIndex, String reason)
           
private  void invalidFile(String filePath, int fileIndex, String messageKey, Object[] params)
          The file at fileIndex is invalid.
private  boolean isAbsoluteDirectoryPath(String path)
           
private  boolean isAbsoluteFilePath(String path)
           
 boolean isCalculateChecksums()
           
 boolean isCancelled(int fileIndex)
           
 boolean isOperationActive()
           
private  void locateFile(String filePath, int fileIndex)
           
private static boolean looksLikeAbsoluteDirectoryPath(String s)
           
private static boolean looksLikeAbsoluteFilePath(String s)
           
private static boolean looksLikeAbsolutePath(String s)
           
private  void openApplication(String path, int fileEntryIndex)
           
private  void openContents()
          This operation is called following the file download phase to open any url's or files marked for being opened.
private  boolean openURL(FileEntry nextFileEntry, int nextEntry)
           
private  void operationFinished(int status)
           
private  void operationStatusChange(int status)
           
 Thread performDownload(boolean separateThread)
          Perform the download.
private  void performDownloadOperation()
          This method has three phases: validation, download, and open.
 Thread performUpload(boolean separateThread)
          Perform the upload operation.
private  void performUploadOperation()
          Return true if the operation started, false otherwise.
private static void PP(String message)
           
private  void propertyChange(String propertyName, int propertyIndex, Object newValue)
           
 void removeHTTPUploadDownloadListener(HTTPUploadDownloadListener l)
          Remove upload/download listener.
 boolean removePostParameter(String key)
          Remove the parameter from the upload operation.
 boolean removePostParameter(String key, int index)
          Remove the parameter from the upload operation for the file at the specified index.
(package private)  int searchForEntry(String key, String value)
           
 void setCalculateChecksums(boolean calculateChecksums)
           
 boolean setCancelled(boolean newValue, int fileIndex)
           
 void setChecksum(long checksum, int fileIndex)
           
 boolean setDefaultFilename(String newValue)
          Set the file name default, e.g.
private  void setFileOperationStatus(int status, int index)
           
 boolean setFileOperationType(int fileOperationType, int fileIndex)
          Set file operation type of:
HTTPUploadDownload.FILE_OPERATION_TYPE_UNKNOWN
HTTPUploadDownload.FILE_OPERATION_TYPE_TRANSFER
HTTPUploadDownload.FILE_OPERATION_TYPE_OPEN
 boolean setGlobalFileChangePrompt(boolean newValue)
          Set the global no file change warning flag.
 boolean setGlobalOverwriteWarning(boolean newValue)
          Set the global overwrite warning flag.
 boolean setHostURL(String newValue, int i)
          Set the target URL.
private  void setHTTPResponseCode(int code)
           
 void setListener(MultiPartPostListener listener)
           
 boolean setName(String newValue, int i)
          Set the local file post for the upload/download entry.
private  void setOperationFailureCode(int code)
           
private  boolean setOperationStatus(int newValue)
          Set the operation status.
private  void setOperationType(int newValue)
          Set the upload or download operation type.
 boolean setOverwriteWarning(boolean newValue, int fileIndex)
          Set the overwrite warning flag for the individual file.
 boolean setPath(String newValue, int i)
          Set the local file path for the upload/download entry.
 void setSuppressFileLocator(boolean value)
           
 void setUploadImpl(String newValue)
          Set uploadImpl value - valid values are rmi|http|echo
 void setUploadToCacheOnly(boolean newValue)
           
 boolean setUploadURL(String newValue)
          Set the url to be used for the upload.
 boolean setURL(String newValue, int i)
          Set the target URL.
protected  URL stringToURL(String fieldName, URL oldURL, String newValue)
           
 void testDownload()
           
 void testUpload()
           
private  int validateDownloadEntries()
          Return a count of the valid files.
 int validateDownloadOperation()
           
private  boolean validateFileWrite(FileEntry fileEntry, int i)
           
private  int validateUploadEntries()
          Return the count of invalid files.
private  boolean validateUploadEntry(FileEntry fileEntry, int i)
           
 int validateUploadOperation()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UPLOAD_URL

public static final String UPLOAD_URL
UploadURL property name.

See Also:
Constant Field Values

DEFAULT_FILENAME

public static final String DEFAULT_FILENAME
Default file name property name.

See Also:
Constant Field Values

HOST_URL

public static final String HOST_URL
Host URL property name.

See Also:
Constant Field Values

URL

public static final String URL
URL property name.

See Also:
Constant Field Values

NAME

public static final String NAME
File post name property name.

See Also:
Constant Field Values

PATH

public static final String PATH
File path property name.

See Also:
Constant Field Values

OPERATION_TYPE

public static final String OPERATION_TYPE
Operation type indicator.

See Also:
Constant Field Values

GLOBAL_OVERWRITE_WARNING

public static final String GLOBAL_OVERWRITE_WARNING
Global overwrite property name.

See Also:
Constant Field Values

OVERWRITE_WARNING

public static final String OVERWRITE_WARNING
Indicates that an individual file overwrite warning flag has changed.

See Also:
Constant Field Values

GLOBAL_FILE_CHANGE_PROMPT

public static final String GLOBAL_FILE_CHANGE_PROMPT
Global "no file change warning" property name.

See Also:
Constant Field Values

FAILURE_NONE

public static final int FAILURE_NONE
Indicates that no failure has occurred. Returned by operation getFailureCode.

See Also:
Constant Field Values

FAILURE_FILE_NOT_FOUND

public static final int FAILURE_FILE_NOT_FOUND
Indicates that the file does not exist. Returned by operation getFailureCode. Only valid when getOperationStatus returns OPERATION_FAILURE.

See Also:
Constant Field Values

FAILURE_IO_ERROR

public static final int FAILURE_IO_ERROR
Indicates that an io error occurred when accessing the file. Returned by operation getFailureCode. Only valid when getOperationStatus returns OPERATION_FAILURE.

See Also:
Constant Field Values

FAILURE_HTTP_ERROR

public static final int FAILURE_HTTP_ERROR
Indicates that an httpwhile processing the request. Returned by operation getFailureCode. Only valid when getOperationStatus returns OPERATION_FAILURE.

See Also:
Constant Field Values

HTTP_RESPONSE_CODE_NONE

public static final int HTTP_RESPONSE_CODE_NONE
Indicates HTTP response code not set. Returned by operation getHTTPResponseCode.

See Also:
Constant Field Values

OPERATION_TYPE_UNKNOWN

public static final int OPERATION_TYPE_UNKNOWN
Unknown operation indicator.

See Also:
Constant Field Values

OPERATION_TYPE_UPLOAD

public static final int OPERATION_TYPE_UPLOAD
Upload operation indicator.

See Also:
Constant Field Values

OPERATION_TYPE_DOWNLOAD

public static final int OPERATION_TYPE_DOWNLOAD
Download operation indicator.

See Also:
Constant Field Values

OPERATION_INACTIVE

public static final int OPERATION_INACTIVE
Indicate that there is no upload/download operation active.

See Also:
Constant Field Values

OPERATION_REQUEST

public static final int OPERATION_REQUEST
Indicates that the user requested upload/download operation. At this point Uploaddownload begins to process all of its file entries. For each entry HTTPUploadDownload checks to see if the file is valid. If the file is not valid it will launch the file browse function to locate a valid file.

See Also:
Constant Field Values

OPERATION_START

public static final int OPERATION_START
Indicates that the operation has started.

See Also:
Constant Field Values

OPERATION_COMPLETE

public static final int OPERATION_COMPLETE
Indicates that the file upload operation has completed succesfully.

See Also:
Constant Field Values

OPERATION_CANCEL

public static final int OPERATION_CANCEL
Indicates that the file upload was cancelled by the user.

See Also:
Constant Field Values

OPERATION_FAILURE

public static final int OPERATION_FAILURE
Indicates the file upload failed. Check the operation status for more information.

See Also:
Constant Field Values

OPERATION_UNKNOWN_FAILURE

public static final int OPERATION_UNKNOWN_FAILURE
See Also:
Constant Field Values

OPERATION_CANCEL_REQUEST

public static final int OPERATION_CANCEL_REQUEST
Indicates that the application has requested that the current upload or download operation be canceled.

See Also:
Constant Field Values

FILE_OPERATION_TYPE_UNKNOWN

public static final int FILE_OPERATION_TYPE_UNKNOWN
File operation type unknown.

See Also:
Constant Field Values

FILE_OPERATION_TYPE_TRANSFER

public static final int FILE_OPERATION_TYPE_TRANSFER
File operation type for file transfer.

See Also:
Constant Field Values

FILE_OPERATION_TYPE_OPEN

public static final int FILE_OPERATION_TYPE_OPEN
File operation type for application launch.

See Also:
Constant Field Values

FILE_OPERATION_INACTIVE

public static final int FILE_OPERATION_INACTIVE
File operation not active.

See Also:
Constant Field Values

FILE_OPERATION_START

public static final int FILE_OPERATION_START
File entry process start.

See Also:
Constant Field Values

FILE_OPERATION_CANCEL_REQUEST

public static final int FILE_OPERATION_CANCEL_REQUEST
File operation cancelled requested by user.

See Also:
Constant Field Values

FILE_OPERATION_CANCEL

public static final int FILE_OPERATION_CANCEL
File operation cancelled by user.

See Also:
Constant Field Values

FILE_OPERATION_FAILURE

public static final int FILE_OPERATION_FAILURE
See Also:
Constant Field Values

FILE_OPERATION_COMPLETE

public static final int FILE_OPERATION_COMPLETE
See Also:
Constant Field Values

FILE_OPERATION_UNKNOWN_FAILURE

public static final int FILE_OPERATION_UNKNOWN_FAILURE
See Also:
Constant Field Values

VALID_EMPTY_FILE

private static boolean VALID_EMPTY_FILE

uploadImpl

private String uploadImpl

uploadToCacheOnly

private boolean uploadToCacheOnly

uploadListener

private MultiPartPostListener uploadListener

DEBUG

private static boolean DEBUG

fileEntries

private Vector fileEntries

operationStatus

private int operationStatus

operationFailureCode

private int operationFailureCode

httpResponseCode

private int httpResponseCode

operationType

private int operationType

globalOverwriteWarning

private boolean globalOverwriteWarning

globalFileChangePrompt

private boolean globalFileChangePrompt

defaultFilename

private String defaultFilename

uploadURL

private URL uploadURL

suppressFileLocator

private boolean suppressFileLocator

operationThread

private HTTPUploadDownload.HTTPUploadDownloadThread operationThread

multiPartPost

private MultiPartPostIfc multiPartPost

download

private Download download

nextDownloadEntry

private int nextDownloadEntry

uploadDownloadListeners

private Hashtable uploadDownloadListeners

postParameters

private Hashtable postParameters

calculateChecksums

private boolean calculateChecksums
Constructor Detail

HTTPUploadDownload

public HTTPUploadDownload()
Initialize this upload download object, providing an initial url, file path.

Method Detail

setListener

public void setListener(MultiPartPostListener listener)

clear

public boolean clear()
Clear the post parameters and file entries. globalOverwriteWarning and globalFileChangePrompt variables will not be reset. The clear operation is only valid if the operationStatus is OPERATION_INACTIVE, OPERATION_COMPLETE, OPERATION_CANCEL or OPERATION_FAILURE. Any other status indicates that the HTTP operation is active and must be stopped by calling operation cancelOperation.

Returns:
true if the clear was executed, false if the state is not correct for clear.

isOperationActive

public boolean isOperationActive()

getOperationType

public int getOperationType()
Return the type of the current upload or download operation, either UPLOAD or DOWNLOAD.


setOperationType

private void setOperationType(int newValue)
Set the upload or download operation type.

Parameters:
newValue - Either OPERATION_TYPE_UPLOAD or OPERATION_TYPE_DOWNLOAD.

getGlobalOverwriteWarning

public boolean getGlobalOverwriteWarning()
Return the global overwrite warning flag. When this flag is true the download process will warn the user of the pending overwrite of each file. This flag is combined with overwrite flags for each individual file.


setGlobalOverwriteWarning

public boolean setGlobalOverwriteWarning(boolean newValue)
Set the global overwrite warning flag. When this flag is true the download process will warn the user of the pending overwrite of each file. This flag is combined with overwrite flags for each individual file.

Parameters:
newValue - The new global overwrite warning value.

getGlobalFileChangePrompt

public boolean getGlobalFileChangePrompt()
Return the global no file change warning flag. When this flag is true the download process will warn the user when there seems to be no difference between the local file and the server file. This decision is based on the modification date and size of the file.


setGlobalFileChangePrompt

public boolean setGlobalFileChangePrompt(boolean newValue)
Set the global no file change warning flag. When this flag is true the download process will warn the user when there seems to be no difference between the local file and the server file. This decision is based on the modification date and size of the file.

Parameters:
newValue - The new global overwrite warning value.

getHTTPResponseCode

public int getHTTPResponseCode()
Return the HTTP response code returned from the post. Note that this value is valid only when operationStatus is OPERATION_COMPLETE, or OPERATION_FAIL.


setHTTPResponseCode

private void setHTTPResponseCode(int code)

getUploadToCacheOnly

public boolean getUploadToCacheOnly()

setUploadToCacheOnly

public void setUploadToCacheOnly(boolean newValue)

getMaxHTTPUploadDownloadCount

public int getMaxHTTPUploadDownloadCount()
Return the maximum number of files to upload or download. Note that some file entries may not be set and yet are included in the count.


getUploadURL

public String getUploadURL()
Return the url to be used for the upload. Note that the upload process assumes a multi-part post so the uploadURL applies to all file entries.


setUploadURL

public boolean setUploadURL(String newValue)
                     throws MalformedURLException
Set the url to be used for the upload. Note that the upload process assumes a multi-part post so the uploadURL applies to all file entries.

Parameters:
newValue - The new value for the upload url.
Throws:
MalformedURLException

getHostURL

public String getHostURL(int i)
Return the current value of the host URL for the file at the specified index.

Parameters:
i - The index of the file entry.

setHostURL

public boolean setHostURL(String newValue,
                          int i)
                   throws MalformedURLException
Set the target URL. This is the URL which will be used for the upload or download.

Parameters:
newValue - The URL for the upload or download.
i - The index of the file entry.
Throws:
MalformedURLException

getURL

public String getURL(int i)
Return the current value of the content URL for the file at the specified index.

Parameters:
i - The index of the file entry.

setURL

public boolean setURL(String newValue,
                      int i)
               throws MalformedURLException
Set the target URL.

Parameters:
newValue - The URL for the upload or download.
i - The index of the file entry.
Throws:
MalformedURLException

getPath

public String getPath(int i)
Return the local file path for the upload/download entry.

Parameters:
i - The index of the file entry.

setPath

public boolean setPath(String newValue,
                       int i)
Set the local file path for the upload/download entry.

Parameters:
newValue - The local file path for the upload.
i - The index of the file entry.

getName

public String getName(int i)
Return the local file post name for the upload/download entry.

Parameters:
i - The index of the file entry.

setName

public boolean setName(String newValue,
                       int i)
Set the local file post for the upload/download entry.

Parameters:
newValue - The local file post name for the upload.
i - The index of the file entry.

isCancelled

public boolean isCancelled(int fileIndex)

setCancelled

public boolean setCancelled(boolean newValue,
                            int fileIndex)

getFileOperationType

public int getFileOperationType(int fileIndex)
Return file operation type of:
HTTPUploadDownload.FILE_OPERATION_TYPE_UNKNOWN
HTTPUploadDownload.FILE_OPERATION_TYPE_TRANSFER
HTTPUploadDownload.FILE_OPERATION_TYPE_OPEN


setFileOperationType

public boolean setFileOperationType(int fileOperationType,
                                    int fileIndex)
Set file operation type of:
HTTPUploadDownload.FILE_OPERATION_TYPE_UNKNOWN
HTTPUploadDownload.FILE_OPERATION_TYPE_TRANSFER
HTTPUploadDownload.FILE_OPERATION_TYPE_OPEN


getOverwriteWarning

public boolean getOverwriteWarning(int fileIndex)
Return the overwrite warning flag for the individual file. When this flag is true, and the globalOverwriteWarning flag is true then the download process will warn the user of the pending overwrite of each file.

Parameters:
fileIndex - The index of the file.

setOverwriteWarning

public boolean setOverwriteWarning(boolean newValue,
                                   int fileIndex)
Set the overwrite warning flag for the individual file. When this flag is true and the globalOverwriteWarning flag is true, the download process will warn the user of the pending overwrite of each file. The controlling listener should prompt the user and if the user confirms the overwrite the controlling listener should call HTTPUploadDownload.setOverwriteWarning( true, fileIndex ); The overwriteWarning setting will be maintained until operation clear after which each file will be set to overwriteWarning = true.

Parameters:
newValue - The new overwrite warning value for the file.
fileIndex - The index of the file.

getChecksum

public long getChecksum(int fileIndex)
Get the cheksum for the file at fileIndex, which will be -1 if not calculated.


setChecksum

public void setChecksum(long checksum,
                        int fileIndex)

getSuppressFileLocator

public boolean getSuppressFileLocator()

setSuppressFileLocator

public void setSuppressFileLocator(boolean value)

getDefaultFilename

public String getDefaultFilename()
Get the file name default, e.g."c:\\temp\\*.txt".


setDefaultFilename

public boolean setDefaultFilename(String newValue)
Set the file name default, e.g. "*.txt". This value is used when a file browse is requested and the file name is not set.

Parameters:
newValue - The default file name.

addPostParameter

public boolean addPostParameter(String key,
                                String value)
Record a parameter to be supplied with the upload operation. Currently only single valued parameters are supported.

Parameters:
key - The name of the parameter.
value - The value of the parameter.

removePostParameter

public boolean removePostParameter(String key)
Remove the parameter from the upload operation.

Parameters:
key - The parameter key.

addPostParameter

public boolean addPostParameter(String key,
                                String value,
                                int index)
Record a parameter to be supplied with the upload operation for the file at the specified index. Currently only single valued parameters are supported.

Parameters:
key - The name of the parameter.
value - The value of the parameter.
index - The index of the file.

removePostParameter

public boolean removePostParameter(String key,
                                   int index)
Remove the parameter from the upload operation for the file at the specified index.

Parameters:
key - The parameter key.
index - The index of the file.

clearPostParameters

public boolean clearPostParameters()
Remove all post parameters.


getOperationStatus

public int getOperationStatus()
Return operation status. Valid statuses include:
OPERATION_INACTIVE, the upload/download is not performing an operation.
OPERATION_REQUEST, the operation has been requested but has not yet started.
OPERATION_START, the operation has started.
OPERATION_COMPLETE the operation has been completed with HTTP response code 200.
OPERATION_CANCEL, the operation has been canceled at the request of the application.
OPERATION_FAIL, the operation failed. The failure is described by the operationFailureCode. the failure can be either a file error, an io error or an HTTP error.


setOperationStatus

private boolean setOperationStatus(int newValue)
Set the operation status.


getOperationStatusMessage

public String getOperationStatusMessage()
Return the operation status message.


getOperationFailureCode

public int getOperationFailureCode()

setOperationFailureCode

private void setOperationFailureCode(int code)

getOperationStatus

public int getOperationStatus(int i)
Return operation status for file.

Parameters:
i - The index of the file entry.

getOperationStatusMessage

public String getOperationStatusMessage(int i)
Return operation status message for file i.

Parameters:
i - The index of the file entry.

getFileOperationStatus

public int getFileOperationStatus(int index)

setFileOperationStatus

private void setFileOperationStatus(int status,
                                    int index)

validateUploadOperation

public int validateUploadOperation()

validateDownloadOperation

public int validateDownloadOperation()

performUpload

public Thread performUpload(boolean separateThread)
Perform the upload operation.

Parameters:
separateThread - indicates whether upload should be run in a separate thread.
Returns:
Thread the upload thread if separateThread is true, null otherwise.

performDownload

public Thread performDownload(boolean separateThread)
Perform the download.

Parameters:
separateThread - indicates whether upload/download should be run in a separate thread.
Returns:
Thread the download thread if separateThread is true, null otherwise.

cancelOperation

public boolean cancelOperation()
Request operation cancel. Note that this operation just requests the cancel, the actual HTTP operation is running in a separate thread and may not immediately stop. The caller must monitor status changes to determine when the operation stops. The caller must inquire to determine which individual file entries were completed.

Returns:
true if the operation was cancelled.

addHTTPUploadDownloadListener

public void addHTTPUploadDownloadListener(HTTPUploadDownloadListener l)
Add listeners to upload and download events.

See Also:
HTTPUploadDownloadEvent

setUploadImpl

public void setUploadImpl(String newValue)
Set uploadImpl value - valid values are rmi|http|echo


getUploadImpl

public String getUploadImpl()
Retrieve uploadImpl value - valid values are rmi|http|echo

Returns:
uploadImpl

removeHTTPUploadDownloadListener

public void removeHTTPUploadDownloadListener(HTTPUploadDownloadListener l)
Remove upload/download listener.


performUploadOperation

private void performUploadOperation()
Return true if the operation started, false otherwise.


getCacheInfo

public String getCacheInfo()

performDownloadOperation

private void performDownloadOperation()
This method has three phases: validation, download, and open. The validation phase makes sure that the download information is complete and valid. If the information is not complete a callback is performed to determine the information. Once a complete set of information has been obtained the download phase is initiated to move any files from the server to the local path. The last phase involves launching any url's or applications which may be needed to work on the content.


downloadFileTransfer

private boolean downloadFileTransfer(FileEntry nextFileEntry,
                                     int nextEntry)

openContents

private void openContents()
This operation is called following the file download phase to open any url's or files marked for being opened.


openApplication

private void openApplication(String path,
                             int fileEntryIndex)

openURL

private boolean openURL(FileEntry nextFileEntry,
                        int nextEntry)

confirmFileDownload

private boolean confirmFileDownload(int index)

confirmFileUpload

private boolean confirmFileUpload(int index)

propertyChange

private void propertyChange(String propertyName,
                            int propertyIndex,
                            Object newValue)

operationStatusChange

private void operationStatusChange(int status)

operationFinished

private void operationFinished(int status)

confirmFileOverwrite

private boolean confirmFileOverwrite(FileEntry fileEntry,
                                     int index)

fileOperationStatusChange

private void fileOperationStatusChange(int status,
                                       String path,
                                       int count)

locateFile

private void locateFile(String filePath,
                        int fileIndex)

invalidFile

private void invalidFile(String filePath,
                         int fileIndex,
                         String reason)

invalidFile

private void invalidFile(String filePath,
                         int fileIndex,
                         String messageKey,
                         Object[] params)
The file at fileIndex is invalid.

Parameters:
filePath - the local file path.
fileIndex - the index of the file entry.
messageKey - the resource bundle key to the reason message
params - the text inserts for the reason message

fileOperationTypeUnknown

private void fileOperationTypeUnknown(URL url,
                                      String filePath,
                                      int fileIndex)

getMultiPartPost

public MultiPartPostIfc getMultiPartPost()

isCalculateChecksums

public boolean isCalculateChecksums()

setCalculateChecksums

public void setCalculateChecksums(boolean calculateChecksums)

dumpFileEntries

public void dumpFileEntries()

dumpFileEntry

public void dumpFileEntry(int index)

dumpPostParameters

private void dumpPostParameters(Hashtable postParameters)

validateUploadEntries

private int validateUploadEntries()
Return the count of invalid files.


validateUploadEntry

private boolean validateUploadEntry(FileEntry fileEntry,
                                    int i)

validateDownloadEntries

private int validateDownloadEntries()
Return a count of the valid files.


validateFileWrite

private boolean validateFileWrite(FileEntry fileEntry,
                                  int i)

getFileEntryAt

private FileEntry getFileEntryAt(int i)

searchForEntry

int searchForEntry(String key,
                   String value)

clearFileEntries

private void clearFileEntries()

canWrite

private boolean canWrite(String path)

fileExists

private boolean fileExists(File file)

canRead

private boolean canRead(String path)

createFile

private File createFile(String path)

isAbsoluteFilePath

private boolean isAbsoluteFilePath(String path)

isAbsoluteDirectoryPath

private boolean isAbsoluteDirectoryPath(String path)

stringToURL

protected URL stringToURL(String fieldName,
                          URL oldURL,
                          String newValue)
                   throws MalformedURLException
Throws:
MalformedURLException

createURL

public static URL createURL(String urlString)
                     throws MalformedURLException
Throws:
MalformedURLException

looksLikeAbsoluteFilePath

private static boolean looksLikeAbsoluteFilePath(String s)

looksLikeAbsolutePath

private static boolean looksLikeAbsolutePath(String s)

looksLikeAbsoluteDirectoryPath

private static boolean looksLikeAbsoluteDirectoryPath(String s)

testDownload

public void testDownload()

testUpload

public void testUpload()

PP

private static void PP(String message)