wt.clients.util.http
Class HTTPUploadDownloadPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Panel
              extended bywt.clients.util.http.HTTPUploadDownloadPanel
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable

public class HTTPUploadDownloadPanel
extends Panel

Panel for uploading and downloading files via HTTP.

Supported API:false

Extendable:false

See Also:
Serialized Form

Nested Class Summary
(package private)  class HTTPUploadDownloadPanel.DocumentHandle
           
(package private)  class HTTPUploadDownloadPanel.TargetInfo
           
(package private)  class HTTPUploadDownloadPanel.UploadDownloadController
           
 
Nested classes inherited from class java.awt.Panel
Panel.AccessibleAWTPanel
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
(package private)  symantec.itools.awt.LabelButton browseButton
           
(package private)  Panel buttonPanel
           
private  ContentItem cachedContentItem
           
(package private)  Choice chooseFileOrURL
           
private  ThreadGroup contextGroup
           
private  ReferenceHolder documentHandle
           
static int DOWNLOAD
          Download mode indicator.
private  boolean embeddedApplet
           
private  FileAccess fileAccess
           
(package private)  TextField fileOrURLTextField
           
(package private)  symantec.itools.awt.LabelButton getButton
           
(package private)  Panel mainPanel
           
private  int mode
           
private  String noPrimaryContentMessage
           
private  Applet parentApplet
           
private  boolean removable
           
(package private)  symantec.itools.awt.LabelButton removeButton
           
private static String RESOURCE
           
static int TARGET_TYPE_FILE
          Target type indicator, indicates a file is the target.
static int TARGET_TYPE_UNKNOWN
          Target type indicator, indicates the type is unknown.
static int TARGET_TYPE_URL
          Target type indicator, indicates a url is the target.
private  boolean uiModeViewOnly
           
static int UPLOAD
          Upload mode indicator
private  HTTPUploadDownload uploadDownload
           
private  HTTPUploadDownloadInfo uploadDownloadInfo
           
private  HTTPUploadDownloadView uploadDownloadView
           
(package private) static boolean VALID_EMPTY_FILE
           
(package private) static boolean VERBOSE
           
 
Fields inherited from class java.awt.Panel
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
HTTPUploadDownloadPanel()
           
 
Method Summary
 void addHTTPUploadDownloadListener(HTTPUploadDownloadListener l)
          Add listeners to upload and download events.
private  boolean addNewFile(int uploadIndex, boolean sameTargetType, boolean isFile, HTTPUploadDownloadPanel.TargetInfo info, String targetName)
           
 boolean addPostParameter(String key, String value)
          Record a parameter to be supplied with the upload operation for the file.
 void browse()
          Invoke the file browse function and allow user to select a path.
 boolean cancelOperation()
           
 boolean checksumsMatch()
           
private  boolean checksumsMatch(String localPath, long checksum)
           
private  String chooseFile()
           
 void clear()
           
static String createFileURLString(String fileString)
           
private  String display(String key, Object[] params)
          Returns the localized string to be displayed to the user given a key.
private  void displayException(Exception e)
          This displays an exception to the user and prints out a stack trace.
private  void displayNoPrimaryMessage()
           
 String getContentName()
          Retrieve the name which will be used on the HTTP upload CONTENT-DISPOSITION.
private  WTContext getContext()
           
 boolean getDebugOption()
           
 String getDefaultFilename()
          Return the default file name.
 FormatContentHolder getDocument()
          Returns the FormatContentHolder created by this frame.
 ReferenceHolder getDocumentHandle()
          Get the oid of the content holder for this panel.
private  HTTPUploadDownloadPanel.TargetInfo getExistingTargetInfo(ContentItem item)
           
private  FileAccess getFileAccess()
           
 boolean getGlobalFileChangePrompt()
           
 boolean getGlobalOverwriteWarning()
           
 String getHostURL()
          Return the host url.
 int getHTTPResponseCode()
           
 Dimension getMaximumSize()
           
 Dimension getMininumSize()
           
 int getMode()
          Return the file upload download mode.
private  String getNoPrimaryContentMessage()
           
 int getOperationFailureCode()
           
 int getOperationStatus()
          Return the most recent status.
 String getOperationStatusMessage()
          Return a user readable status message.
 Applet getParentApplet()
          Return the launching applet (if any).
protected  Frame getParentFrame()
          Return the parent frame.
 Dimension getPreferredSize()
           
