Example usage for com.amazonaws.services.cloudfront.model ListInvalidationsResult getInvalidationList

List of usage examples for com.amazonaws.services.cloudfront.model ListInvalidationsResult getInvalidationList

Introduction

In this page you can find the example usage for com.amazonaws.services.cloudfront.model ListInvalidationsResult getInvalidationList.

Prototype


public InvalidationList getInvalidationList() 

Source Link

Document

Information about invalidation batches.

Usage

From source file:ch.cyberduck.core.cloudfront.CloudFrontDistributionConfiguration.java

License:Open Source License

/**
 * @param distribution Configuration/*from   www .j a  v  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);
    }
}