Example usage for com.amazonaws.services.cloudfront.model CustomHeaders CustomHeaders

List of usage examples for com.amazonaws.services.cloudfront.model CustomHeaders CustomHeaders

Introduction

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

Prototype

CustomHeaders

Source Link

Usage

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

License:Open Source License

protected com.amazonaws.services.cloudfront.model.Distribution createDownloadDistribution(final Path container,
        final Distribution distribution) throws BackgroundException {
    if (log.isDebugEnabled()) {
        log.debug(String.format("Create new %s distribution", distribution.getMethod().toString()));
    }/*from www.j a  v a 2s. com*/
    final AmazonCloudFront client = client(container);
    final URI origin = this.getOrigin(container, distribution.getMethod());
    final String originId = String.format("%s-%s", preferences.getProperty("application.name"),
            new AlphanumericRandomStringService().random());
    final DistributionConfig config = new DistributionConfig(new AlphanumericRandomStringService().random(),
            distribution.isEnabled())
                    .withComment(originId)
                    .withOrigins(
                            new Origins().withQuantity(1)
                                    .withItems(new Origin().withId(originId)
                                            .withCustomHeaders(new CustomHeaders().withQuantity(0))
                                            .withOriginPath(StringUtils.EMPTY).withDomainName(origin.getHost())
                                            .withS3OriginConfig(new S3OriginConfig()
                                                    .withOriginAccessIdentity(StringUtils.EMPTY))))
                    .withPriceClass(PriceClass.PriceClass_All)
                    .withDefaultCacheBehavior(new DefaultCacheBehavior().withTargetOriginId(originId)
                            .withForwardedValues(new ForwardedValues().withQueryString(true)
                                    .withCookies(new CookiePreference().withForward(ItemSelection.All)))
                            .withViewerProtocolPolicy(ViewerProtocolPolicy.AllowAll).withMinTTL(0L)
                            .withTrustedSigners(new TrustedSigners().withEnabled(false).withQuantity(0)))
                    .withDefaultRootObject(distribution.getIndexDocument()).withAliases(new Aliases()
                            .withItems(distribution.getCNAMEs()).withQuantity(distribution.getCNAMEs().length));
    // Make bucket name fully qualified
    final String loggingTarget = ServiceUtils.generateS3HostnameForBucket(distribution.getLoggingContainer(),
            false, new S3Protocol().getDefaultHostname());
    if (log.isDebugEnabled()) {
        log.debug(String.format("Set logging target for %s to %s", distribution, loggingTarget));
    }
    config.setLogging(new LoggingConfig().withEnabled(distribution.isLogging()).withIncludeCookies(true)
            .withBucket(loggingTarget).withPrefix(preferences.getProperty("cloudfront.logging.prefix")));
    return client.createDistribution(new CreateDistributionRequest(config)).getDistribution();
}