wt.clients.util.http
Class HTTPUploadDownloadTask

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

public class HTTPUploadDownloadTask
extends Object

Class HTTPUploadDownloadTask is a generic task class which is a gathering point for tasks associated with uploading or downloading content from content holders.

Supported API: true

Extendable: false


Nested Class Summary
(package private)  class HTTPUploadDownloadTask.DownloadContentThread
           
 
Field Summary
private static String ALWAYS_OPEN
           
private static String ALWAYS_SAVE
           
private  ContentHolder contentHolder
           
private  ThreadGroup contextGroup
           
private static boolean DEBUG
          Flag used to provide debugging messages.
private  FileAccess fileAccess
           
private  Applet parentApplet
           
private  Frame parentFrame
           
private static String RESOURCES
           
private static boolean SHOW_CONTENTS
           
private static boolean STRUCTURE_DOWNLOAD
           
 
Constructor Summary
HTTPUploadDownloadTask(Applet parent_applet, Frame parent_frame, ContentHolder content_holder)
          Construct a HTTPUploadDownloadTask to handle the content of a ContentHolder object.
 
Method Summary
 String createValidDefaultPath(String path)
           
private  void downloadDocumentFile(boolean remember)
          Download the contents in the ContentHolder being checked out by this task.
private  void downloadDocumentFile(boolean remember, DocumentFormData form_data)
          Download the contents in the ContentHolder being checked out by this task.
 void downloadFiles(boolean remember)
          Performs the actual download.
 void downloadFiles(boolean remember, DocumentFormData form_data)
          Performs the actual download.
 String downloadPrimaryFile(FormatContentHolder doc, String upload_from_path)
          Provides a convenience method for downloading the primary content from a document.
 ContentHolder getContentHolder()
          Returns the ContentHolder item.
private  WTContext getContext()
           
private  FileAccess getFileAccess()
           
 Applet getParentApplet()
          Returns the parent Applet which provides context to this task.
 Frame getParentFrame()
          Returns the Frame which is used as the owner of dialogs launched in this task.
 boolean isDirectory(String path)
           
private  HTTPUploadDownload loadUploadAddFiles(HTTPUploadDownload upload, Vector fileVector)
           
private  HTTPUploadDownload loadUploadAddURLs(HTTPUploadDownload upload, Vector urlVector)
           
private  HTTPUploadDownload loadUploadRemoveFiles(HTTPUploadDownload upload, Vector fileVector)
           
private  HTTPUploadDownload loadUploadRemoveURLs(HTTPUploadDownload upload, Vector urlVector)
           
private  HTTPUploadDownload loadUploadReplaceFiles(HTTPUploadDownload upload, Vector fileVector)
           
private  HTTPUploadDownload loadUploadReplaceURLs(HTTPUploadDownload upload, Vector urlVector)
           
 void setContentHolder(ContentHolder content_holder)
          Sets the ContentHolder item.
private  void setContext(boolean set)
           
 void setParentApplet(Applet parent_applet)
          Sets the parent Applet which provides context to this task.
 void setParentFrame(Frame parent_frame)
          Sets the Frame to be used as the owner of dialogs launched in this task.
private  void showMessageDialog(String message, Exception e)
           
 void uploadContentItems(FormatContentHolder document, Hashtable vectorHashtable, Applet applet, Frame frame)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCES

private static String RESOURCES

DEBUG

private static boolean DEBUG
Flag used to provide debugging messages.


SHOW_CONTENTS

private static boolean SHOW_CONTENTS

STRUCTURE_DOWNLOAD

private static boolean STRUCTURE_DOWNLOAD

ALWAYS_OPEN

private static String ALWAYS_OPEN

ALWAYS_SAVE

private static String ALWAYS_SAVE

parentApplet

private Applet parentApplet

parentFrame

private Frame parentFrame

contentHolder

private ContentHolder contentHolder

contextGroup

private ThreadGroup contextGroup

fileAccess

private FileAccess fileAccess
Constructor Detail

HTTPUploadDownloadTask

public HTTPUploadDownloadTask(Applet parent_applet,
                              Frame parent_frame,
                              ContentHolder content_holder)
Construct a HTTPUploadDownloadTask to handle the content of a ContentHolder object.

Parameters:
parent_applet - The parent Applet from which this task gets its context.
parent_frame - The parent Frame which is used to provide a Frame for launching dialogs. If no frame is provided, the applet is used in launching dialogs.
Method Detail

setParentApplet

public void setParentApplet(Applet parent_applet)
Sets the parent Applet which provides context to this task. The parent Applet is used to get the appropriate WTContext object for this task.

Parameters:
parent_applet - the Applet to be used for context
See Also:
getParentApplet(), WTContext

getParentApplet

public Applet getParentApplet()
Returns the parent Applet which provides context to this task. The parent Applet is used to get the appropriate WTContext object for this task.

Returns:
the Applet used for providing context
See Also:
setParentApplet(java.applet.Applet), WTContext

setParentFrame

