private GatekeeperMessage retrieveGatekeeperResponse(S3Object[] objects) throws Exception { // Check whether Uploader has all necessary credentials from user inputs. boolean s3CredentialsProvided = userInputProperties.getProperty("AwsAccessKey") != null && userInputProperties.getProperty("AwsSecretKey") != null && userInputProperties.getProperty("S3BucketName") != null; GatekeeperMessage gatekeeperMessage = null; if (s3CredentialsProvided) { log.debug("S3 login credentials and bucket name are available, the Uploader " + "will generate its own Gatekeeper response"); gatekeeperMessage = buildGatekeeperResponse(objects); } else { gatekeeperMessage = contactGatewayServer(objects); } return gatekeeperMessage; }
/** * Move the wizard backward one step/screen. */ private void wizardStepBackward() { drawWizardScreen(currentState - 1); }
/** * Constructor to run this application in a stand-alone window. * * @param ownerFrame the frame the application will be displayed in * @throws S3ServiceException */ public Uploader(JFrame ownerFrame, Properties standAloneArgumentProperties) throws S3ServiceException { this(false); this.ownerFrame = ownerFrame; this.standAloneArgumentProperties = standAloneArgumentProperties; init(); ownerFrame.getContentPane().add(this); ownerFrame.setBounds(this.getBounds()); ownerFrame.setVisible(true); }
String applicationTitle = replaceMessageVariables( uploaderProperties.getStringProperty("gui.applicationTitle", null)); if (applicationTitle != null) { footerLabel.setHorizontalAlignment(JLabel.CENTER); if (footerHtml != null) { footerLabel.setText(replaceMessageVariables(footerHtml)); includeFooter = true; chooseFileButton.setActionCommand("ChooseFile"); chooseFileButton.addActionListener(this); configureButton(chooseFileButton, "screen.2.browseButton"); cancelUploadButton.setActionCommand("CancelUpload"); cancelUploadButton.addActionListener(this); configureButton(cancelUploadButton, "screen.4.cancelButton"); new GridBagConstraints(0, 3, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); this.getContentPane().add(appContentPanel); this.setBounds(new Rectangle(new Dimension(preferredWidth, preferredHeight))); initDropTarget(new Component[] {this} ); wizardStepForward();
wizardStepForward(); } else if ("Back".equals(actionEvent.getActionCommand())) { wizardStepBackward(); } else if ("ChooseFile".equals(actionEvent.getActionCommand())) { JFileChooser fileChooser = new JFileChooser(); fileList.add(fileChooser.getSelectedFile()); if (checkProposedUploadFiles(fileList)) { wizardStepForward();
userGuidanceLabel.setText(replaceMessageVariables(title)); configureButton(nextButton, "screen." + nextState + ".nextButton"); configureButton(backButton, "screen." + nextState + ".backButton"); this.getDropTarget().setActive(false); replaceMessageVariables(uploaderProperties.getStringProperty("screen.2.dragDropPrompt", "Missing property 'screen.2.dragDropPrompt'"))); this.getDropTarget().setActive(true); } else if (nextState == WIZARD_SCREEN_3) { primaryPanelCardLayout.show(primaryPanel, "screen3"); String fileInformation = uploaderProperties.getStringProperty("screen.3.fileInformation", "Missing property 'screen.3.fileInformation'"); fileToUploadLabel.setText(replaceMessageVariables(fileInformation)); } else if (nextState == WIZARD_SCREEN_4) { primaryPanelCardLayout.show(primaryPanel, "screen4"); fileInformationLabel.setText(replaceMessageVariables(fileInformation)); finalMessageLabel.setText(replaceMessageVariables(finalMessage)); } else { log.error("Ignoring unexpected wizard screen number: " + nextState);
progressStatusTextLabel.setText(replaceMessageVariables(statusText)); progressTransferDetailsLabel.setText(""); } else { progressStatusTextLabel.setText(replaceMessageVariables(statusText)); progressTransferDetailsLabel.setText(replaceMessageVariables(transferDetailsText)); drawWizardScreen(WIZARD_SCREEN_5); progressTransferDetailsLabel.setText(""); uploadCancelled = true; drawWizardScreen(WIZARD_SCREEN_3); SwingUtilities.invokeLater(new Runnable() { public void run() { progressStatusTextLabel.setText(""); progressTransferDetailsLabel.setText(""); failWithFatalError(ERROR_CODE__S3_UPLOAD_FAILED); SwingUtilities.invokeLater(new Runnable() { public void run() {
while (st.hasMoreTokens()) { String paramName = st.nextToken(); String paramValue = this.getParameter(paramName); initGui(); failWithFatalError(ERROR_CODE__MISSING_REQUIRED_PARAM); return;
gatekeeperMessage = retrieveGatekeeperResponse(objectsForUpload); } catch (Exception e) { log.info("Upload request was denied", e); failWithFatalError(ERROR_CODE__UPLOAD_REQUEST_DECLINED); return; xmlGenerator.addMessageProperties(gatekeeperMessage.getMessageProperties()); SignedUrlAndObject[] uploadItems = prepareSignedObjects( objectsForUpload, gatekeeperMessage.getSignatureRequests(), xmlGenerator); GatekeeperMessage.PROPERTY_TRANSACTION_ID); if (priorTransactionId == null) { failWithFatalError(ERROR_CODE__TRANSACTION_ID_REQUIRED_TO_CREATE_XML_SUMMARY); return; gatekeeperMessage = retrieveGatekeeperResponse(new S3Object[] {summaryXmlObject}); SignedUrlAndObject[] xmlSummaryItem = prepareSignedObjects(new S3Object[] {summaryXmlObject}, gatekeeperMessage.getSignatureRequests(), null);
httpClientGatekeeper = initHttpConnection(); if (gatekeeperErrorCode != null) { log.warn("Received Gatekeeper error code: " + gatekeeperErrorCode); failWithFatalError(gatekeeperErrorCode); return null;
/** * Follows hyperlinks clicked on by a user. This is achieved differently depending on whether * Cockpit is running as an applet or as a stand-alone application: * <ul> * <li>Application: Detects the default browser application for the user's system (using * <tt>BareBonesBrowserLaunch</tt>) and opens the link as a new window in that browser</li> * <li>Applet: Opens the link in the current browser using the applet's context</li> * </ul> * * @param url * the url to open * @param target * the target pane to open the url in, eg "_blank". This may be null. */ public void followHyperlink(URL url, String target) { if (isRunningAsApplet) { if (target == null) { getAppletContext().showDocument(url); } else { getAppletContext().showDocument(url, target); } } else { BareBonesBrowserLaunch.openURL(url.toString()); } }
new Uploader(ownerFrame, argumentProperties);
String applicationTitle = replaceMessageVariables( uploaderProperties.getStringProperty("gui.applicationTitle", null)); if (applicationTitle != null) { footerLabel.setHorizontalAlignment(JLabel.CENTER); if (footerHtml != null) { footerLabel.setText(replaceMessageVariables(footerHtml)); includeFooter = true; chooseFileButton.setActionCommand("ChooseFile"); chooseFileButton.addActionListener(this); configureButton(chooseFileButton, "screen.2.browseButton"); cancelUploadButton.setActionCommand("CancelUpload"); cancelUploadButton.addActionListener(this); configureButton(cancelUploadButton, "screen.4.cancelButton"); new GridBagConstraints(0, 3, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); this.getContentPane().add(appContentPanel); this.setBounds(new Rectangle(new Dimension(preferredWidth, preferredHeight))); initDropTarget(new Component[] {this} ); wizardStepForward();
wizardStepForward(); } else if ("Back".equals(actionEvent.getActionCommand())) { wizardStepBackward(); } else if ("ChooseFile".equals(actionEvent.getActionCommand())) { JFileChooser fileChooser = new JFileChooser(); fileList.add(fileChooser.getSelectedFile()); if (checkProposedUploadFiles(fileList)) { wizardStepForward();
userGuidanceLabel.setText(replaceMessageVariables(title)); configureButton(nextButton, "screen." + nextState + ".nextButton"); configureButton(backButton, "screen." + nextState + ".backButton"); this.getDropTarget().setActive(false); replaceMessageVariables(uploaderProperties.getStringProperty("screen.2.dragDropPrompt", "Missing property 'screen.2.dragDropPrompt'"))); this.getDropTarget().setActive(true); } else if (nextState == WIZARD_SCREEN_3) { primaryPanelCardLayout.show(primaryPanel, "screen3"); String fileInformation = uploaderProperties.getStringProperty("screen.3.fileInformation", "Missing property 'screen.3.fileInformation'"); fileToUploadLabel.setText(replaceMessageVariables(fileInformation)); } else if (nextState == WIZARD_SCREEN_4) { primaryPanelCardLayout.show(primaryPanel, "screen4"); fileInformationLabel.setText(replaceMessageVariables(fileInformation)); finalMessageLabel.setText(replaceMessageVariables(finalMessage)); } else { log.error("Ignoring unexpected wizard screen number: " + nextState);
progressStatusTextLabel.setText(replaceMessageVariables(statusText)); progressTransferDetailsLabel.setText(""); } else { progressStatusTextLabel.setText(replaceMessageVariables(statusText)); progressTransferDetailsLabel.setText(replaceMessageVariables(transferDetailsText)); drawWizardScreen(WIZARD_SCREEN_5); progressTransferDetailsLabel.setText(""); uploadCancelled = true; drawWizardScreen(WIZARD_SCREEN_3); SwingUtilities.invokeLater(new Runnable() { public void run() { progressStatusTextLabel.setText(""); progressTransferDetailsLabel.setText(""); failWithFatalError(ERROR_CODE__S3_UPLOAD_FAILED); SwingUtilities.invokeLater(new Runnable() { public void run() {
while (st.hasMoreTokens()) { String paramName = st.nextToken(); String paramValue = this.getParameter(paramName); initGui(); failWithFatalError(ERROR_CODE__MISSING_REQUIRED_PARAM); return;
gatekeeperMessage = retrieveGatekeeperResponse(objectsForUpload); } catch (Exception e) { log.info("Upload request was denied", e); failWithFatalError(ERROR_CODE__UPLOAD_REQUEST_DECLINED); return; xmlGenerator.addMessageProperties(gatekeeperMessage.getMessageProperties()); SignedUrlAndObject[] uploadItems = prepareSignedObjects( objectsForUpload, gatekeeperMessage.getSignatureRequests(), xmlGenerator); GatekeeperMessage.PROPERTY_TRANSACTION_ID); if (priorTransactionId == null) { failWithFatalError(ERROR_CODE__TRANSACTION_ID_REQUIRED_TO_CREATE_XML_SUMMARY); return; gatekeeperMessage = retrieveGatekeeperResponse(new S3Object[] {summaryXmlObject}); SignedUrlAndObject[] xmlSummaryItem = prepareSignedObjects(new S3Object[] {summaryXmlObject}, gatekeeperMessage.getSignatureRequests(), null);
httpClientGatekeeper = initHttpConnection(); if (gatekeeperErrorCode != null) { log.warn("Received Gatekeeper error code: " + gatekeeperErrorCode); failWithFatalError(gatekeeperErrorCode); return null;
/** * Follows hyperlinks clicked on by a user. This is achieved differently depending on whether * Cockpit is running as an applet or as a stand-alone application: * <ul> * <li>Application: Detects the default browser application for the user's system (using * <tt>BareBonesBrowserLaunch</tt>) and opens the link as a new window in that browser</li> * <li>Applet: Opens the link in the current browser using the applet's context</li> * </ul> * * @param url * the url to open * @param target * the target pane to open the url in, eg "_blank". This may be null. */ public void followHyperlink(URL url, String target) { if (isRunningAsApplet) { if (target == null) { getAppletContext().showDocument(url); } else { getAppletContext().showDocument(url, target); } } else { BareBonesBrowserLaunch.openURL(url.toString()); } }