use of com.amazonaws.AmazonServiceException in project SAGU by brianmcmichael.
the class DeleteArchiveFrame method actionPerformed.
@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.");
}
}
use of com.amazonaws.AmazonServiceException in project SAGU by brianmcmichael.
the class InventoryRequest method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == jbtInventoryRequest) {
SwingWorker<Object, Void> inventoryWorker = new SwingWorker<Object, Void>() {
@Override
protected Object doInBackground() throws Exception {
//Create dumb progressbar
Date d = new Date();
JFrame inventoryFrame = new JFrame("Waiting for inventory");
{
inventoryFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
Calendar cal = Calendar.getInstance();
cal.setTime(d);
cal.add(Calendar.MINUTE, 250);
String doneString = cal.getTime().toString();
JLabel doneTimeLabel = new JLabel("<html><body>Inventory of vault " + irVault + " requested.<br>Estimated completion by " + doneString + "</html></body>");
final JProgressBar dumJProgressBar = new JProgressBar(JProgressBar.HORIZONTAL);
dumJProgressBar.setIndeterminate(true);
inventoryFrame.add(dumJProgressBar, BorderLayout.NORTH);
inventoryFrame.add(doneTimeLabel, BorderLayout.CENTER);
inventoryFrame.setBackground(wc);
inventoryFrame.setSize(300, 60);
}
centerDefineFrame(inventoryFrame, 500, 100);
inventoryFrame.setVisible(true);
try {
JobParameters jParameters = new JobParameters().withType("inventory-retrieval");
InitiateJobRequest initJobRequest = new InitiateJobRequest().withVaultName(irVault).withJobParameters(jParameters);
InitiateJobResult initJobResult = irClient.initiateJob(initJobRequest);
String thisJobId = initJobResult.getJobId();
Thread.sleep(12600000);
Boolean success = waitForJob(irClient, irVault, thisJobId);
while (!success) {
Thread.sleep(WAIT_TIME);
success = waitForJob(irClient, irVault, thisJobId);
}
GetJobOutputRequest gjoRequest = new GetJobOutputRequest().withVaultName(irVault).withJobId(thisJobId);
GetJobOutputResult gjoResult = irClient.getJobOutput(gjoRequest);
Format formatter = new SimpleDateFormat("yyyyMMMdd_HHmmss");
String fileDate = formatter.format(d);
String fileName = irVault + fileDate + ".txt";
String filePath = "" + CUR_DIR + System.getProperty("file.separator") + fileName;
FileWriter fileStream = new FileWriter(filePath);
BufferedWriter out = new BufferedWriter(fileStream);
BufferedReader in = new BufferedReader(new InputStreamReader(gjoResult.getBody()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
out.write(inputLine);
}
out.close();
inventoryFrame.setVisible(false);
JOptionPane.showMessageDialog(null, "Successfully exported " + irVault + " inventory to " + filePath.toString(), "Saved", JOptionPane.INFORMATION_MESSAGE);
return null;
} catch (AmazonServiceException k) {
JOptionPane.showMessageDialog(null, "The server returned an error. Files will not be inventoried for 24 hours after upload. Also check that correct location of vault has been set on the previous page.", "Error", JOptionPane.ERROR_MESSAGE);
System.out.println("" + k);
inventoryFrame.setVisible(false);
} catch (AmazonClientException i) {
JOptionPane.showMessageDialog(null, "Client Error. Check that all fields are correct. Inventory not requested.", "Error", JOptionPane.ERROR_MESSAGE);
inventoryFrame.setVisible(false);
} catch (Exception j) {
JOptionPane.showMessageDialog(null, "Inventory not found. Unspecified Error.", "Error", JOptionPane.ERROR_MESSAGE);
inventoryFrame.setVisible(false);
}
return null;
}
};
inventoryWorker.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.");
}
}
use of com.amazonaws.AmazonServiceException in project SAGU by brianmcmichael.
the class AmazonDownloadRequest method actionPerformed.
@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 {
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.");
}
}
use of com.amazonaws.AmazonServiceException in project stocator by SparkTC.
the class COSAPIClient method initMultipartUploads.
private void initMultipartUploads(Configuration conf) throws IOException {
boolean purgeExistingMultipart = Utils.getBoolean(conf, FS_COS, FS_ALT_KEYS, PURGE_EXISTING_MULTIPART, DEFAULT_PURGE_EXISTING_MULTIPART);
long purgeExistingMultipartAge = Utils.getLong(conf, FS_COS, FS_ALT_KEYS, PURGE_EXISTING_MULTIPART_AGE, DEFAULT_PURGE_EXISTING_MULTIPART_AGE);
if (purgeExistingMultipart) {
Date purgeBefore = new Date(new Date().getTime() - purgeExistingMultipartAge * 1000);
try {
transfers.abortMultipartUploads(mBucket, purgeBefore);
} catch (AmazonServiceException e) {
if (e.getStatusCode() == 403) {
LOG.debug("Failed to purging multipart uploads against {}," + " FS may be read only", mBucket, e);
} else {
throw translateException("purging multipart uploads", mBucket, e);
}
}
}
}
use of com.amazonaws.AmazonServiceException in project flink by apache.
the class KinesisProxyTest method testIsRecoverableExceptionWithNullErrorType.
@Test
public void testIsRecoverableExceptionWithNullErrorType() {
final AmazonServiceException ex = new AmazonServiceException("asdf");
ex.setErrorType(null);
assertFalse(KinesisProxy.isRecoverableException(ex));
}
Aggregations