Example usage for com.amazonaws.services.glacier.model DescribeVaultOutput getVaultName

List of usage examples for com.amazonaws.services.glacier.model DescribeVaultOutput getVaultName

Introduction

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

Prototype


public String getVaultName() 

Source Link

Document

The name of the vault.

Usage

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

License:Open Source License

private void repopulateVaults(String accessString, String secretString) {

    int newLoc = getServerRegion();

    if (!(getAccessKey().equals("") || getSecretKey().equals(""))) {
        AmazonGlacierClient newVaultCheckClient = makeClient(accessString, secretString, newLoc);

        String marker = null;/*from w  w w.j ava 2s  .c o  m*/
        vaultSelector.removeAllItems();
        vaultSelector.addItem("Select Existing:");
        do {
            ListVaultsRequest lv = new ListVaultsRequest().withMarker(marker).withLimit("1000");

            ListVaultsResult lvr = newVaultCheckClient.listVaults(lv);
            ArrayList<DescribeVaultOutput> vList = new ArrayList<DescribeVaultOutput>(lvr.getVaultList());
            marker = lvr.getMarker();

            for (DescribeVaultOutput vault : vList) {
                vaultSelector.addItem(vault.getVaultName());
            }

        } while (marker != null);
    }
}

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

License:Open Source License

public void repopulateVaults(String accessString, String secretString) {

    int newLoc = locationChoice.getSelectedIndex();

    if (!(accessField.getText().trim().equals("") || secretField.getText().trim().equals(""))) {
        AmazonGlacierClient newVaultCheckClient = makeClient(accessString, secretString, newLoc);

        String marker = null;//from  w  w  w.  j a v a2  s.  c  o  m
        vaultSelector.removeAllItems();
        vaultSelector.addItem("Select Existing:");
        do {
            ListVaultsRequest lv = new ListVaultsRequest().withMarker(marker).withLimit("1000");

            ListVaultsResult lvr = newVaultCheckClient.listVaults(lv);
            ArrayList<DescribeVaultOutput> vList = new ArrayList<DescribeVaultOutput>(lvr.getVaultList());
            marker = lvr.getMarker();

            for (DescribeVaultOutput vault : vList) {
                vaultSelector.addItem(vault.getVaultName());
            }

        } while (marker != null);
    }
}

From source file:com.brianmcmichael.SimpleGlacierUploader.SimpleGlacierUploader.java

License:Open Source License

public void repopulateVaults(String accessString, String secretString, int regionInt) {

    int newLoc = locationChoice.getSelectedIndex();

    if (((accessField.getText().trim().equals("")) == true)
            || (secretField.getText().trim().equals("")) == true) {
    } else {/* w  w  w.  jav  a 2 s  . co m*/
        AmazonGlacierClient newVaultCheckClient = new AmazonGlacierClient();
        newVaultCheckClient = makeClient(accessString, secretString, newLoc);
        // BasicAWSCredentials credentials = new
        // BasicAWSCredentials(accessString,secretString);

        String marker = null;
        vaultSelector.removeAllItems();
        vaultSelector.addItem("Select Existing:");
        do {
            ListVaultsRequest lv = new ListVaultsRequest().withMarker(marker).withLimit("1000");

            ListVaultsResult lvr = newVaultCheckClient.listVaults(lv);
            ArrayList<DescribeVaultOutput> vList = new ArrayList<DescribeVaultOutput>(lvr.getVaultList());
            marker = lvr.getMarker();

            for (DescribeVaultOutput vault : vList) {
                vaultSelector.addItem(vault.getVaultName());
            }

        } while (marker != null);
    }
}

From source file:com.optimalbi.AmazonAccount.java

License:Apache License

private void populateGlacier() throws AmazonClientException {
    for (Region r : regions) {
        if (r.isServiceSupported(ServiceAbbreviations.Glacier)) {
            AmazonGlacierClient glacierClient = new AmazonGlacierClient(credentials.getCredentials());
            glacierClient.setRegion(r);//from  w w  w. ja  v a  2s  .  c o m
            ListVaultsResult result = glacierClient.listVaults(new ListVaultsRequest());
            List<DescribeVaultOutput> vaults = result.getVaultList();
            for (DescribeVaultOutput d : vaults) {
                DescribeVaultResult res = glacierClient
                        .describeVault(new DescribeVaultRequest(d.getVaultName()));
                Service temp = new LocalGlacierService(d.getVaultName(), credentials, r, res, logger);
                services.add(temp);
            }
        }
    }
}

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

/**
 * Returns a set of vault names./*from   ww w .  j a va 2 s  .c o m*/
 * This method makes use of data cached by <b>list()</b> and call that
 * method first internally.
 * 
 * @return a list of vault names
 * @throws Exception 
 */
