List of usage examples for com.amazonaws.services.glacier.transfer ArchiveTransferManager download
public void download(final String accountId, final String vaultName, final String archiveId, final File file) throws AmazonServiceException, AmazonClientException
From source file:com.brianmcmichael.sagu.AmazonDownloadRequest.java
License:Open Source License
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == jbtDownload) { archiveId = jtfDownloadField.getText().trim(); if ((archiveId.equals(""))) { JOptionPane.showMessageDialog(null, "Enter the Archive ID of the file to be requested.", "Error", JOptionPane.ERROR_MESSAGE); } else {//from w w w .j a v a 2 s. co m SwingWorker downloadWorker = new SwingWorker() { private String archiveId = jtfDownloadField.getText().trim(); @Override protected Object doInBackground() throws Exception { // Create dumb progressbar JFrame downloadFrame = new JFrame("Downloading"); { downloadFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); final JProgressBar dumJProgressBar = new JProgressBar(JProgressBar.HORIZONTAL); dumJProgressBar.setIndeterminate(true); downloadFrame.add(dumJProgressBar, BorderLayout.NORTH); downloadFrame.setSize(300, 60); } centerDefineFrame(downloadFrame, 300, 50); String archiveId = jtfDownloadField.getText().trim(); try { String vaultName = dlVault; FileDialog fd = new FileDialog(new Frame(), "Save Archive As...", FileDialog.SAVE); fd.setFile("Save Archive As..."); fd.setDirectory(System.getProperty("user.dir")); fd.setLocation(50, 50); fd.setVisible(true); String filePath = "" + fd.getDirectory() + System.getProperty("file.separator") + fd.getFile(); File outFile = new File(filePath); if (outFile != null) { downloadFrame.setTitle("Downloading " + outFile.toString()); downloadFrame.setVisible(true); final Endpoint endpoint = Endpoint.getByIndex(locationChoice); AmazonSQSClient dlSQS = new AmazonSQSClient(dlCredentials); AmazonSNSClient dlSNS = new AmazonSNSClient(dlCredentials); dlSQS.setEndpoint(endpoint.getSQSEndpoint()); dlSNS.setEndpoint(endpoint.getSNSEndpoint()); // ArchiveTransferManager atm = new // ArchiveTransferManager(dlClient, // dlCredentials); ArchiveTransferManager atm = new ArchiveTransferManager(dlClient, dlSQS, dlSNS); atm.download("-", vaultName, archiveId, outFile); JOptionPane.showMessageDialog(null, "Sucessfully downloaded " + outFile.toString(), "Success", JOptionPane.INFORMATION_MESSAGE); downloadFrame.setVisible(false); } } catch (AmazonServiceException k) { JOptionPane.showMessageDialog(null, "The server returned an error. Wait 24 hours after submitting an archive to attempt a download. Also check that correct location of archive has been set on the previous page.", "Error", JOptionPane.ERROR_MESSAGE); System.out.println("" + k); downloadFrame.setVisible(false); } catch (AmazonClientException i) { JOptionPane.showMessageDialog(null, "Client Error. Check that all fields are correct. Archive not downloaded.", "Error", JOptionPane.ERROR_MESSAGE); downloadFrame.setVisible(false); } catch (Exception j) { JOptionPane.showMessageDialog(null, "Archive not found. Unspecified Error.", "Error", JOptionPane.ERROR_MESSAGE); downloadFrame.setVisible(false); } return null; } }; downloadWorker.execute(); try { Thread.sleep(500); } catch (InterruptedException e1) { e1.printStackTrace(); } this.setVisible(false); dispose(); } } else if (e.getSource() == jbtBack) { this.setVisible(false); dispose(); } else { JOptionPane.showMessageDialog(this, "Please choose a valid action."); } }
From source file:com.brianmcmichael.sagu.ui.AmazonDownloadRequest.java
License:Open Source License
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == jbtDownload) { archiveId = jtfDownloadField.getText().trim(); if ((archiveId.equals(""))) { JOptionPane.showMessageDialog(null, "Enter the Archive ID of the file to be requested.", "Error", JOptionPane.ERROR_MESSAGE); } else {//from w w w . ja v a 2 s . co m SwingWorker<Object, Void> downloadWorker = new SwingWorker<Object, Void>() { private String archiveId = jtfDownloadField.getText().trim(); @Override protected Void doInBackground() throws Exception { // Create dumb progressbar JFrame downloadFrame = new JFrame("Downloading"); { downloadFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); final JProgressBar dumJProgressBar = new JProgressBar(JProgressBar.HORIZONTAL); dumJProgressBar.setIndeterminate(true); downloadFrame.add(dumJProgressBar, BorderLayout.NORTH); downloadFrame.setSize(300, 60); } centerDefineFrame(downloadFrame, 300, 50); try { String vaultName = dlVault; FileDialog fd = new FileDialog(new Frame(), "Save Archive As...", FileDialog.SAVE); fd.setFile("Save Archive As..."); fd.setDirectory(System.getProperty("user.dir")); fd.setLocation(50, 50); fd.setVisible(true); String filePath = "" + fd.getDirectory() + System.getProperty("file.separator") + fd.getFile(); File outFile = new File(filePath); if (outFile != null) { downloadFrame.setTitle("Downloading " + outFile.toString()); downloadFrame.setVisible(true); final Endpoint endpoint = Endpoint.getByIndex(locationChoice); AmazonSQSClient dlSQS = new AmazonSQSClient(dlCredentials); AmazonSNSClient dlSNS = new AmazonSNSClient(dlCredentials); dlSQS.setEndpoint(endpoint.getSQSEndpoint()); dlSNS.setEndpoint(endpoint.getSNSEndpoint()); // ArchiveTransferManager atm = new // ArchiveTransferManager(dlClient, // dlCredentials); ArchiveTransferManager atm = new ArchiveTransferManager(dlClient, dlSQS, dlSNS); atm.download("-", vaultName, archiveId, outFile); JOptionPane.showMessageDialog(null, "Sucessfully downloaded " + outFile.toString(), "Success", JOptionPane.INFORMATION_MESSAGE); downloadFrame.setVisible(false); } } catch (AmazonServiceException k) { JOptionPane.showMessageDialog(null, "The server returned an error. Wait 24 hours after submitting an archive to attempt a download. Also check that correct location of archive has been set on the previous page.", "Error", JOptionPane.ERROR_MESSAGE); System.out.println("" + k); downloadFrame.setVisible(false); } catch (AmazonClientException i) { JOptionPane.showMessageDialog(null, "Client Error. Check that all fields are correct. Archive not downloaded.", "Error", JOptionPane.ERROR_MESSAGE); downloadFrame.setVisible(false); } catch (Exception j) { JOptionPane.showMessageDialog(null, "Archive not found. Unspecified Error.", "Error", JOptionPane.ERROR_MESSAGE); downloadFrame.setVisible(false); } return null; } }; downloadWorker.execute(); try { Thread.sleep(500); } catch (InterruptedException e1) { e1.printStackTrace(); } this.setVisible(false); dispose(); } } else if (e.getSource() == jbtBack) { this.setVisible(false); dispose(); } else { JOptionPane.showMessageDialog(this, "Please choose a valid action."); } }
From source file:com.brianmcmichael.SimpleGlacierUploader.AmazonDownloadRequest.java
License:Open Source License
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == jbtDownload) { archiveId = jtfDownloadField.getText().trim(); if ((archiveId.equals(""))) { JOptionPane.showMessageDialog(null, "Enter the Archive ID of the file to be requested.", "Error", JOptionPane.ERROR_MESSAGE); } else {/* ww w . j a v a2 s . co m*/ SwingWorker downloadWorker = new SwingWorker() { private String archiveId = jtfDownloadField.getText().trim(); @Override protected Object doInBackground() throws Exception { // Create dumb progressbar JFrame downloadFrame = new JFrame("Downloading"); { downloadFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); final JProgressBar dumJProgressBar = new JProgressBar(JProgressBar.HORIZONTAL); dumJProgressBar.setIndeterminate(true); downloadFrame.add(dumJProgressBar, BorderLayout.NORTH); downloadFrame.setSize(300, 60); } centerDefineFrame(downloadFrame, 300, 50); String archiveId = jtfDownloadField.getText().trim(); try { String vaultName = dlVault; FileDialog fd = new FileDialog(new Frame(), "Save Archive As...", FileDialog.SAVE); fd.setFile("Save Archive As..."); fd.setDirectory(System.getProperty("user.dir")); fd.setLocation(50, 50); fd.setVisible(true); String filePath = "" + fd.getDirectory() + System.getProperty("file.separator") + fd.getFile(); File outFile = new File(filePath); if (outFile != null) { downloadFrame.setTitle("Downloading " + outFile.toString()); downloadFrame.setVisible(true); Endpoints notificationEP = new Endpoints(locationChoice); AmazonSQSClient dlSQS = new AmazonSQSClient(dlCredentials); AmazonSNSClient dlSNS = new AmazonSNSClient(dlCredentials); dlSQS.setEndpoint(notificationEP.sqsEndpoint()); dlSNS.setEndpoint(notificationEP.snsEndpoint()); // ArchiveTransferManager atm = new // ArchiveTransferManager(dlClient, // dlCredentials); ArchiveTransferManager atm = new ArchiveTransferManager(dlClient, dlSQS, dlSNS); atm.download("-", vaultName, archiveId, outFile); JOptionPane.showMessageDialog(null, "Sucessfully downloaded " + outFile.toString(), "Success", JOptionPane.INFORMATION_MESSAGE); downloadFrame.setVisible(false); } } catch (AmazonServiceException k) { JOptionPane.showMessageDialog(null, "The server returned an error. Wait 24 hours after submitting an archive to attempt a download. Also check that correct location of archive has been set on the previous page.", "Error", JOptionPane.ERROR_MESSAGE); System.out.println("" + k); downloadFrame.setVisible(false); } catch (AmazonClientException i) { JOptionPane.showMessageDialog(null, "Client Error. Check that all fields are correct. Archive not downloaded.", "Error", JOptionPane.ERROR_MESSAGE); downloadFrame.setVisible(false); } catch (Exception j) { JOptionPane.showMessageDialog(null, "Archive not found. Unspecified Error.", "Error", JOptionPane.ERROR_MESSAGE); downloadFrame.setVisible(false); } return null; } }; downloadWorker.execute(); try { Thread.sleep(500); } catch (InterruptedException e1) { e1.printStackTrace(); } this.setVisible(false); dispose(); } } else if (e.getSource() == jbtBack) { this.setVisible(false); dispose(); } else { JOptionPane.showMessageDialog(this, "Please choose a valid action."); } }