private  ContentItem getPrimaryContentItem()
           
 String getTarget()
          Return the target file or url.
 int getTargetType()
           
 boolean getUIModeViewOnly()
           
 HTTPUploadDownload getUploadDownload()
           
 String getUploadURL()
          Return the upload url.
 void init(Applet parentApplet)
          Initialize this panel.
 void init(Applet parentApplet, HTTPUploadDownload newUploadDownload, HTTPUploadDownloadView view, int targetType)
          Initialize this panel to use the passed HTTPUploadDownload) object.
 boolean isDebug()
           
 boolean isDirty()
          Should be invoked before a call to save; this is where checksumming and initial file validation occurs.
 boolean isEmbeddedApplet()
           
 boolean isGetButtonVisible()
           
 boolean isRemovable()
           
 boolean isValidTarget()
           
 boolean isValidTarget(String target)
           
 void launchDebugDialog()
           
private  void localize()
          This sets the display text of the fields to the localized string from the resource bundle.
 void performDownloadOperation(boolean separateThread)
           
private  void performGet()
           
 void performOperation()
          Perform the upload or download operation indicated by the mode property.
 void performOperation(boolean separateThread)
          Perform the upload or download operation indicated by the mode property.
 void performUploadOperation(boolean separateThread)
           
protected  void performUploadOperation(boolean separateThread, boolean needsSynch)
           
private  void reactFieldGainedFocus(TextField tf)
           
private  void reactFieldLostFocus(TextField tf)
           
private  boolean removeCurrentFile(int uploadIndex, boolean isFile, HTTPUploadDownloadPanel.TargetInfo info)
           
 void removeHTTPUploadDownloadListener(HTTPUploadDownloadListener l)
          Remove upload/download listener.
 boolean removePostParameter(String key)
          Remove the parameter from the upload operation for the file at the specified index.
 void resetPrimaryContent()
           
 boolean save()
           
 boolean save(boolean check)
          Save the target content.
private  boolean savePrimaryContentItem(ContentItem primary)
           
 void setChooseFileOrURLVisible(boolean visible)
          Set the chooseFileOrURL choice menu to visible or not visible based on the boolean parameter.
 boolean setContentName(String name)
          Set the name which will be used on the HTTP upload CONTENT-DISPOSITION
 void setDebug(boolean newValue)
           
 void setDebugOption(boolean debugOption)
           
 void setDefaultFilename(String defaultName)
          Set the default file name.
 void setDisplayDeleteCheckbox()
           
 void setDisplayDeleteNotDisplay()
           
 void setDisplayUploadCheckbox()
           
 void setDisplayUploadNotDisplay()
           
private  void setDocument(FormatContentHolder newDocument)
           
 void setDocumentHandle(ReferenceHolder referenceHolder)
           
 void setEmbeddedApplet(boolean embeddedApplet)
           
 void setGetButtonVisible(boolean visible)
           
 void setGlobalFileChangePrompt(boolean newValue)
           
 void setGlobalOverwriteWarning(boolean newValue)
           
 boolean setHostURL(String url)
          Set the host url.
 void setMode(int newMode)
          Set the file upload or download mode.
 void setParentApplet(Applet parentApplet)
           
 void setRemovable(boolean a_removable)
           
 boolean setTarget(String target)
          Set the target file or url.
 void setTargetType(int targetType)
           
 void setUIModeViewOnly(boolean newValue)
           
 boolean setUploadURL(String urlString)
          Set the upload url.
protected  void showMessageDialog(String message, boolean modal)
           
private  void synch(int updateMode)
           
private  void synch(int updateMode, int index)
           
private  void targetTypeChanged()
           
private  void update(int updateMode)
           
private  void update(int updateMode, int targetType, int index)
           
private  void updateDocumentInformation(boolean reset)
           
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMinimumSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RESOURCE

private static String RESOURCE

VERBOSE

static boolean VERBOSE

VALID_EMPTY_FILE

static boolean VALID_EMPTY_FILE

UPLOAD

public static final int UPLOAD
Upload mode indicator

See Also:
Constant Field Values

DOWNLOAD

public static final int DOWNLOAD
Download mode indicator.

See Also:
Constant Field Values

TARGET_TYPE_UNKNOWN

public static final int TARGET_TYPE_UNKNOWN
Target type indicator, indicates the type is unknown.

See Also:
Constant Field Values

TARGET_TYPE_FILE

public static final int TARGET_TYPE_FILE
Target type indicator, indicates a file is the target.

See Also:
Constant Field Values

TARGET_TYPE_URL

public static final int TARGET_TYPE_URL
Target type indicator, indicates a url is the target.

See Also:
Constant Field Values

mainPanel

Panel mainPanel

buttonPanel

Panel buttonPanel

chooseFileOrURL

Choice chooseFileOrURL

fileOrURLTextField

TextField fileOrURLTextField

browseButton

symantec.itools.awt.LabelButton browseButton

removeButton

symantec.itools.awt.LabelButton removeButton

getButton

symantec.itools.awt.LabelButton getButton

uploadDownload

private HTTPUploadDownload uploadDownload