public Set<String> listNames() throws Exception {
    list();
    String[] vaultNameArray = new String[allVaults.size()];
    short i = 0;

    for (final DescribeVaultOutput dvo : allVaults) {
        vaultNameArray[i++] = dvo.getVaultName();
    }
    return new HashSet<>(Arrays.asList(vaultNameArray));
}

From source file:com.vrane.metaGlacier.gui.vaults.VaultListPanel.java

void init(final HashMap<String, String> lastcount) {
    JTextField jt;// w w w . j a  v  a2 s.c  o  m
    short count = 0;
    byte rows = 1;

    if (list.size() > 0) {
        add(new JLabel());
        add(new HeaderJT("Archives"));
        add(new HeaderJT("Last count"));
        add(new HeaderJT("Size"));
        add(new JLabel());
    }
    for (final DescribeVaultOutput dvo : list) {
        count++;
        if (count < minimum || count > maximum) {
            continue;
        }
        rows++;
        final String vault_name = dvo.getVaultName();
        final JLabel la = GlacierFrame.makeLabel(" " + vault_name + " ");
        add(la);
        String buttonString;
        long numArchives = dvo.getNumberOfArchives();
        if (numArchives > 0) {
            buttonString = "Inventory";
            la.setBorder(BorderFactory.createRaisedBevelBorder());
            la.addMouseListener(new MouseClickListener() {

                @Override
                public void mouseClicked(MouseEvent me) {
                    new LaunchArchiveManager(vault_name).execute();
                }
            });
        } else {
            buttonString = "Delete";
        }
        jt = new JTextField(5);
        jt.setText(numArchives + "");
        jt.setHorizontalAlignment(JTextField.RIGHT);
        jt.setEditable(false);
        add(jt);
        jt = new JTextField(5);
        String last_count_text = null;
        last_count_text = (String) (lastcount.containsKey(vault_name) ? lastcount.get(vault_name)
                : "" + numArchives);
        jt.setText(last_count_text);

        jt.setHorizontalAlignment(JTextField.RIGHT);
        jt.setEditable(false);
        add(jt);
        jt = new ByteTextField(dvo.getSizeInBytes());
        add(jt);
        final JButton vaultButton = new JButton(buttonString);
        vaultButton.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ae) {
                if (!vaultButton.isEnabled()) {
                    return;
                }
                vaultButton.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                vaultButton.validate();
                if (vaultButton.getText().equals("Delete")) {
                    vaultButton.setEnabled(false);
                    try {
                        if (new Vault(vault_name).delete()) {
                            vaultButton.setText("deleted");
                        } else {
                            vaultButton.setEnabled(true);
                        }
                    } catch (Exception e) {
                        LGR.log(Level.SEVERE, null, e);
                        JOptionPane.showMessageDialog(null,
                                "Failed to delete vault. An archive added recently?");
                        vaultButton.setEnabled(true);
                    }
                } else {
                    new VaultInventoryJobDialog(vault_name);
                }
                vaultButton.setCursor(Cursor.getDefaultCursor());
            }
        });
        add(vaultButton);
    }
    init(rows, (short) 5);
}

From source file:com.vrane.metaGlacier.gui.VSplash.java

private void get_data() {
    say("Getting vault list from AWS");
    final long beginning = System.currentTimeMillis();
    List<DescribeVaultOutput> list = null;
    HashMap<String, String> lastCounts = new HashMap();
    long afterMetadata = 0;
    boolean success = false;

    try {/*from  w  ww.java  2s.c o  m*/
        list = new AllVaults().list();
    } catch (Exception ex) {
        LGR.log(Level.SEVERE, null, ex);
        dispose();
        JOptionPane.showMessageDialog(null, "Error getting vaults.  Check your connection or AWS keys");
        return;
    }
    LGR.fine("Received vault list from AWS");
    final long afterAWS = System.currentTimeMillis();

    if (!GlacierFrame.haveMetadataProvider()) {
        success = true;
    } else if (list.size() > 0) {
        say("Syncing with metadata provider");
        VaultList vaultList = new VaultList(GlacierFrame.getAWSRegion());
        List<VaultRO> mvlList = new ArrayList();
        for (final DescribeVaultOutput dvo : list) {
            final VaultRO vro = new VaultRO(dvo.getVaultName(), dvo.getNumberOfArchives(),
                    dvo.getCreationDate(), dvo.getSizeInBytes());
            mvlList.add(vro);
        }
        vaultList.setList(mvlList);
        String error_string = null;
        try {
            success = vaultList.sync();
            afterMetadata = System.currentTimeMillis();
            lastCounts = vaultList.getLastArchiveCounts();
            if (!success) {
                LGR.info("failed to sync");
            }
        } catch (SDKException | APIException ex) {
            LGR.log(Level.SEVERE, null, ex);
        } catch (SignInException ex) {
            LGR.log(Level.SEVERE, null, ex);
            error_string = "Failed to sign-in to metadata account";
        }
        dispose();
        if (!success) {
            if (error_string == null) {
                error_string = "Error from metadata provider";
            }
            JOptionPane.showMessageDialog(this, error_string);
        }
    }
    dispose();
    if (!success) {
        return;
    }
    new VaultManageDialog(list, afterAWS - beginning, afterMetadata == 0 ? 0 : (afterMetadata - afterAWS),
            lastCounts);
}

