Example usage for com.amazonaws.services.glacier.model GlacierJobDescription getJobId

List of usage examples for com.amazonaws.services.glacier.model GlacierJobDescription getJobId

Introduction

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

Prototype


public String getJobId() 

Source Link

Document

An opaque string that identifies an Amazon S3 Glacier job.

Usage

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

private void get_data() {
    say("Getting data from AWS for " + vaultName);
    Vault vaultObj = new Vault(vaultName);
    List<GlacierJobDescription> jobs = vaultObj.listJobs();
    Calendar cal = new GregorianCalendar();

    // The following date will always be in the past for this software
    cal.set(2012, 0, 01, 1, 1, 1);/* w w w .j  a  v a2s . c  o m*/
    Date mostRecent = cal.getTime();
    Date invDate = null;
    LGR.log(Level.INFO, "number of jobs to process {0}", jobs.size());
    for (final GlacierJobDescription j : jobs) {
        final String jobId = j.getJobId();
        GetJobOutputResult jor = null;
        VaultInventory vi = null;
        Date yesterday = new Date(System.currentTimeMillis() - 86400000);

        LGR.log(Level.FINE, "Getting data for {0}", jobId);
        try {
            jor = vaultObj.getJobOutput(jobId);
        } catch (Exception e) {
            LGR.log(Level.SEVERE, null, e);
            continue;
        }
        final String jobContentType = jor.getContentType();
        if (jobContentType == null) {
            /* XXX why getMessage() returns null with this */
            LGR.log(Level.SEVERE, "Job content-type is null");
            continue;
        }
        LGR.log(Level.FINE, "job content type {0}", jobContentType);

        if (jor.getContentType().equals("application/octet-stream")) {
            /* This means archive download job is ready */
            AllVaults.addDownloadableArchiveJobId(vaultName, jobId);
            LGR.log(Level.FINE, "number of archive jobs found {0}", ++job_count);
            continue;
        } // Else this might be the inventory job
        LGR.log(Level.INFO, "parsing for job content-type {0}", jor.getContentType());
        try {
            vi = new VaultInventory(jor, vaultName);
        } catch (Exception ex) {
            LGR.log(Level.SEVERE, null, ex);
            dispose();
            LGR.log(Level.WARNING, "Job content type {0} job id {1}",
                    new Object[] { jor.getContentType(), jobId });
            JOptionPane.showMessageDialog(null, "Error getting archives");
            return;
        }
        invDate = vi.getInventoryDate();
        LGR.log(Level.INFO, "inventory date {0}", invDate);
        if (invDate.compareTo(mostRecent) < 0) {
            continue;
        }
        mostRecent = invDate;
        if (invDate.compareTo(yesterday) < 0) {
            LGR.info("inventory older than 24 hours");
            continue;
        }
        LGR.fine("Now getting archive list from AWS");
        Archives = vi.getArchives();
        LGR.log(Level.INFO, "Number of archives from this job= {0}", Archives == null ? 0 : Archives.size());
    }
    LGR.log(Level.INFO, "number of archives from AWS {0}", Archives == null ? 0 : Archives.size());
    final boolean noAWSdata = jobs.isEmpty() || Archives == null;
    if (noAWSdata) {
        if (!GlacierFrame.haveMetadataProvider()) {
            dispose();
            JOptionPane.showMessageDialog(null, "No job data from AWS");
            return;
        } else if (!Main.frame.doNotConfirmGettingMetadata()) {
            final int selectedButton = JOptionPane.showConfirmDialog(this, "Get data from metadata provider?",
                    "No AWS Job Ready", JOptionPane.YES_NO_OPTION);
            if (selectedButton != JOptionPane.YES_OPTION) {
                dispose();
                return;
            }
        }
    }
    if (GlacierFrame.haveMetadataProvider()) {
        say("Getting data from metadata provider");
        MArchiveList mal = new MArchiveList(new Vault(vaultName));
        if (Archives != null) {
            for (Archive a : Archives) {
                ArchiveRO ma = new ArchiveRO(a.getArchiveId(), a.getSize(), a.getDescription());
                mal.add(ma.withAWSCreateTime(a.getAWSCreateTime()));
            }
        }
        boolean metadataError = true;
        try {
            if (mal.sync()) {
                for (final MArchive mar : mal.getArchiveList()) {
                    ExtraArchives.add(mar);
                }
                metadataError = false;
            }
        } catch (SDKException e) {
            LGR.log(Level.SEVERE, null, e);
        } catch (Exception ex) {
            LGR.log(Level.SEVERE, null, ex);
        }
        if (metadataError) {
            JOptionPane.showMessageDialog(this, "Error from metadata provider!");
            dispose();
        }
    }
    if (noAWSdata && ExtraArchives.isEmpty()) {
        dispose();
        JOptionPane.showMessageDialog(this, "No data retrieved");
        return;
    }
    ArchiveManageDialog amd = new ArchiveManageDialog(vaultName, Archives, ExtraArchives, false,
            "inventory for '" + vaultName + "'");
    dispose();
    amd.setVisible(true);

}