uploadDownloadView

private HTTPUploadDownloadView uploadDownloadView

uploadDownloadInfo

private HTTPUploadDownloadInfo uploadDownloadInfo

parentApplet

private Applet parentApplet

documentHandle

private ReferenceHolder documentHandle

contextGroup

private ThreadGroup contextGroup

fileAccess

private FileAccess fileAccess

noPrimaryContentMessage

private String noPrimaryContentMessage

uiModeViewOnly

private boolean uiModeViewOnly

removable

private boolean removable

embeddedApplet

private boolean embeddedApplet

mode

private int mode

cachedContentItem

private ContentItem cachedContentItem
Constructor Detail

HTTPUploadDownloadPanel

public HTTPUploadDownloadPanel()
Method Detail

init

public void init(Applet parentApplet)
Initialize this panel. This operation (or init(HTTPUploadDownload)) must be called once this panel has been added to its parent container. This operation automatically creates an HTTPUploadDownload object. To supply your own HTTPUploadDownload object call operation init(HTTPUploadDownload).


init

public void init(Applet parentApplet,
                 HTTPUploadDownload newUploadDownload,
                 HTTPUploadDownloadView view,
                 int targetType)
Initialize this panel to use the passed HTTPUploadDownload) object. This operation (or init()) must be called once this panel has been added to its parent container.


getMininumSize

public Dimension getMininumSize()

getMaximumSize

public Dimension getMaximumSize()

getPreferredSize

public Dimension getPreferredSize()

getDocumentHandle

public ReferenceHolder getDocumentHandle()
Get the oid of the content holder for this panel.


setDocumentHandle

public void setDocumentHandle(ReferenceHolder referenceHolder)

getUploadDownload

public HTTPUploadDownload getUploadDownload()

getUploadURL

public String getUploadURL()
Return the upload url.


setUploadURL

public boolean setUploadURL(String urlString)
Set the upload url.


getHostURL

public String getHostURL()
Return the host url.


setHostURL

public boolean setHostURL(String url)
Set the host url.

Parameters:
url - The host url.
Returns:
true if valid url, false otherwise.

getTarget

public String getTarget()
Return the target file or url.


setTarget

public boolean setTarget(String target)
Set the target file or url.

Parameters:
target - The file path, e.g. "E:\abcd\test.txt" or "E:\abcd\*.txt" or url.

getContentName

public String getContentName()
Retrieve the name which will be used on the HTTP upload CONTENT-DISPOSITION.


setContentName

public boolean setContentName(String name)
Set the name which will be used on the HTTP upload CONTENT-DISPOSITION


getUIModeViewOnly

public boolean getUIModeViewOnly()

setUIModeViewOnly

public void setUIModeViewOnly(boolean newValue)

getMode

public int getMode()
Return the file upload download mode.


setMode

public void setMode(int newMode)
Set the file upload or download mode.

Parameters:
newMode - HTTPUploadDownload.DOWNLOAD or HTTPUploadDownload.UPLOAD.

getTargetType

public int getTargetType()

setTargetType

public void setTargetType(int targetType)

setRemovable

public void setRemovable(boolean a_removable)

isRemovable

public boolean isRemovable()

setGetButtonVisible

public void setGetButtonVisible(boolean visible)

isGetButtonVisible

public boolean isGetButtonVisible()

isValidTarget

public boolean isValidTarget()

isValidTarget

public boolean isValidTarget(String target)

isEmbeddedApplet

public boolean isEmbeddedApplet()

setEmbeddedApplet

public void setEmbeddedApplet(boolean embeddedApplet)

addPostParameter

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

Parameters:
key - The name of the parameter.
value - The value of the parameter.
Returns:
true if the operation was performed, false if the operation was not allowed.

removePostParameter

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

Parameters:
key - The parameter key.
Returns:
true if the operation was performed, false if the operation was not allowed.

getDefaultFilename

public String getDefaultFilename()
Return the default file name.


setDefaultFilename

public void setDefaultFilename(String defaultName)
Set the default file name. This value is used to initialize the browse dialog when no file name is supplied.


getGlobalOverwriteWarning

public boolean getGlobalOverwriteWarning()

setGlobalOverwriteWarning

public void setGlobalOverwriteWarning(boolean newValue)

getGlobalFileChangePrompt

public boolean getGlobalFileChangePrompt()

setGlobalFileChangePrompt

public void setGlobalFileChangePrompt(boolean newValue)

getParentApplet

public Applet getParentApplet()
Return the launching applet (if any).


setParentApplet

public void setParentApplet(Applet parentApplet)

performOperation

public void performOperation()
Perform the upload or download operation indicated by the mode property.

Returns:
true if the operation was started, false otherwise.

performOperation

