@Test public void testRestore() throws Exception { final Path bucket = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.volume)); final Path test = new Path(bucket, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); final byte[] content = RandomUtils.nextBytes(512); final TransferStatus status = new TransferStatus(); status.setStorageClass("GLACIER"); status.setLength(content.length); status.setChecksum(new SHA256ChecksumCompute().compute(new ByteArrayInputStream(content), status)); final HttpResponseOutputStream<StorageObject> out = new S3WriteFeature(session).write(test, status, new DisabledConnectionCallback()); new StreamCopier(status, status).transfer(new ByteArrayInputStream(content), out); out.close(); assertEquals("GLACIER", new S3AttributesFinderFeature(session, true).find(test).getStorageClass()); final Glacier feature = new Glacier(session, new DisabledX509TrustManager(), new DefaultX509KeyManager()); feature.restore(test, new DisabledLoginCallback()); new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledPasswordCallback(), new Delete.DisabledCallback()); }
@Override public void restore(final Path file, final LoginCallback prompt) throws BackgroundException { final Path container = containerService.getContainer(file); try { this.authenticated(new Authenticated<Void>() { @Override public Void call() throws BackgroundException { try { final AmazonS3 client = client(container); client.restoreObjectV2(new RestoreObjectRequest(container.getName(), containerService.getKey(file)) .withVersionId(file.attributes().getVersionId()) .withExpirationInDays(preferences.getInteger("s3.glacier.restore.expiration.days")) .withGlacierJobParameters(new GlacierJobParameters().withTier(preferences.getProperty("s3.glacier.restore.tier"))) ); } catch(AmazonClientException e) { throw new AmazonServiceExceptionMappingService().map("Failure to write attributes of {0}", e, file); } return null; } }, prompt); } catch(ConflictException e) { log.warn(String.format("Restore for %s already in progress %s", file, e)); } }
Glacier implements Restore { @Override public void restore(final Path file, final LoginCallback prompt) throws BackgroundException { final Path container = containerService.getContainer(file); try { this.authenticated(new Authenticated<Void>() { @Override public Void call() throws BackgroundException { try { final AmazonS3 client = client(container); client.restoreObjectV2(new RestoreObjectRequest(container.getName(), containerService.getKey(file)) .withVersionId(file.attributes().getVersionId()) .withExpirationInDays(preferences.getInteger("s3.glacier.restore.expiration.days")) .withGlacierJobParameters(new GlacierJobParameters().withTier(preferences.getProperty("s3.glacier.restore.tier"))) ); } catch(AmazonClientException e) { throw new AmazonServiceExceptionMappingService().map("Failure to write attributes of {0}", e, file); } return null; } }, prompt); } catch(ConflictException e) { log.warn(String.format("Restore for %s already in progress %s", file, e)); } } }
Glacier implements Restore { @Override public void restore(final Path file, final LoginCallback prompt) throws BackgroundException { final Path container = containerService.getContainer(file); try { this.authenticated(new Authenticated<Void>() { @Override public Void call() throws BackgroundException { try { final AmazonS3 client = client(container); client.restoreObjectV2(new RestoreObjectRequest(container.getName(), containerService.getKey(file)) .withVersionId(file.attributes().getVersionId()) .withExpirationInDays(preferences.getInteger("s3.glacier.restore.expiration.days")) .withGlacierJobParameters(new GlacierJobParameters().withTier(preferences.getProperty("s3.glacier.restore.tier"))) ); } catch(AmazonClientException e) { throw new AmazonServiceExceptionMappingService().map("Failure to write attributes of {0}", e, file); } return null; } }, prompt); } catch(ConflictException e) { log.warn(String.format("Restore for %s already in progress %s", file, e)); } } Glacier(final S3Session session, final X509TrustManager trust, final X509KeyManager key); }
Glacier implements Restore { @Override public void restore(final Path file, final LoginCallback prompt) throws BackgroundException { final Path container = containerService.getContainer(file); try { this.authenticated(new Authenticated<Void>() { @Override public Void call() throws BackgroundException { try { final AmazonS3 client = client(container); client.restoreObjectV2(new RestoreObjectRequest(container.getName(), containerService.getKey(file)) .withVersionId(file.attributes().getVersionId()) .withExpirationInDays(preferences.getInteger("s3.glacier.restore.expiration.days")) .withGlacierJobParameters(new GlacierJobParameters().withTier(preferences.getProperty("s3.glacier.restore.tier"))) ); } catch(AmazonClientException e) { throw new AmazonServiceExceptionMappingService().map("Failure to write attributes of {0}", e, file); } return null; } }, prompt); } catch(ConflictException e) { log.warn(String.format("Restore for %s already in progress %s", file, e)); } } Glacier(final S3Session session, final X509TrustManager trust, final X509KeyManager key); @Override void restore(final Path file, final LoginCallback prompt); @Override boolean isRestorable(final Path file); }
Glacier implements Restore { @Override public void restore(final Path file, final LoginCallback prompt) throws BackgroundException { final Path container = containerService.getContainer(file); try { this.authenticated(new Authenticated<Void>() { @Override public Void call() throws BackgroundException { try { final AmazonS3 client = client(container); client.restoreObjectV2(new RestoreObjectRequest(container.getName(), containerService.getKey(file)) .withVersionId(file.attributes().getVersionId()) .withExpirationInDays(preferences.getInteger("s3.glacier.restore.expiration.days")) .withGlacierJobParameters(new GlacierJobParameters().withTier(preferences.getProperty("s3.glacier.restore.tier"))) ); } catch(AmazonClientException e) { throw new AmazonServiceExceptionMappingService().map("Failure to write attributes of {0}", e, file); } return null; } }, prompt); } catch(ConflictException e) { log.warn(String.format("Restore for %s already in progress %s", file, e)); } } Glacier(final S3Session session, final X509TrustManager trust, final X509KeyManager key); @Override void restore(final Path file, final LoginCallback prompt); @Override boolean isRestorable(final Path file);  }