wt.clients.util.http
Class UploadApplet

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Panel
              extended byjava.applet.Applet
                  extended bywt.clients.util.http.UploadApplet
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
RemoteWorkerUploadApplet

public class UploadApplet
extends Applet

Applet for uploading and downloading files via HTTP. May be used for either single or multiple upload destinations. If multiple, concatenated target files will be uploaded to their corresponding concatenated uploadURLs, but all secondary content attachments will be uploaded to the first of the uploadURLs.
This applet accepts several initialization parameters.

 <param	name="target"          value="e:\abcd\efgh\file.txt"> (for multiple destinations, may concatenate with contentDelim value)
<param name="debug" value="TRUE" or "FALSE"> default is "FALSE"
<param name="bgcolor" value="########"> decimal integer value of the desired background color, default is 14934992
This is a decimal integer giving the red, green, and blue components
where the red component is in bits 16-23 of the argument,
the green component is in bits 8-15 of the argument,
and the blue component is in bits 0-7.
The value zero indicates no contribution from the primary color component.
Example: for the hex RGB color #E3E3CF, the bgcolor value would be "14934992". For #0000FF, bgcolor="255".
<param name="wt.context.locale" value="XX"> locale tag for current browser language
<param name="workspacePath" value="drive\directory\filename"> user preference workspacePath value, if set
<param name="validEmptyFile" value="TRUE" or "FALSE"> default is "FALSE"
<param name="callingAction" value="create" or "updateReplace">
<param name="uploadURL" value=URL to upload files to (for multiple destinations, may concatenate with contentDelim value)
<param name="attachments" value=concatenated attachments transactions in the form of FILE + "newfile"|oid + DELIM + filepath + DELIM + "ADD"|"REMOVE", with RECORD_DELIM between the transactions
<param name="contentDelim" DELIM used in attachments and uploadURL strings, defaults to ";;;qqq">
<param name="contentRecordDelim" RECORD_DELIM used in attachments string, defaults to ";;;zzz">
<param name="completionUrl" value=URL to go to after successful completion of upload>
<param name="failureUrl" value=URL to go to if primary target is invalid or upload fails>
<param name="jsFeedbackMethod" value=method name of JavaScript method that displays invalid filepaths - must accept two arguments, the paths and the URL to go to next, i.e. function displayFeedback( invalidPaths, nextUrl ), defaults to "displayInvalidPaths">
<param name="multipleQuantity" value=if uploading multiple target files to multiple uploadURLs, how many are there? (multiple primaries assumes primary files only, not primary URLs)
<param name="targetType" value="FILE" or "URL" or "NONE" for non-multiple situation, defaults to "FILE"
<param name="uploadImpl" value="rmi" or "http", defaults to "rmi"


The following parameters are only relevant when callingAction=updateReplace: <param name="continueIfFileNotFound" value="true" or "false"> user preference - whether to automatically continue the operation if filepath is invalid
<param name="continueIfFileUnchanged" value="true" or "false"> user preference - whether to automatically continue the operation if local file is identical to Windchill file
<param name="uploadIfFileChanged" value="true" or "false"> user preference - whether to automatically upload if the local file is different than the Windchill file
<param name="checksum" value=persisted checksum of current persisted primary content>
<param name="persistedFilename" value=persisted filename (no path) of current persisted primary content
<param name="oidString" value=OID of current persisted primary content ApplicationData object>
Note: oidString must be in the format of "wt.content.ApplicationData:1437923". Attempting to use an OID with a leading "OR:", such as "OR:wt.content.ApplicationData:1437923", will likely result in server-side failure to persist the uploaded object.


Supported API:true

Extendable:false

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.applet.Applet
Applet.AccessibleApplet
 
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
protected static String CALLING_ACTION
           
protected  String callingAction
           
protected static int CANCEL
           
protected static String CONTENT_DELIM
           
protected static String CONTENT_RECORD_DELIM
           
private static String CONTENT_RESOURCES
           
protected  String contentDelim
           
protected  String contentRecordDelim
           
private  ThreadGroup contextGroup
           
protected static String CONTINUE_IF_FILE_NOT_FOUND
           
protected static String CONTINUE_IF_FILE_UNCHANGED
           
protected  boolean continueIfFileNotFound
           
protected  boolean continueIfFileUnchanged
           
static String CREATE_ACTION
           
protected  boolean DEBUG
           
static String DEBUG_STRING
           
