Example usage for com.amazonaws.services.glacier.model GetJobOutputRequest setVaultName

List of usage examples for com.amazonaws.services.glacier.model GetJobOutputRequest setVaultName

Introduction

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

Prototype


public void setVaultName(String vaultName) 

Source Link

Document

The name of the vault.

Usage

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

License:Open Source License

private GetJobOutputResult waitForJobCompletion(String vault, String jobId) throws InterruptedException {
    GetJobOutputRequest job = new GetJobOutputRequest();
    job.setVaultName(vault);
    job.setJobId(jobId);/* w  w  w .  j a  v a  2s.c om*/

    GetJobOutputResult res = null;
    boolean stop = false;
    while (!stop) {
        int code = 0;
        String error = "";
        try {
            res = this.client.getJobOutput(job);
            code = res.getStatus();
        } catch (AmazonServiceException e) {
            error = e.getMessage();
            code = e.getStatusCode();
        }

        switch (code) {
        case 200:
            stop = true;
            break;
        case 400:
            if (error.contains("The job is not currently available for download")) {
                Formatter.printInfoLine("Job is not finished yet, waiting...");
            } else {
                Formatter.printErrorLine("AWS returned code 400. Body Malformed.");
                System.exit(1);
            }
            break;
        case 404:
            Formatter.printErrorLine("AWS returned code 404. Vault or Job could not be found.");
            System.exit(1);
        default:
            Formatter.printInfoLine(String.format("Job returned code %d, waiting 30 seconds", code));
            break;
        }
        if (!stop) {
            Thread.sleep(1000 * 60);
        }
    }

    return res;
}