Search in sources :

Example 46 with AmazonServiceException

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.");
    }
}
Also used : DeleteArchiveRequest(com.amazonaws.services.glacier.model.DeleteArchiveRequest) AmazonClientException(com.amazonaws.AmazonClientException) AmazonServiceException(com.amazonaws.AmazonServiceException) AmazonServiceException(com.amazonaws.AmazonServiceException) AmazonClientException(com.amazonaws.AmazonClientException)

Example 47 with AmazonServiceException

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.");
    }
}
Also used : FileWriter(java.io.FileWriter) AmazonClientException(com.amazonaws.AmazonClientException) BufferedWriter(java.io.BufferedWriter) Format(java.text.Format) SimpleDateFormat(java.text.SimpleDateFormat) InputStreamReader(java.io.InputStreamReader) Calendar(java.util.Calendar) Date(java.util.Date) AmazonServiceException(com.amazonaws.AmazonServiceException) AmazonClientException(com.amazonaws.AmazonClientException) BufferedReader(java.io.BufferedReader) AmazonServiceException(com.amazonaws.AmazonServiceException) SimpleDateFormat(java.text.SimpleDateFormat)

Example 48 with AmazonServiceException

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.");
    }
}
Also used : AmazonClientException(com.amazonaws.AmazonClientException) AmazonSQSClient(com.amazonaws.services.sqs.AmazonSQSClient) AmazonSNSClient(com.amazonaws.services.sns.AmazonSNSClient) AmazonServiceException(com.amazonaws.AmazonServiceException) AmazonClientException(com.amazonaws.AmazonClientException) ArchiveTransferManager(com.amazonaws.services.glacier.transfer.ArchiveTransferManager) Endpoint(com.brianmcmichael.sagu.Endpoint) AmazonServiceException(com.amazonaws.AmazonServiceException) File(java.io.File)

Example 49 with AmazonServiceException

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);
            }
        }
    }
}
Also used : AmazonServiceException(com.amazonaws.AmazonServiceException) Date(java.util.Date)

Example 50 with AmazonServiceException

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));
}
Also used : AmazonServiceException(com.amazonaws.AmazonServiceException) Test(org.junit.Test)

Aggregations

AmazonServiceException (com.amazonaws.AmazonServiceException)109 DataStoreException (org.apache.jackrabbit.core.data.DataStoreException)21 AmazonS3 (com.amazonaws.services.s3.AmazonS3)15 ObjectMetadata (com.amazonaws.services.s3.model.ObjectMetadata)15 AmazonClientException (com.amazonaws.AmazonClientException)13 IOException (java.io.IOException)12 Collection (java.util.Collection)12 AmazonDynamoDB (com.amazonaws.services.dynamodbv2.AmazonDynamoDB)11 File (java.io.File)10 Message (org.apache.camel.Message)10 ArrayList (java.util.ArrayList)8 S3Object (com.amazonaws.services.s3.model.S3Object)7 TransferManager (com.amazonaws.services.s3.transfer.TransferManager)7 FileNotFoundException (java.io.FileNotFoundException)7 Copy (com.amazonaws.services.s3.transfer.Copy)6 CopyObjectRequest (com.amazonaws.services.s3.model.CopyObjectRequest)5 ObjectListing (com.amazonaws.services.s3.model.ObjectListing)5 S3ObjectSummary (com.amazonaws.services.s3.model.S3ObjectSummary)5 AttributeValue (com.amazonaws.services.dynamodbv2.model.AttributeValue)4 ProvisionedThroughput (com.amazonaws.services.dynamodbv2.model.ProvisionedThroughput)4