protected static int DECLINED_UPLOAD
           
protected  String defaultFilename
           
protected static int DO_UPLOAD
           
protected  String docOperation
           
private static String DOCUMENTOID
           
protected  long existingChecksum
           
protected static int FAILURE
           
protected static int FILE_NOT_FOUND
           
protected static int FILE_UNCHANGED
           
private  FileAccess fileAccess
           
protected  String formName
           
protected  String hostName
           
private static Object initSync
           
protected  String invalidPathsDisplay
           
protected  String jsFeedbackMethod
           
protected  long localChecksum
           
protected  int multipleQuantity
           
protected static int NO_UPLOAD
           
protected  String persistedFilename
           
protected  boolean removable
           
private static String RESOURCE
           
protected static String SECONDARY_CONTENT
           
protected  String secondaryContent
           
protected  String sessionID
           
protected static int SUCCESS
           
protected static String TARGET_TYPE
           
static int TARGET_TYPE_FILE
           
static int TARGET_TYPE_NONE
           
static int TARGET_TYPE_URL
           
protected  int targetType
           
protected static int UNKNOWN
           
static String UPDATE_ACTION
           
protected static String UPLOAD_IF_FILE_CHANGED
           
static String UPLOAD_IMPL
           
protected static String UPLOAD_URL
           
private  HTTPUploadDownload uploadDownload
           
private  HTTPUploadDownloadView uploadDownloadView
           
protected  boolean uploadIfFileChanged
           
protected  String uploadImpl
           
protected  String uploadPath
           
protected  int uploadStatus
           
protected  boolean uploadToCacheOnly
           
protected  String uploadURL
           
protected static String VALID_EMPTY_FILE
           
protected  boolean validEmptyFile
           
protected static String WORKSPACE_PATH
           
protected  String workspacePath
           
 
Fields inherited from class java.applet.Applet
 
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
UploadApplet()
           
 
Method Summary
 String browseForFile(String path)
          Browse local file system.
private  boolean checksumsMatch()
           
private  boolean confirm(String displayMessage)
           
 String createValidDefaultPath(String path)
           
 void destroy()
           
private  String escape(String source)
           
private  WTContext getContext()
           
private  FileAccess getFileAccess()
           
 String getParameter(String paramName, String defaultParamValue)
           
 Applet getParentApplet()
           
 Frame getParentFrame()
           
private  URL getUrl()
           
 void init()
           
 boolean isDirectory(String path)
           
 boolean isValidTarget(String target)
           
private  String[] parseIntoArray(String parseFrom, String delimiter, int arraySize)
           
protected  boolean saveContent()
           
protected  boolean saveContent(boolean primaryUpload)
           
 String sendKeyValueToServer(String key, String value)
           
 void start()
           
 void stop()
           
protected  void stripInvalidAttachments()
           
 void updateContent()
           
 void updateMultiple()
           
protected  void validateAttachments()
           
protected  void validateFiles()
           
protected  void validateTarget()
           
 
Methods inherited from class java.applet.Applet
getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
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, getMaximumSize, getMinimumSize, getPreferredSize, 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, 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, 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

DOCUMENTOID

private static final String DOCUMENTOID
See Also:
Constant Field Values

UNKNOWN

protected static final int UNKNOWN
See Also:
Constant Field Values

NO_UPLOAD

protected static final int NO_UPLOAD
See Also:
Constant Field Values

DO_UPLOAD

protected static final int DO_UPLOAD
See Also:
Constant Field Values

CANCEL

protected static final int CANCEL
See Also:
Constant Field Values

SUCCESS

protected static final int SUCCESS
See Also:
Constant Field Values

FAILURE

protected static final int FAILURE
See Also:
Constant Field Values

FILE_NOT_FOUND

protected static final int FILE_NOT_FOUND
See Also:
Constant Field Values

FILE_UNCHANGED

protected static final int FILE_UNCHANGED
See Also:
Constant Field Values

DECLINED_UPLOAD

protected static final int DECLINED_UPLOAD
See Also:
Constant Field Values

TARGET_TYPE_FILE

public static final int TARGET_TYPE_FILE
See Also:
Constant Field Values

TARGET_TYPE_URL

public static final int TARGET_TYPE_URL
See Also:
Constant Field Values

TARGET_TYPE_NONE

public static final int TARGET_TYPE_NONE
See Also:
Constant Field Values

CREATE_ACTION

