|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.clients.util.http.HTTPUploadDownload
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 |
public static final String UPLOAD_URL
public static final String DEFAULT_FILENAME
public static final String HOST_URL
public static final String URL
public static final String NAME
public static final String PATH
public static final String OPERATION_TYPE
public static final String GLOBAL_OVERWRITE_WARNING
public static final String OVERWRITE_WARNING
public static final String GLOBAL_FILE_CHANGE_PROMPT
public static final int FAILURE_NONE
getFailureCode
.
public static final int FAILURE_FILE_NOT_FOUND
getFailureCode
. Only valid when getOperationStatus
returns OPERATION_FAILURE.
public static final int FAILURE_IO_ERROR
getFailureCode
. Only valid when getOperationStatus
returns OPERATION_FAILURE.
public static final int FAILURE_HTTP_ERROR
getFailureCode
. Only valid when getOperationStatus
returns OPERATION_FAILURE.
public static final int HTTP_RESPONSE_CODE_NONE
getHTTPResponseCode
.
public static final int OPERATION_TYPE_UNKNOWN
public static final int OPERATION_TYPE_UPLOAD
public static final int OPERATION_TYPE_DOWNLOAD
public static final int OPERATION_INACTIVE
public static final int OPERATION_REQUEST
public static final int OPERATION_START
public static final int OPERATION_COMPLETE
public static final int OPERATION_CANCEL
public static final int OPERATION_FAILURE
public static final int OPERATION_UNKNOWN_FAILURE
public static final int OPERATION_CANCEL_REQUEST
public static final int FILE_OPERATION_TYPE_UNKNOWN
public static final int FILE_OPERATION_TYPE_TRANSFER
public static final int FILE_OPERATION_TYPE_OPEN
public static final int FILE_OPERATION_INACTIVE
public static final int FILE_OPERATION_START
public static final int FILE_OPERATION_CANCEL_REQUEST
public static final int FILE_OPERATION_CANCEL
public static final int FILE_OPERATION_FAILURE
public static final int FILE_OPERATION_COMPLETE
public static final int FILE_OPERATION_UNKNOWN_FAILURE
private static boolean VALID_EMPTY_FILE
private String uploadImpl
private boolean uploadToCacheOnly
private MultiPartPostListener uploadListener
private static boolean DEBUG
private Vector fileEntries
private int operationStatus
private int operationFailureCode
private int httpResponseCode
private int operationType
private boolean globalOverwriteWarning
private boolean globalFileChangePrompt
private String defaultFilename
private URL uploadURL
private boolean suppressFileLocator
private HTTPUploadDownload.HTTPUploadDownloadThread operationThread
private MultiPartPostIfc multiPartPost
private Download download
private int nextDownloadEntry
private Hashtable uploadDownloadListeners
private Hashtable postParameters
private boolean calculateChecksums
Constructor Detail |
public HTTPUploadDownload()
Method Detail |
public void setListener(MultiPartPostListener listener)
public boolean clear()
cancelOperation
.
public boolean isOperationActive()
public int getOperationType()
private void setOperationType(int newValue)
newValue
- Either OPERATION_TYPE_UPLOAD or OPERATION_TYPE_DOWNLOAD.public boolean getGlobalOverwriteWarning()
public boolean setGlobalOverwriteWarning(boolean newValue)
newValue
- The new global overwrite warning value.public boolean getGlobalFileChangePrompt()
public boolean setGlobalFileChangePrompt(boolean newValue)
newValue
- The new global overwrite warning value.public int getHTTPResponseCode()
private void setHTTPResponseCode(int code)
public boolean getUploadToCacheOnly()
public void setUploadToCacheOnly(boolean newValue)
public int getMaxHTTPUploadDownloadCount()
public String getUploadURL()
public boolean setUploadURL(String newValue) throws MalformedURLException
newValue
- The new value for the upload url.
MalformedURLException
public String getHostURL(int i)
i
- The index of the file entry.public boolean setHostURL(String newValue, int i) throws MalformedURLException
newValue
- The URL for the upload or download.i
- The index of the file entry.
MalformedURLException
public String getURL(int i)
i
- The index of the file entry.public boolean setURL(String newValue, int i) throws MalformedURLException
newValue
- The URL for the upload or download.i
- The index of the file entry.
MalformedURLException
public String getPath(int i)
i
- The index of the file entry.public boolean setPath(String newValue, int i)
newValue
- The local file path for the upload.i
- The index of the file entry.public String getName(int i)
i
- The index of the file entry.public boolean setName(String newValue, int i)
newValue
- The local file post name for the upload.i
- The index of the file entry.public boolean isCancelled(int fileIndex)
public boolean setCancelled(boolean newValue, int fileIndex)
public int getFileOperationType(int fileIndex)
public boolean setFileOperationType(int fileOperationType, int fileIndex)
public boolean getOverwriteWarning(int fileIndex)
fileIndex
- The index of the file.public boolean setOverwriteWarning(boolean newValue, int fileIndex)
newValue
- The new overwrite warning value for the file.fileIndex
- The index of the file.public long getChecksum(int fileIndex)
public void setChecksum(long checksum, int fileIndex)
public boolean getSuppressFileLocator()
public void setSuppressFileLocator(boolean value)
public String getDefaultFilename()
public boolean setDefaultFilename(String newValue)
newValue
- The default file name.public boolean addPostParameter(String key, String value)
key
- The name of the parameter.value
- The value of the parameter.public boolean removePostParameter(String key)
key
- The parameter key.public boolean addPostParameter(String key, String value, int index)
key
- The name of the parameter.value
- The value of the parameter.index
- The index of the file.public boolean removePostParameter(String key, int index)
key
- The parameter key.index
- The index of the file.public boolean clearPostParameters()
public int getOperationStatus()
private boolean setOperationStatus(int newValue)
public String getOperationStatusMessage()
public int getOperationFailureCode()
private void setOperationFailureCode(int code)
public int getOperationStatus(int i)
i
- The index of the file entry.public String getOperationStatusMessage(int i)
i
- The index of the file entry.public int getFileOperationStatus(int index)
private void setFileOperationStatus(int status, int index)
public int validateUploadOperation()
public int validateDownloadOperation()
public Thread performUpload(boolean separateThread)
separateThread
- indicates whether upload should be run in a separate thread.
public Thread performDownload(boolean separateThread)
separateThread
- indicates whether upload/download should be run in a separate thread.
public boolean cancelOperation()
public void addHTTPUploadDownloadListener(HTTPUploadDownloadListener l)
HTTPUploadDownloadEvent
public void setUploadImpl(String newValue)
public String getUploadImpl()
public void removeHTTPUploadDownloadListener(HTTPUploadDownloadListener l)
private void performUploadOperation()
public String getCacheInfo()
private void performDownloadOperation()
private boolean downloadFileTransfer(FileEntry nextFileEntry, int nextEntry)
private void openContents()
private void openApplication(String path, int fileEntryIndex)
private boolean openURL(FileEntry nextFileEntry, int nextEntry)
private boolean confirmFileDownload(int index)
private boolean confirmFileUpload(int index)
private void propertyChange(String propertyName, int propertyIndex, Object newValue)
private void operationStatusChange(int status)
private void operationFinished(int status)
private boolean confirmFileOverwrite(FileEntry fileEntry, int index)
private void fileOperationStatusChange(int status, String path, int count)
private void locateFile(String filePath, int fileIndex)
private void invalidFile(String filePath, int fileIndex, String reason)
private void invalidFile(String filePath, int fileIndex, String messageKey, Object[] params)
filePath
- the local file path.fileIndex
- the index of the file entry.messageKey
- the resource bundle key to the reason messageparams
- the text inserts for the reason messageprivate void fileOperationTypeUnknown(URL url, String filePath, int fileIndex)
public MultiPartPostIfc getMultiPartPost()
public boolean isCalculateChecksums()
public void setCalculateChecksums(boolean calculateChecksums)
public void dumpFileEntries()
public void dumpFileEntry(int index)
private void dumpPostParameters(Hashtable postParameters)
private int validateUploadEntries()
private boolean validateUploadEntry(FileEntry fileEntry, int i)
private int validateDownloadEntries()
private boolean validateFileWrite(FileEntry fileEntry, int i)
private FileEntry getFileEntryAt(int i)
int searchForEntry(String key, String value)
private void clearFileEntries()
private boolean canWrite(String path)
private boolean fileExists(File file)
private boolean canRead(String path)
private File createFile(String path)
private boolean isAbsoluteFilePath(String path)
private boolean isAbsoluteDirectoryPath(String path)
protected URL stringToURL(String fieldName, URL oldURL, String newValue) throws MalformedURLException
MalformedURLException
public static URL createURL(String urlString) throws MalformedURLException
MalformedURLException
private static boolean looksLikeAbsoluteFilePath(String s)
private static boolean looksLikeAbsolutePath(String s)
private static boolean looksLikeAbsoluteDirectoryPath(String s)
public void testDownload()
public void testUpload()
private static void PP(String message)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |