/** * @param distribution Distribution configuration * @return Configuration * @throws CloudFrontServiceException CloudFront failure details * @throws IOException Service error */ private DistributionConfig getDistributionConfig( final org.jets3t.service.model.cloudfront.Distribution distribution) throws IOException, CloudFrontServiceException { CloudFrontService cf = this.getClient(); if (distribution.isStreamingDistribution()) { return cf.getStreamingDistributionConfig(distribution.getId()); } return cf.getDistributionConfig(distribution.getId()); }
private Distribution convert( final org.jets3t.service.model.cloudfront.Distribution d, Distribution.Method method) throws IOException, CloudFrontServiceException { // Retrieve distributions configuration to access current logging status settings. final DistributionConfig distributionConfig = this.getDistributionConfig(d); final String loggingTarget; if (null == distributionConfig.getLoggingStatus()) { // Default logging target to origin itself loggingTarget = ServiceUtils.findBucketNameInHostname( d.getConfig().getOrigin().getDomainName(), Protocol.S3_SSL.getDefaultHostname()); } else { loggingTarget = ServiceUtils.findBucketNameInHostname( distributionConfig.getLoggingStatus().getBucket(), Protocol.S3_SSL.getDefaultHostname()); } final Distribution distribution = new Distribution( d.getId(), distributionConfig.getEtag(), distributionConfig.getCallerReference(), d.getConfig().getOrigin().getDomainName(), method, d.getConfig().isEnabled(), d.isDeployed(), // CloudFront URL String.format("%s://%s%s", method.getScheme(), d.getDomainName(), method.getContext()), method.equals(Distribution.DOWNLOAD) || method.equals(Distribution.CUSTOM) ? String.format("https://%s%s", d.getDomainName(), method.getContext()) : null, // No SSL null, Locale.localizedString(d.getStatus(), "S3"), distributionConfig.getCNAMEs(), distributionConfig.getLoggingStatus().isEnabled(), loggingTarget, distributionConfig.getDefaultRootObject()); if (this.isInvalidationSupported(method)) { distribution.setInvalidationStatus(this.readInvalidationStatus(distribution)); } if (this.isLoggingSupported(method)) { distribution.setContainers(this.getContainers()); } return distribution; }