Example usage for com.amazonaws.services.glacier.model DeleteArchiveRequest DeleteArchiveRequest

List of usage examples for com.amazonaws.services.glacier.model DeleteArchiveRequest DeleteArchiveRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.glacier.model DeleteArchiveRequest DeleteArchiveRequest.

Prototype

public DeleteArchiveRequest() 

Source Link

Document

Default constructor for DeleteArchiveRequest object.

Usage

From source file:ai.serotonin.backup.Backup.java

License:Mozilla Public License

private void deleteOldBackups() throws Exception {
    final int maxFiles = configRoot.get("maxFiles").asInt();
    if (maxFiles <= 0)
        return;/*from w  ww. ja  v  a  2  s .co m*/

    final String vaultName = getVaultName();
    final List<Archive> archives = getInventory();

    if (archives == null)
        LOG.warn("Could not delete old backups");
    else {
        Collections.sort(archives);
        LOG.info("Found " + archives.size() + " archives in inventory");

        while (archives.size() > maxFiles) {
            final Archive archive = archives.remove(0);
            LOG.info("Purging archive named " + archive.filename);
            final DeleteArchiveRequest request = new DeleteArchiveRequest() //
                    .withVaultName(vaultName) //
                    .withArchiveId(archive.id);
            client.deleteArchive(request);
        }

        final StringBuilder sb = new StringBuilder();
        for (final Archive archive : archives) {
            if (sb.length() > 0)
                sb.append(", ");
            sb.append(archive.filename);
        }
        LOG.info("Keeping archive(s) named " + sb.toString());
    }
}

From source file:com.brianmcmichael.sagu.DeleteArchiveFrame.java

License:Open Source License

@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 {//from www  .ja v  a 2 s . co  m

            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.");
    }

}

From source file:com.leverno.ysbos.archive.example.ArchiveDelete.java

License:Open Source License

public static void main(String[] args) throws IOException {

    AWSCredentials credentials = AwsUtil.getCredentials();

    client = new AmazonGlacierClient(credentials);
    client.setEndpoint(Constants.endpoint);

    try {//from   w ww .  j a v  a  2 s .  co  m

        // ArchiveDelete the archive.
        client.deleteArchive(new DeleteArchiveRequest().withVaultName(vaultName).withArchiveId(archiveId));

        System.out.println("Deleted archive successfully.");

    } catch (Exception e) {
        System.err.println("Archive not deleted.");
        System.err.println(e);
    }
}

From source file:com.vrane.metaGlacier.Archive.java

/**
 * Delete an archive from AWS./* w w  w  . ja  v  a2 s .  c  o  m*/
 * Also mark any metadata object as deleted; metadata marked as such will be
 * deleted after 24 hours.  Because AWS inventory list is not realtime, this
 * application does not delete metadata object immediately because otherwise
 * it is reinserted when the archive lists are synchronized soon after
 * deletion. To delete it manually in your custom application, see metadata
 * API or SDK.
 * 
 * @return true on successful deletion
 */
public boolean delete() {
    DeleteArchiveRequest request = new DeleteArchiveRequest().withVaultName(vaultName).withArchiveId(archiveId);
    final MArchive ma = new MArchive(new Vault(vaultName), archiveId);

    if (!isInAWSInventory()) {

        /* This code path should not be reached because delete button should
        * be greyed out for this case
        */
        deleteError = "Cannot delete because it is not in AWS";
        return false;
    }
    try {
        GlacierFrame.getClient().deleteArchive(request);
    } catch (Exception e) {
        LGR.log(Level.SEVERE, null, e);
        deleteError = "AWS Error in deleting";
        return false;
    }
    if (!GlacierFrame.haveMetadataProvider()) {
        return true;
    }
    try {
        return ma.markDeleted();
    } catch (SDKException | APIException | SignInException ex) {
        LGR.log(Level.SEVERE, null, ex);
    }
    deleteError = "Error in deleting from Metadata Provider";
    return false;
}

From source file:nl.nekoconeko.glaciercmd.GlacierClient.java

License:Open Source License

protected void deleteArchive(String vault, String archiveId) {
    DeleteArchiveRequest deleteArchiveRequest = new DeleteArchiveRequest();
    deleteArchiveRequest.setVaultName(vault);
    deleteArchiveRequest.setArchiveId(archiveId);

    client.deleteArchive(deleteArchiveRequest);
}

From source file:org.duraspace.glacier.DeleteArchiveFrame.java

License:Open Source License

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 {//from  ww  w  .  java 2s. c o  m

            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.");
    }

}