public static final String CREATE_ACTION
See Also:
Constant Field Values

UPDATE_ACTION

public static final String UPDATE_ACTION
See Also:
Constant Field Values

DEBUG_STRING

public static final String DEBUG_STRING
See Also:
Constant Field Values

UPLOAD_IMPL

public static final String UPLOAD_IMPL
See Also:
Constant Field Values

initSync

private static Object initSync

CONTENT_RESOURCES

private static String CONTENT_RESOURCES

RESOURCE

private static String RESOURCE

CONTINUE_IF_FILE_NOT_FOUND

protected static String CONTINUE_IF_FILE_NOT_FOUND

CONTINUE_IF_FILE_UNCHANGED

protected static String CONTINUE_IF_FILE_UNCHANGED

UPLOAD_IF_FILE_CHANGED

protected static String UPLOAD_IF_FILE_CHANGED

WORKSPACE_PATH

protected static String WORKSPACE_PATH

UPLOAD_URL

protected static String UPLOAD_URL

CALLING_ACTION

protected static String CALLING_ACTION

VALID_EMPTY_FILE

protected static String VALID_EMPTY_FILE

SECONDARY_CONTENT

protected static String SECONDARY_CONTENT

CONTENT_RECORD_DELIM

protected static String CONTENT_RECORD_DELIM

CONTENT_DELIM

protected static String CONTENT_DELIM

TARGET_TYPE

protected static String TARGET_TYPE

uploadDownload

private HTTPUploadDownload uploadDownload

uploadDownloadView

private HTTPUploadDownloadView uploadDownloadView

contextGroup

private ThreadGroup contextGroup

DEBUG

protected boolean DEBUG

continueIfFileNotFound

protected boolean continueIfFileNotFound

continueIfFileUnchanged

protected boolean continueIfFileUnchanged

uploadIfFileChanged

protected boolean uploadIfFileChanged

validEmptyFile

protected boolean validEmptyFile

removable

protected boolean removable

workspacePath

protected String workspacePath

persistedFilename

protected String persistedFilename

callingAction

protected String callingAction

docOperation

protected String docOperation

fileAccess

private FileAccess fileAccess

uploadStatus

protected int uploadStatus

multipleQuantity

protected int multipleQuantity

localChecksum

protected long localChecksum

existingChecksum

protected long existingChecksum

uploadPath

protected String uploadPath

defaultFilename

protected String defaultFilename

uploadURL

protected String uploadURL

invalidPathsDisplay

protected String invalidPathsDisplay

secondaryContent

protected String secondaryContent

contentRecordDelim

protected String contentRecordDelim

contentDelim

protected String contentDelim

targetType

protected int targetType

jsFeedbackMethod

protected String jsFeedbackMethod

uploadImpl

protected String uploadImpl

uploadToCacheOnly

protected boolean uploadToCacheOnly

hostName

protected String hostName

sessionID

protected String sessionID

formName

protected String formName
Constructor Detail

UploadApplet

public UploadApplet()
Method Detail

init

public void init()

start

public void start()

stop

public void stop()

destroy

public void destroy()

updateContent

public void updateContent()

updateMultiple

public void updateMultiple()

validateFiles

protected void validateFiles()

validateTarget

protected void validateTarget()

validateAttachments

protected void validateAttachments()

stripInvalidAttachments

protected void stripInvalidAttachments()

saveContent

protected boolean saveContent()

saveContent

protected boolean saveContent(boolean primaryUpload)

getUrl

private URL getUrl()

isValidTarget

public boolean isValidTarget(String target)

getFileAccess

private FileAccess getFileAccess()

getParameter

public String getParameter(String paramName,
                           String defaultParamValue)

checksumsMatch

private boolean checksumsMatch()

getParentApplet

public Applet getParentApplet()

getParentFrame

public Frame getParentFrame()

confirm

private boolean confirm(String displayMessage)

getContext

private WTContext getContext()

escape

private String escape(String source)

parseIntoArray

private String[] parseIntoArray(String parseFrom,
                                String delimiter,
                                int arraySize)

browseForFile

public String browseForFile(String path)
Browse local file system. The file name that is located will be used for the pending upload or download. The result of this browse will become the first or primary file.


isDirectory

public boolean isDirectory(String path)

createValidDefaultPath

public String createValidDefaultPath(String path)

sendKeyValueToServer

public String sendKeyValueToServer(String key,
                                   String value)
                            throws Exception
Throws:
Exception