public void setParentFrame(Frame parent_frame)
Sets the Frame to be used as the owner of dialogs launched in this task. Since a Dialog requires a Frame to be constructed, this task must be given a frame to use.

Parameters:
parent_frame - the Frame used for launching dialogs from this task
See Also:
getParentFrame(), Dialog

getParentFrame

public Frame getParentFrame()
Returns the Frame which is used as the owner of dialogs launched in this task. If the parent frame has not been explicitly set (via setParentFrame), this method will try to retrieve a frame by traversing the parent hierarchy of the parent applet, if the parent applet has been given.

Returns:
the parent Frame used for launching dialogs from this task
See Also:
setParentFrame(java.awt.Frame), setParentApplet(java.applet.Applet)

setContentHolder

public void setContentHolder(ContentHolder content_holder)
                      throws WTException
Sets the ContentHolder item. This method does not verify that the given ContentHolder corresponds to an object that has content.

Parameters:
content_holder - the ContentHolder object to be checked out
Throws:
WTException

getContentHolder

public ContentHolder getContentHolder()
Returns the ContentHolder item.

Returns:
the ContentHolder item
See Also:
setContentHolder(wt.content.ContentHolder)

downloadFiles

public void downloadFiles(boolean remember)
                   throws PropertyVetoException,
                          WTException
Performs the actual download. If the object is a FormatContentHolder then only the primary content will be downloaded and if the remember flag flag is set the location that the ContentItem is downloaded to will be stored in the ContentItem. If the object is not a FormatContentHolder, format operations are allowed on the object, and there are ContentItems a dialog will be presented to allow the user to select those files for download.

Returns:
the ContentHolder object to have the content downloaded.
Throws:
PropertyVetoException
WTException
See Also:
ContentHolder, FormatContentHolder

downloadFiles

public void downloadFiles(boolean remember,
                          DocumentFormData form_data)
                   throws PropertyVetoException,
                          WTException
Performs the actual download. If the object is a FormatContentHolder then only the primary content will be downloaded and if the remember flag flag is set the location that the ContentItem is downloaded to will be stored in the ContentItem. If the object is not a FormatContentHolder, format operations are allowed on the object, and there are ContentItems a dialog will be presented to allow the user to select those files for download.

Returns:
the ContentHolder object to have the content downloaded.
Throws:
PropertyVetoException
WTException
See Also:
ContentHolder, FormatContentHolder

downloadDocumentFile

private void downloadDocumentFile(boolean remember)
                           throws PropertyVetoException,
                                  WTException,
                                  InterruptedException
Download the contents in the ContentHolder being checked out by this task.

Throws:
PropertyVetoException - if an error occurs downloading the content.
WTException - if an error occurs downloading the content.
InterruptedException - if an error occurs downloading the content.

downloadDocumentFile

private void downloadDocumentFile(boolean remember,
                                  DocumentFormData form_data)
                           throws PropertyVetoException,
                                  WTException,
                                  InterruptedException
Download the contents in the ContentHolder being checked out by this task.

Throws:
PropertyVetoException - if an error occurs downloading the content.
WTException - if an error occurs downloading the content.
InterruptedException - if an error occurs downloading the content.

getContext

private WTContext getContext()

setContext

private void setContext(boolean set)

showMessageDialog

private void showMessageDialog(String message,
                               Exception e)

downloadPrimaryFile

public String downloadPrimaryFile(FormatContentHolder doc,
                                  String upload_from_path)
                           throws WTException
Provides a convenience method for downloading the primary content from a document. Will through exceptions for failed downloads. Does not checkout or affect any persistent data in the database so it won't remember that this file was downloaded or that where it was put. Not to be used when a file is downloaded as part of checking out the document object. May be used on other files in a structure that are not being checked out on a check out. Does nothing if content item is of any other type than ApplicationData, such as a URL.

Throws:
WTException

uploadContentItems

public void uploadContentItems(FormatContentHolder document,
                               Hashtable vectorHashtable,
                               Applet applet,
                               Frame frame)
                        throws WTException
Throws:
WTException

loadUploadAddFiles

private HTTPUploadDownload loadUploadAddFiles(HTTPUploadDownload upload,
                                              Vector fileVector)

loadUploadRemoveFiles

private HTTPUploadDownload loadUploadRemoveFiles(HTTPUploadDownload upload,
                                                 Vector fileVector)

loadUploadReplaceFiles

private HTTPUploadDownload loadUploadReplaceFiles(HTTPUploadDownload upload,
                                                  Vector fileVector)

loadUploadAddURLs

private HTTPUploadDownload loadUploadAddURLs(HTTPUploadDownload upload,
                                             Vector urlVector)

loadUploadRemoveURLs

private HTTPUploadDownload loadUploadRemoveURLs(HTTPUploadDownload upload,
                                                Vector urlVector)

loadUploadReplaceURLs

private HTTPUploadDownload loadUploadReplaceURLs(HTTPUploadDownload upload,
                                                 Vector urlVector)

getFileAccess

private FileAccess getFileAccess()

createValidDefaultPath

public String createValidDefaultPath(String path)

isDirectory

public boolean isDirectory(String path)