List of usage examples for com.amazonaws.services.cloudfront AmazonCloudFront updateDistribution
UpdateDistributionResult updateDistribution(UpdateDistributionRequest updateDistributionRequest);
Updates the configuration for a web distribution.
From source file:ch.cyberduck.core.cloudfront.CloudFrontDistributionConfiguration.java
License:Open Source License
/** * Amazon CloudFront Extension used to enable or disable a distribution configuration and its CNAMESs *//*from w w w.j a va 2s .c om*/ protected UpdateDistributionResult updateDownloadDistribution(final Path container, final Distribution distribution) throws IOException, BackgroundException { final URI origin = this.getOrigin(container, distribution.getMethod()); if (log.isDebugEnabled()) { log.debug(String.format("Update %s distribution with origin %s", distribution.getMethod().toString(), origin)); } final AmazonCloudFront client = client(container); final GetDistributionConfigResult response = client .getDistributionConfig(new GetDistributionConfigRequest(distribution.getId())); final DistributionConfig config = response.getDistributionConfig().withEnabled(distribution.isEnabled()) .withDefaultRootObject(distribution.getIndexDocument()).withAliases(new Aliases() .withItems(distribution.getCNAMEs()).withQuantity(distribution.getCNAMEs().length)); if (distribution.isLogging()) { // 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.updateDistribution( new UpdateDistributionRequest(config, distribution.getId(), response.getETag())); }
From source file:ch.cyberduck.core.cloudfront.CloudFrontDistributionConfiguration.java
License:Open Source License
protected UpdateDistributionResult updateCustomDistribution(final Path container, final Distribution distribution) throws IOException, BackgroundException { final URI origin = this.getOrigin(container, distribution.getMethod()); if (log.isDebugEnabled()) { log.debug(String.format("Update %s distribution with origin %s", distribution.getMethod().toString(), origin));// w ww . j a v a2s.c om } final AmazonCloudFront client = client(container); final GetDistributionConfigResult response = client .getDistributionConfig(new GetDistributionConfigRequest(distribution.getId())); final DistributionConfig config = response.getDistributionConfig().withEnabled(distribution.isEnabled()) .withDefaultRootObject(distribution.getIndexDocument() != null ? distribution.getIndexDocument() : StringUtils.EMPTY) .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.updateDistribution( new UpdateDistributionRequest(config, distribution.getId(), response.getETag())); }