Example usage for com.amazonaws.services.cloudfront.model DistributionConfig getDefaultRootObject

List of usage examples for com.amazonaws.services.cloudfront.model DistributionConfig getDefaultRootObject

Introduction

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

Prototype


public String getDefaultRootObject() 

Source Link

Document

<p> The object that you want CloudFront to request from your origin (for example, <code>index.html</code>) when a viewer requests the root URL for your distribution (<code>http://www.example.com</code>) instead of an object in your distribution (<code>http://www.example.com/product-description.html</code>).

Usage

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

License:Open Source License

private Distribution readDownloadDistribution(final AmazonCloudFront client, final DistributionSummary summary,
        final Path container, final Distribution.Method method) throws BackgroundException {
    // Retrieve distributions configuration to access current logging status settings.
    try {// ww  w.  j  a v a 2  s .  c  o m
        final GetDistributionConfigResult response = client
                .getDistributionConfig(new GetDistributionConfigRequest(summary.getId()));
        final DistributionConfig configuration = response.getDistributionConfig();
        final Distribution distribution = new Distribution(this.getOrigin(container, method), method,
                summary.isEnabled());
        distribution.setId(summary.getId());
        distribution.setDeployed("Deployed".equals(summary.getStatus()));
        distribution.setUrl(URI.create(
                String.format("%s://%s%s", method.getScheme(), summary.getDomainName(), method.getContext())));
        distribution.setSslUrl(method.equals(Distribution.DOWNLOAD) || method.equals(Distribution.CUSTOM)
                ? URI.create(String.format("https://%s%s", summary.getDomainName(), method.getContext()))
                : null);
        distribution.setReference(configuration.getCallerReference());
        distribution.setEtag(response.getETag());
        distribution.setStatus(LocaleFactory.localizedString(summary.getStatus(), "S3"));
        distribution.setCNAMEs(configuration.getAliases().getItems()
                .toArray(new String[configuration.getAliases().getItems().size()]));
        distribution.setLogging(configuration.getLogging().isEnabled());
        distribution
                .setLoggingContainer(StringUtils.isNotBlank(configuration.getLogging().getBucket())
                        ? ServiceUtils.findBucketNameInHostname(configuration.getLogging().getBucket(),
                                new S3Protocol().getDefaultHostname())
                        : null);
        if (StringUtils.isNotBlank(configuration.getDefaultRootObject())) {
            distribution.setIndexDocument(configuration.getDefaultRootObject());
        }
        if (this.getFeature(Purge.class, method) != null) {
            distribution.setInvalidationStatus(this.readInvalidationStatus(client, distribution));
        }
        if (this.getFeature(DistributionLogging.class, method) != null) {
            distribution.setContainers(new S3BucketListService(session).list(
                    new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory)),
                    new DisabledListProgressListener()).toList());
        }
        return distribution;
    } catch (AmazonClientException e) {
        throw new AmazonServiceExceptionMappingService().map("Cannot read CDN configuration", e);
    }
}