List of usage examples for com.amazonaws.services.glacier.model ResourceNotFoundException getErrorMessage
public String getErrorMessage()
From source file:ai.serotonin.backup.Base.java
License:Mozilla Public License
List<Archive> getInventory() throws Exception { final String vaultName = getVaultName(); final InitiateJobRequest initJobRequest = new InitiateJobRequest() // .withVaultName(vaultName) // .withJobParameters(new JobParameters() // .withType("inventory-retrieval") // //.withSNSTopic("*** provide SNS topic ARN ****") // );/*from w ww .ja v a 2 s . c o m*/ String jobId; try { LOG.info("Initiating inventory job..."); final InitiateJobResult initJobResult = client.initiateJob(initJobRequest); jobId = initJobResult.getJobId(); } catch (final ResourceNotFoundException e) { // Ignore. No inventory is available. LOG.warn("Inventory not available: " + e.getErrorMessage()); return null; } // Wait for the inventory job to complete. waitForJob(vaultName, jobId); // Get the output of the inventory job. LOG.info("Inventory job completed. Getting output..."); final GetJobOutputRequest jobOutputRequest = new GetJobOutputRequest().withVaultName(vaultName) .withJobId(jobId); final GetJobOutputResult jobOutputResult = client.getJobOutput(jobOutputRequest); final ObjectMapper mapper = new ObjectMapper(); final ObjectNode rootNode = mapper.readValue(jobOutputResult.getBody(), ObjectNode.class); final List<Archive> archives = new ArrayList<>(); for (final JsonNode archiveNode : rootNode.get("ArchiveList")) archives.add(new Archive(archiveNode)); Collections.sort(archives); return archives; }