public AmazonGlacierClient getGlacierClient(String region) throws AmazonClientException { AmazonGlacierClient glacierClient = null; try { AWSCredentials credentials = getAwsCredentials(); glacierClient = new AmazonGlacierClient(credentials); glacierClient.setEndpoint("https://glacier." + region + ".amazonaws.com"); } catch (IOException e) { throw new AmazonClientException(e.getMessage()); } catch (IllegalArgumentException e) { throw new AmazonClientException(e.getMessage()); } return glacierClient; }
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == jbtDelete) { if ((jtfDeleteField.getText().trim().equals(""))) { JOptionPane.showMessageDialog( null, "Enter the Archive ID of the file to be deleted.", "Error", JOptionPane.ERROR_MESSAGE); } else { try { String archiveId = jtfDeleteField.getText().trim(); // Banish the extra chars printed in early logs. String sendThis = archiveId.replaceAll("[^\\p{Print}]", ""); String vaultName = deleteVault; // Delete the archive. deleteClient.deleteArchive( new DeleteArchiveRequest().withVaultName(vaultName).withArchiveId(sendThis)); JOptionPane.showMessageDialog( null, "Deleted archive successfully.", "Success", JOptionPane.INFORMATION_MESSAGE); } catch (AmazonServiceException k) { JOptionPane.showMessageDialog( null, "The server returned an error. Wait 24 hours after submitting an archive to attempt a delete. Also check that correct location of archive has been set on the previous page.", "Error", JOptionPane.ERROR_MESSAGE); System.out.println("" + k); } catch (AmazonClientException i) { JOptionPane.showMessageDialog( null, "Client Error. Check that all fields are correct. Archive not deleted.", "Error", JOptionPane.ERROR_MESSAGE); } catch (Exception j) { JOptionPane.showMessageDialog( null, "Archive not deleted. Unspecified Error.", "Error", JOptionPane.ERROR_MESSAGE); } jtfDeleteField.setText(""); jtfDeleteField.requestFocus(); } } else if (e.getSource() == jbtBack) { this.setVisible(false); dispose(); } else { JOptionPane.showMessageDialog(this, "Please choose a valid action."); } }