public class Uploader extends javax.swing.JApplet implements S3ServiceEventListener, java.awt.event.ActionListener, javax.swing.event.ListSelectionListener, HyperlinkActivatedListener, org.apache.http.client.CredentialsProvider
For more information and help please see the Uploader Guide.
The Uploader is highly configurable through properties specified in a file uploader.properties. This file must be available at the root of the classpath.
javax.swing.JApplet.AccessibleJAppletjava.applet.Applet.AccessibleApplet| Modifier and Type | Field and Description |
|---|---|
private javax.swing.JPanel |
appContentPanel |
static java.lang.String |
APPLICATION_DESCRIPTION |
private javax.swing.JButton |
backButton |
private javax.swing.JPanel |
buttonsPanel |
private java.awt.CardLayout |
buttonsPanelCardLayout |
private ByteFormatter |
byteFormatter |
private javax.swing.JButton |
cancelUploadButton |
private int |
currentState |
private JHtmlLabel |
dragDropTargetLabel |
static java.lang.String |
ERROR_CODE__MISSING_REQUIRED_PARAM |
static java.lang.String |
ERROR_CODE__S3_UPLOAD_FAILED |
static java.lang.String |
ERROR_CODE__TRANSACTION_ID_REQUIRED_TO_CREATE_XML_SUMMARY |
static java.lang.String |
ERROR_CODE__UPLOAD_REQUEST_DECLINED |
private boolean |
fatalErrorOccurred
Set to true if an upload failed due to a key name clash in S3, in which case an error
message is displayed in the final 'thankyou' screen.
|
private JHtmlLabel |
fileInformationLabel |
private int |
fileMaxCount |
private long |
fileMaxSizeMB |
private long |
fileMinSizeMB |
private java.io.File[] |
filesToUpload
The files to upload to S3.
|
private JHtmlLabel |
fileToUploadLabel |
private JHtmlLabel |
finalMessageLabel |
private java.awt.GridBagLayout |
GRID_BAG_LAYOUT |
private GuiUtils |
guiUtils |
static int |
HTTP_CONNECTION_TIMEOUT |
private org.apache.http.client.HttpClient |
httpClientGatekeeper |
private boolean |
includeXmlSummaryDoc
If set to true via the "xmlSummary" configuration property, the Uploader will
generate an XML summary document describing the files uploaded by the user and
will upload this summary document to S3.
|
private java.awt.Insets |
insetsDefault |
private java.awt.Insets |
insetsNone |
private boolean |
isRunningAsApplet |
private static org.apache.commons.logging.Log |
log |
static int |
MAX_CONNECTION_RETRIES |
private org.apache.http.client.CredentialsProvider |
mCredentialProvider |
private javax.swing.JButton |
nextButton |
private java.awt.Frame |
ownerFrame |
private java.util.HashMap |
parametersMap |
private javax.swing.JPanel |
primaryPanel |
private java.awt.CardLayout |
primaryPanelCardLayout |
private java.lang.Exception |
priorFailureException
Variable to store application exceptions, so that client failure information can be
included in the information provided to the Gatekeeper when uploads are retried.
|
private javax.swing.JProgressBar |
progressBar |
private JHtmlLabel |
progressStatusTextLabel |
private JHtmlLabel |
progressTransferDetailsLabel |
private S3ServiceMulti |
s3ServiceMulti |
private static long |
serialVersionUID |
private SkinsFactory |
skinsFactory |
static int |
SOCKET_CONNECTION_TIMEOUT |
private java.util.Properties |
standAloneArgumentProperties
Properties set in stand-alone application from the command line arguments.
|
private TimeFormatter |
timeFormatter |
private CancelEventTrigger |
uploadCancelEventTrigger |
private boolean |
uploadCancelled
Set to true when a file upload has been cancelled, to prevent the Uploader from
uploading an XML summary file when the prior file upload was cancelled.
|
static java.lang.String |
UPLOADER_PROPERTIES_FILENAME |
private static java.lang.String |
UPLOADER_VERSION_ID |
private Jets3tProperties |
uploaderProperties
Uploader's properties.
|
private boolean |
uploadingFinalObject
Set to true when the object/file being uploaded is the final in a set, eg when
the XML metadata is being uploaded after a movie file.
|
private JHtmlLabel |
userGuidanceLabel |
private UserInputFields |
userInputFields |
private java.util.Properties |
userInputProperties |
private java.util.ArrayList |
validFileExtensions
The list of file extensions accepted by the Uploader.
|
static int |
WIZARD_SCREEN_1 |
static int |
WIZARD_SCREEN_2 |
static int |
WIZARD_SCREEN_3 |
static int |
WIZARD_SCREEN_4 |
static int |
WIZARD_SCREEN_5 |
accessibleContext, rootPane, rootPaneCheckingEnabled| Modifier | Constructor and Description |
|---|---|
|
Uploader()
Constructor to run this application as an Applet.
|
private |
Uploader(boolean pIsRunningApplet) |
|
Uploader(javax.swing.JFrame ownerFrame,
java.util.Properties standAloneArgumentProperties)
Constructor to run this application in a stand-alone window.
|
| Modifier and Type | Method and Description |
|---|---|
void |
actionPerformed(java.awt.event.ActionEvent actionEvent)
Handles GUI actions.
|
private GatekeeperMessage |
buildGatekeeperResponse(S3Object[] objects)
Builds a Gatekeeper response based on AWS credential information available in the Uploader
properties.
|
private boolean |
checkProposedUploadFiles(java.util.List fileList)
Checks that all the files in a list are acceptable for uploading.
|
void |
clear()
Clear credentials.
|
private void |
configureButton(javax.swing.JButton button,
java.lang.String propertiesPrefix)
Configures a button's text, tooltip and image using uploader properties prefixed
with the given properties prefix.
|
private GatekeeperMessage |
contactGatewayServer(S3Object[] objects)
Retrieves a signed PUT URL from the given URL address.
|
private void |
drawWizardScreen(int nextState)
Draws the wizard screen appropriate to the stage in the wizard process the user has
reached.
|
private void |
failWithFatalError(java.lang.String errorCode)
When a fatal error occurs, go straight to last screen to display the error message
and make the error code available as a variable (
${errorCode}) to be used
in the error message displayed to the user. |
void |
followHyperlink(java.net.URL url,
java.lang.String target)
Follows hyperlinks clicked on by a user.
|
org.apache.http.auth.Credentials |
getCredentials(org.apache.http.auth.AuthScope scope)
Implementation method for the CredentialsProvider interface.
|
void |
init()
Prepares application to run as a GUI by finding/creating a root owner JFrame, and
(if necessary) creating a directory for storing remembered logins.
|
private void |
initDropTarget(java.awt.Component[] dropTargetComponents)
Initialise the application's File drop targets for drag and drop copying of local files
to S3.
|
private void |
initGui()
Initialises the application's GUI elements.
|
private org.apache.http.client.HttpClient |
initHttpConnection() |
static void |
main(java.lang.String[] args)
Run the Uploader as a stand-alone application.
|
private SignedUrlAndObject[] |
prepareSignedObjects(S3Object[] objects,
SignatureRequest[] signatureRequests,
XmlGenerator xmlGenerator) |
private java.lang.String |
replaceMessageVariables(java.lang.String message)
Replaces variables of the form ${variableName} in the input string with the value of that
variable name in the local uploaderProperties properties object, or with one of the
following special variables:
fileName : Name of file being uploaded
fileSize : Size of the file being uploaded, eg 1.04 MB
filePath : Absolute path of the file being uploaded
maxFileSize : The maxiumum allowed file size in MB
maxFileCount : The maximum number of files that may be uploaded
validFileExtensions : A list of the file extensions allowed
If the variable named in the input string is not available, or has no value, the variable
reference is left in the result.
|
private GatekeeperMessage |
retrieveGatekeeperResponse(S3Object[] objects) |
void |
s3ServiceEventPerformed(CopyObjectsEvent event) |
void |
s3ServiceEventPerformed(CreateBucketsEvent event) |
void |
s3ServiceEventPerformed(CreateObjectsEvent event)
Listener method that responds to events from the jets3t toolkit when objects are
created in S3 - ie when files are uploaded.
|
void |
s3ServiceEventPerformed(DeleteObjectsEvent event) |
void |
s3ServiceEventPerformed(DeleteVersionedObjectsEvent event) |
void |
s3ServiceEventPerformed(DownloadObjectsEvent event) |
void |
s3ServiceEventPerformed(GetObjectHeadsEvent event) |
void |
s3ServiceEventPerformed(GetObjectsEvent event) |
void |
s3ServiceEventPerformed(ListObjectsEvent event) |
void |
s3ServiceEventPerformed(LookupACLEvent event) |
void |
s3ServiceEventPerformed(UpdateACLEvent event) |
void |
setCredentials(org.apache.http.auth.AuthScope authscope,
org.apache.http.auth.Credentials credentials) |
private void |
uploadFilesToS3()
Uploads to S3 the file referenced by the variable fileToUpload, providing
progress feedback to the user all the while.
|
void |
valueChanged(javax.swing.event.ListSelectionEvent arg0) |
private void |
wizardStepBackward()
Move the wizard backward one step/screen.
|
private void |
wizardStepForward()
Move the wizard forward one step/screen.
|
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isRootPaneCheckingEnabled, paramString, remove, repaint, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, updatedestroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, isValidateRoot, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stopadd, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTreeaction, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, 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, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, revalidate, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleprivate static final long serialVersionUID
private static final org.apache.commons.logging.Log log
public static final java.lang.String APPLICATION_DESCRIPTION
public static final java.lang.String UPLOADER_PROPERTIES_FILENAME
private static final java.lang.String UPLOADER_VERSION_ID
public static final int WIZARD_SCREEN_1
public static final int WIZARD_SCREEN_2
public static final int WIZARD_SCREEN_3
public static final int WIZARD_SCREEN_4
public static final int WIZARD_SCREEN_5
public static final java.lang.String ERROR_CODE__MISSING_REQUIRED_PARAM
public static final java.lang.String ERROR_CODE__S3_UPLOAD_FAILED
public static final java.lang.String ERROR_CODE__UPLOAD_REQUEST_DECLINED
public static final java.lang.String ERROR_CODE__TRANSACTION_ID_REQUIRED_TO_CREATE_XML_SUMMARY
public static final int HTTP_CONNECTION_TIMEOUT
public static final int SOCKET_CONNECTION_TIMEOUT
public static final int MAX_CONNECTION_RETRIES
private java.awt.Frame ownerFrame
private UserInputFields userInputFields
private java.util.Properties userInputProperties
private org.apache.http.client.HttpClient httpClientGatekeeper
private S3ServiceMulti s3ServiceMulti
private java.io.File[] filesToUpload
private java.util.ArrayList validFileExtensions
private Jets3tProperties uploaderProperties
private java.util.Properties standAloneArgumentProperties
private final ByteFormatter byteFormatter
private final TimeFormatter timeFormatter
private int fileMaxCount
private long fileMaxSizeMB
private long fileMinSizeMB
private final java.awt.Insets insetsDefault
private final java.awt.Insets insetsNone
private final GuiUtils guiUtils
private int currentState
private final boolean isRunningAsApplet
private java.util.HashMap parametersMap
private SkinsFactory skinsFactory
private final java.awt.GridBagLayout GRID_BAG_LAYOUT
private JHtmlLabel userGuidanceLabel
private javax.swing.JPanel appContentPanel
private javax.swing.JPanel buttonsPanel
private javax.swing.JPanel primaryPanel
private java.awt.CardLayout primaryPanelCardLayout
private java.awt.CardLayout buttonsPanelCardLayout
private javax.swing.JButton backButton
private javax.swing.JButton nextButton
private javax.swing.JButton cancelUploadButton
private JHtmlLabel dragDropTargetLabel
private JHtmlLabel fileToUploadLabel
private JHtmlLabel fileInformationLabel
private JHtmlLabel progressTransferDetailsLabel
private javax.swing.JProgressBar progressBar
private JHtmlLabel progressStatusTextLabel
private JHtmlLabel finalMessageLabel
private CancelEventTrigger uploadCancelEventTrigger
private volatile boolean uploadingFinalObject
private volatile boolean includeXmlSummaryDoc
private volatile boolean uploadCancelled
private boolean fatalErrorOccurred
private java.lang.Exception priorFailureException
private final org.apache.http.client.CredentialsProvider mCredentialProvider
private Uploader(boolean pIsRunningApplet)
public Uploader()
public Uploader(javax.swing.JFrame ownerFrame,
java.util.Properties standAloneArgumentProperties)
throws S3ServiceException
ownerFrame - the frame the application will be displayed inS3ServiceExceptionpublic void init()
init in class java.applet.Appletprivate void initGui()
private void initDropTarget(java.awt.Component[] dropTargetComponents)
dropTargetComponents - the components files can be dropped on to transfer them to S3private boolean checkProposedUploadFiles(java.util.List fileList)
fileList - A list of Files to check.private GatekeeperMessage buildGatekeeperResponse(S3Object[] objects) throws java.lang.Exception
The required properties are:
objects - java.lang.Exceptionprivate GatekeeperMessage contactGatewayServer(S3Object[] objects) throws java.lang.Exception
credsProviderParamName - the name of the parameter containing the server URL target for the PUT request.HttpExceptionjava.lang.Exceptionprivate GatekeeperMessage retrieveGatekeeperResponse(S3Object[] objects) throws java.lang.Exception
java.lang.Exceptionprivate void uploadFilesToS3()
private SignedUrlAndObject[] prepareSignedObjects(S3Object[] objects, SignatureRequest[] signatureRequests, XmlGenerator xmlGenerator) throws java.lang.Exception
java.lang.Exceptionpublic void s3ServiceEventPerformed(CreateObjectsEvent event)
s3ServiceEventPerformed in interface S3ServiceEventListenerprivate void configureButton(javax.swing.JButton button,
java.lang.String propertiesPrefix)
button - propertiesPrefix - private void drawWizardScreen(int nextState)
nextState - an integer detailing the screen the user is moving to.private void wizardStepForward()
private void wizardStepBackward()
private void failWithFatalError(java.lang.String errorCode)
${errorCode}) to be used
in the error message displayed to the user.
If there is an Uploader property errorCodeMessage.<code> corresponding
to this error code, the value of this property is made available as a variable
(${errorMessage}). If there is no such property available the
${errorMessage} variable will be an empty string.
errorCode - the error code, which may correspond with an error message in uploader.properties.private java.lang.String replaceMessageVariables(java.lang.String message)
message - string that may have variables to replacepublic void actionPerformed(java.awt.event.ActionEvent actionEvent)
actionPerformed in interface java.awt.event.ActionListenerprivate org.apache.http.client.HttpClient initHttpConnection()
public void followHyperlink(java.net.URL url,
java.lang.String target)
followHyperlink in interface HyperlinkActivatedListenerurl - the url to opentarget - the target pane to open the url in, eg "_blank". This may be null.public void setCredentials(org.apache.http.auth.AuthScope authscope,
org.apache.http.auth.Credentials credentials)
setCredentials in interface org.apache.http.client.CredentialsProviderpublic void clear()
clear in interface org.apache.http.client.CredentialsProviderpublic org.apache.http.auth.Credentials getCredentials(org.apache.http.auth.AuthScope scope)
Based on sample code: InteractiveAuthenticationExample
getCredentials in interface org.apache.http.client.CredentialsProviderpublic void s3ServiceEventPerformed(ListObjectsEvent event)
s3ServiceEventPerformed in interface S3ServiceEventListenerpublic void s3ServiceEventPerformed(CreateBucketsEvent event)
s3ServiceEventPerformed in interface S3ServiceEventListenerpublic void s3ServiceEventPerformed(DeleteObjectsEvent event)
s3ServiceEventPerformed in interface S3ServiceEventListenerpublic void s3ServiceEventPerformed(GetObjectsEvent event)
s3ServiceEventPerformed in interface S3ServiceEventListenerpublic void s3ServiceEventPerformed(GetObjectHeadsEvent event)
s3ServiceEventPerformed in interface S3ServiceEventListenerpublic void s3ServiceEventPerformed(LookupACLEvent event)
s3ServiceEventPerformed in interface S3ServiceEventListenerpublic void s3ServiceEventPerformed(UpdateACLEvent event)
s3ServiceEventPerformed in interface S3ServiceEventListenerpublic void s3ServiceEventPerformed(DownloadObjectsEvent event)
s3ServiceEventPerformed in interface S3ServiceEventListenerpublic void s3ServiceEventPerformed(CopyObjectsEvent event)
s3ServiceEventPerformed in interface S3ServiceEventListenerpublic void s3ServiceEventPerformed(DeleteVersionedObjectsEvent event)
s3ServiceEventPerformed in interface S3ServiceEventListenerpublic void valueChanged(javax.swing.event.ListSelectionEvent arg0)
valueChanged in interface javax.swing.event.ListSelectionListenerpublic static void main(java.lang.String[] args)
throws java.lang.Exception
args - java.lang.Exception