List of usage examples for com.amazonaws.services.cloudfront AmazonCloudFront listInvalidations
ListInvalidationsResult listInvalidations(ListInvalidationsRequest listInvalidationsRequest);
Lists invalidation batches.
From source file:ch.cyberduck.core.cloudfront.CloudFrontDistributionConfiguration.java
License:Open Source License
/** * @param distribution Configuration/*w ww .j av a 2 s. c om*/ * @return Status message from service */ private String readInvalidationStatus(final AmazonCloudFront client, final Distribution distribution) throws BackgroundException { try { int pending = 0; int completed = 0; String marker = null; do { final ListInvalidationsResult response = client .listInvalidations(new ListInvalidationsRequest(distribution.getId()) .withMaxItems(String.valueOf(1000)).withMarker(marker)); for (InvalidationSummary s : response.getInvalidationList().getItems()) { // When the invalidation batch is finished, the status is Completed. if ("Completed".equals(s.getStatus())) { // No schema for status enumeration. Fail. completed++; } else { // InProgress pending++; } } marker = response.getInvalidationList().getNextMarker(); } while (marker != null); if (pending > 0) { return MessageFormat.format(LocaleFactory.localizedString("{0} invalidations in progress", "S3"), pending); } if (completed > 0) { return MessageFormat.format(LocaleFactory.localizedString("{0} invalidations completed", "S3"), completed); } return LocaleFactory.localizedString("None"); } catch (AmazonClientException e) { throw new AmazonServiceExceptionMappingService().map("Cannot read CDN configuration", e); } }