From source file:englishcoffeedrinker.corpse.Vault.java

License:Open Source License

/**
 * Creates a Vault instance from the description returned as part
 * of a ListVault command. Note that this won't contain a breakdown
 * of the archives contained with the vault as this information
 * isn't returned as part of a vault listing; you need to request
 * a vault inventory if you need to find out the details of each
 * archive in the vault.//w ww .ja va2 s  .  c  om
 * @param vault
 */
public Vault(DescribeVaultOutput vault) {
    this.arn = vault.getVaultARN();
    this.name = vault.getVaultName();
    this.creationDate = vault.getCreationDate();
    this.inventoryDate = vault.getLastInventoryDate();
    this.numArchives = vault.getNumberOfArchives();
    this.sizeInBytes = vault.getSizeInBytes();

    //a simple vault description doesn't contain the list
    //of archives, you have to request a vault inventory
    //to get the full list, which is why you should be
    //maintaining a local index of your glacier vaults
    archives = new ArrayList<Archive>();
}

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

License:Open Source License

public static void main(String[] args) {
    CommandLine cli = Configuration.parseCli(ModeType.ROOT, args);

    if (cli.hasOption("config")) {
        Configuration.loadFile(cli.getOptionValue("config"));
    }/*  w  w w  .  j  a va  2  s  . com*/

    Configuration.load(cli);

    if (Configuration.getMode() == ModeType.HELP) {
        if (Configuration.hasHelpType()) {
            ConfigModes.printConfigModeHelp(Configuration.getHelpType());
        } else {
            ConfigModes.printConfigModeHelp(ModeType.ROOT);
        }
        System.exit(0);
    }

    if (Configuration.getMode() == ModeType.VERSION) {
        Formatter.printHeader();
        System.exit(0);
    }

    if (!Configuration.hasKey() || !Configuration.hasSecret() || !Configuration.hasRegion()) {
        Formatter.printErrorLine("Make sure key, secret and region are set!");
        System.exit(-1);
    }

    GlacierClient gc = new GlacierClient(Configuration.getKey(), Configuration.getSecret());
    gc.setEndpoint(Configuration.getRegion().getEndpoint());

    if (Configuration.getMode() == ModeType.LIST) {
        Configuration.load(ModeType.LIST, args);
        if (!Configuration.hasListType()) {
            Formatter.printErrorLine("Make sure you specify a list type!");
            System.exit(-1);
        }

        switch (Configuration.getListType()) {
        case VAULT:
            List<DescribeVaultOutput> vaults = gc.getVaults();
            for (DescribeVaultOutput vault : vaults) {
                Formatter.printInfoLine(String.format("[%s] %d items, %d bytes, %s last checked",
                        vault.getVaultName(), vault.getNumberOfArchives(), vault.getSizeInBytes(),
                        vault.getLastInventoryDate()));
            }
            break;
        case ARCHIVE:
            if (!Configuration.hasVault()) {
                Formatter.printErrorLine("A vault has to be specified to list archives");
                System.exit(-1);
            }
            DescribeVaultResult vault = gc.describeVault(Configuration.getVault());
            Formatter.printInfoLine(
                    String.format("[%s] %d items, %d bytes, %s last checked", vault.getVaultName(),
                            vault.getNumberOfArchives(), vault.getSizeInBytes(), vault.getLastInventoryDate()));
            break;
        default:
            Formatter.printErrorLine("Invalid list type selected");
            System.exit(-1);
        }
    } else if (Configuration.getMode() == ModeType.INITIATEINVENTORY) {
        Configuration.load(ModeType.INITIATEINVENTORY, args);

        Formatter.printInfoLine("Requesting an inventory from AWS Glacier...");
        Formatter.printInfoLine(String.format("Job has been created with id: %s",
                gc.initiateRetrieveVaultInventory(Configuration.getVault())));
    } else if (Configuration.getMode() == ModeType.GETINVENTORY) {
        Configuration.load(ModeType.GETINVENTORY, args);

        Formatter.printInfoLine(
                String.format("Retrieving inventory with id %s from AWS Glacier...", Configuration.getJobId()));
        VaultInventory inv = null;
        try {
            inv = gc.retrieveVaultInventoryJob(Configuration.getVault(), Configuration.getJobId());
        } catch (InterruptedException e) {
            e.printStackTrace();
            System.exit(-1);
        }

        Formatter.printInfoLine(String.format("Vault ARN: %s", inv.VaultARN));
        Formatter.printInfoLine(String.format("Last Inventory Date: %s", inv.InventoryDate.toString()));
        Formatter.printInfoLine(String.format("Vault contains %d archives:", inv.ArchiveList.size()));
        for (Archive arch : inv.ArchiveList) {
            StringBuilder a = new StringBuilder();
            a.append(String.format("Archive ID: %s\n", arch.ArchiveId));
            a.append(String.format("Archive Description: %s\n", arch.ArchiveDescription));
            a.append(String.format("Archive Size: %d bytes\n", arch.Size));
            a.append(String.format("Creation Date: %s\n", arch.CreationDate.toString()));
            a.append(String.format("SHA256 Hash: %s\n", arch.SHA256TreeHash));
            Formatter.printBorderedInfo(a.toString());
        }

    } else if (Configuration.getMode() == ModeType.UPLOAD) {
        Configuration.load(ModeType.UPLOAD, args);

        Formatter.printInfoLine(String.format("Uploading '%s' to vault '%s'", Configuration.getInputFile(),
                Configuration.getVault()));
        UploadResult res = gc.uploadFile(Configuration.getVault(), Configuration.getInputFile(),
                Configuration.getDescription());
        Formatter.printInfoLine(String.format("Upload completed, archive has ID: %s", res.getArchiveId()));
    } else if (Configuration.getMode() == ModeType.DOWNLOAD) {
        Configuration.load(ModeType.DOWNLOAD, args);

        Formatter.printInfoLine(String.format("Download '%s' from vault '%s', saving as '%s'",
                Configuration.getArchive(), Configuration.getVault(), Configuration.getOutputFile()));
        Formatter.printInfoLine("Note that this will take several hours, please be patient...");
        gc.downloadFile(Configuration.getVault(), Configuration.getArchive(), Configuration.getOutputFile());
        Formatter.printInfoLine("Download completed");

    } else if (Configuration.getMode() == ModeType.INITIATEDOWNLOAD) {
        Configuration.load(ModeType.INITIATEDOWNLOAD, args);
        Formatter.printInfoLine(String.format("Requesting download of archive '%s' from vault '%s'...",
                Configuration.getArchive(), Configuration.getVault()));
        Formatter.printInfoLine(String.format("Job has been created with id: %s",
                gc.initiateDownload(Configuration.getVault(), Configuration.getArchive())));
    } else if (Configuration.getMode() == ModeType.GETDOWNLOAD) {
        Configuration.load(ModeType.GETDOWNLOAD, args);
        Formatter.printInfoLine(
                String.format("Retrieving download with '%s' from AWS Glacier, and saving it to '%s'...",
                        Configuration.getJobId(), Configuration.getOutputFile()));
        try {
            gc.retrieveDownloadJob(Configuration.getVault(), Configuration.getJobId(),
                    Configuration.getOutputFile());
        } catch (InterruptedException e) {
            e.printStackTrace();
            System.exit(-1);
        }
        Formatter.printInfoLine("Download completed");
    } else if (Configuration.getMode() == ModeType.DELETEARCHIVE) {
        Configuration.load(ModeType.DELETEARCHIVE, args);
        Formatter.printInfoLine(String.format("Deleting archive with id '%s' from vault '%s'",
                Configuration.getArchive(), Configuration.getVault()));
        gc.deleteArchive(Configuration.getVault(), Configuration.getArchive());
    } else {
        Formatter.printErrorLine("WHA-HUH!?");
        System.exit(-1);
    }
}

From source file:opendap.aws.glacier.NoaaResourceIngester.java

License:Open Source License

public String describeVault(DescribeVaultOutput dvo) {
    StringBuilder sb = new StringBuilder();
    sb.append("================================================================================\n");
    sb.append("Found Vault: ").append(dvo.getVaultName()).append("\n");
    sb.append("    getCreationDateString(): ").append(dvo.getCreationDate()).append("\n");
    sb.append("    getLastInventoryDate(): ").append(dvo.getLastInventoryDate()).append("\n");
    sb.append("    getNumberOfArchives(): ").append(dvo.getNumberOfArchives()).append("\n");
    sb.append("    getSizeInBytes(): ").append(dvo.getSizeInBytes()).append("\n");
    sb.append("    getVaultARN(): ").append(dvo.getVaultARN()).append("\n");
    sb.append("    toString(): ").append(dvo.toString()).append("\n");
    sb.append("    toString(): ").append(dvo.getVaultName()).append("\n");
    return sb.toString();
}