public void performOperation(boolean separateThread)
Perform the upload or download operation indicated by the mode property.

Parameters:
separateThread - launch a separate thhread when true.
Returns:
true if the operation was started, false otherwise.

cancelOperation

public boolean cancelOperation()

performUploadOperation

public void performUploadOperation(boolean separateThread)

performUploadOperation

protected void performUploadOperation(boolean separateThread,
                                      boolean needsSynch)

performDownloadOperation

public void performDownloadOperation(boolean separateThread)

save

public boolean save()

save

public boolean save(boolean check)
Save the target content. Note that this operation will not check to see if the panel "is dirty". If This operation should occur only when the content has changed the caller should first check by calling operation isDirty().


getDocument

public FormatContentHolder getDocument()
Returns the FormatContentHolder created by this frame.

See Also:
FormatContentHolder

getOperationStatus

public int getOperationStatus()
Return the most recent status.


getOperationStatusMessage

public String getOperationStatusMessage()
Return a user readable status message.


getOperationFailureCode

public int getOperationFailureCode()

getHTTPResponseCode

public int getHTTPResponseCode()

clear

public void clear()

addHTTPUploadDownloadListener

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

See Also:
UploadDownloadEvent

removeHTTPUploadDownloadListener

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


setChooseFileOrURLVisible

public void setChooseFileOrURLVisible(boolean visible)
Set the chooseFileOrURL choice menu to visible or not visible based on the boolean parameter. Visible is the default. Note: before setting it to "not visible", make sure that its value has been set to the value you desire, by calling either setTargetType(TARGET_TYPE_FILE) or setTargetType(TARGET_TYPE_URL).


checksumsMatch

public boolean checksumsMatch()

isDirty

public boolean isDirty()
Should be invoked before a call to save; this is where checksumming and initial file validation occurs.


browse

public void browse()
Invoke the file browse function and allow user to select a path.

Returns:
true if the url is valid, false otherwise.

resetPrimaryContent

public void resetPrimaryContent()

setDocument

private void setDocument(FormatContentHolder newDocument)

getPrimaryContentItem

private ContentItem getPrimaryContentItem()

savePrimaryContentItem

private boolean savePrimaryContentItem(ContentItem primary)

removeCurrentFile

private boolean removeCurrentFile(int uploadIndex,
                                  boolean isFile,
                                  HTTPUploadDownloadPanel.TargetInfo info)

addNewFile

private boolean addNewFile(int uploadIndex,
                           boolean sameTargetType,
                           boolean isFile,
                           HTTPUploadDownloadPanel.TargetInfo info,
                           String targetName)

chooseFile

private String chooseFile()

checksumsMatch

private boolean checksumsMatch(String localPath,
                               long checksum)

getExistingTargetInfo

private HTTPUploadDownloadPanel.TargetInfo getExistingTargetInfo(ContentItem item)

updateDocumentInformation

private void updateDocumentInformation(boolean reset)

getFileAccess

private FileAccess getFileAccess()

getParentFrame

protected Frame getParentFrame()
Return the parent frame.


update

private void update(int updateMode)

update

private void update(int updateMode,
                    int targetType,
                    int index)

performGet

private void performGet()

synch

private void synch(int updateMode)

synch

private void synch(int updateMode,
                   int index)

displayNoPrimaryMessage

private void displayNoPrimaryMessage()

targetTypeChanged

private void targetTypeChanged()

localize

private void localize()
This sets the display text of the fields to the localized string from the resource bundle.


getNoPrimaryContentMessage

private String getNoPrimaryContentMessage()

getContext

private WTContext getContext()

display

private String display(String key,
                       Object[] params)
Returns the localized string to be displayed to the user given a key.

Parameters:
key - The string that represents the key in the BeansRB.
Returns:
A string to be displayed to the user.

displayException

private void displayException(Exception e)
This displays an exception to the user and prints out a stack trace.


showMessageDialog

protected void showMessageDialog(String message,
                                 boolean modal)

createFileURLString

public static String createFileURLString(String fileString)

reactFieldGainedFocus

private void reactFieldGainedFocus(TextField tf)

reactFieldLostFocus

private void reactFieldLostFocus(TextField tf)

setDisplayDeleteNotDisplay

public void setDisplayDeleteNotDisplay()

setDisplayDeleteCheckbox

public void setDisplayDeleteCheckbox()

setDisplayUploadCheckbox

public void setDisplayUploadCheckbox()

setDisplayUploadNotDisplay

public void setDisplayUploadNotDisplay()

getDebugOption

public boolean getDebugOption()

setDebugOption

public void setDebugOption(boolean debugOption)

isDebug

public boolean isDebug()

setDebug

public void setDebug(boolean newValue)

launchDebugDialog

public void launchDebugDialog()