@Test public void testWriteNewDownload() throws Exception { final AtomicBoolean set = new AtomicBoolean(); final CloudFrontDistributionConfiguration configuration = new CloudFrontDistributionConfiguration(session, new DisabledX509TrustManager(), new DefaultX509KeyManager(), Collections.emptyMap()) { @Override protected UpdateDistributionResult updateDownloadDistribution(final Path container, final Distribution distribution) { fail(); return null; } @Override protected com.amazonaws.services.cloudfront.model.Distribution createDownloadDistribution(final Path container, final Distribution distribution) { set.set(true); return new com.amazonaws.services.cloudfront.model.Distribution().withId(""); } }; final Path container = new Path(UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory, Path.Type.volume)); final Distribution distribution = new Distribution(Distribution.DOWNLOAD, true); configuration.write(container, distribution, new DisabledLoginCallback()); assertTrue(set.get()); }
@Override public void write(final Path file, final Distribution distribution, final LoginCallback prompt) throws BackgroundException { final Path container = containerService.getContainer(file); this.authenticated(new Authenticated<Void>() { @Override public Void call() throws BackgroundException { try { if(null == distribution.getId()) { if(log.isDebugEnabled()) { log.debug(String.format("No existing distribution found for method %s", distribution.getMethod())); } if(distribution.getMethod().equals(Distribution.STREAMING)) { distribution.setId(createStreamingDistribution(container, distribution).getId()); } else if(distribution.getMethod().equals(Distribution.DOWNLOAD)) { distribution.setId(createDownloadDistribution(container, distribution).getId()); } else if(distribution.getMethod().equals(Distribution.CUSTOM) || distribution.getMethod().equals(Distribution.WEBSITE_CDN)) { distribution.setId(createCustomDistribution(container, distribution).getId()); } } else { if(distribution.getMethod().equals(Distribution.DOWNLOAD)) { distribution.setEtag(updateDownloadDistribution(container, distribution).getETag()); } else if(distribution.getMethod().equals(Distribution.STREAMING)) { distribution.setEtag(updateStreamingDistribution(container, distribution).getETag()); } else if(distribution.getMethod().equals(Distribution.CUSTOM) || distribution.getMethod().equals(Distribution.WEBSITE_CDN)) { distribution.setEtag(updateCustomDistribution(container, distribution).getETag()); } } } catch(AmazonClientException e) { throw new AmazonServiceExceptionMappingService().map("Cannot write CDN configuration", e); } return null; } }, prompt); }
CloudFrontDistributionConfiguration implements DistributionConfiguration, Purge, Index, DistributionLogging, Cname { @Override public void write(final Path file, final Distribution distribution, final LoginCallback prompt) throws BackgroundException { final Path container = containerService.getContainer(file); this.authenticated(new Authenticated<Void>() { @Override public Void call() throws BackgroundException { try { if(null == distribution.getId()) { if(log.isDebugEnabled()) { log.debug(String.format("No existing distribution found for method %s", distribution.getMethod())); } if(distribution.getMethod().equals(Distribution.STREAMING)) { distribution.setId(createStreamingDistribution(container, distribution).getId()); } else if(distribution.getMethod().equals(Distribution.DOWNLOAD)) { distribution.setId(createDownloadDistribution(container, distribution).getId()); } else if(distribution.getMethod().equals(Distribution.CUSTOM) || distribution.getMethod().equals(Distribution.WEBSITE_CDN)) { distribution.setId(createCustomDistribution(container, distribution).getId()); } } else { if(distribution.getMethod().equals(Distribution.DOWNLOAD)) { distribution.setEtag(updateDownloadDistribution(container, distribution).getETag()); } else if(distribution.getMethod().equals(Distribution.STREAMING)) { distribution.setEtag(updateStreamingDistribution(container, distribution).getETag()); } else if(distribution.getMethod().equals(Distribution.CUSTOM) || distribution.getMethod().equals(Distribution.WEBSITE_CDN)) { distribution.setEtag(updateCustomDistribution(container, distribution).getETag()); } } } catch(AmazonClientException e) { throw new AmazonServiceExceptionMappingService().map("Cannot write CDN configuration", e); } return null; } }, prompt); } }
CloudFrontDistributionConfiguration implements DistributionConfiguration, Purge, Index, DistributionLogging, Cname { @Override public void write(final Path file, final Distribution distribution, final LoginCallback prompt) throws BackgroundException { final Path container = containerService.getContainer(file); this.authenticated(new Authenticated<Void>() { @Override public Void call() throws BackgroundException { try { if(null == distribution.getId()) { if(log.isDebugEnabled()) { log.debug(String.format("No existing distribution found for method %s", distribution.getMethod())); } if(distribution.getMethod().equals(Distribution.STREAMING)) { distribution.setId(createStreamingDistribution(container, distribution).getId()); } else if(distribution.getMethod().equals(Distribution.DOWNLOAD)) { distribution.setId(createDownloadDistribution(container, distribution).getId()); } else if(distribution.getMethod().equals(Distribution.CUSTOM) || distribution.getMethod().equals(Distribution.WEBSITE_CDN)) { distribution.setId(createCustomDistribution(container, distribution).getId()); } } else { if(distribution.getMethod().equals(Distribution.DOWNLOAD)) { distribution.setEtag(updateDownloadDistribution(container, distribution).getETag()); } else if(distribution.getMethod().equals(Distribution.STREAMING)) { distribution.setEtag(updateStreamingDistribution(container, distribution).getETag()); } else if(distribution.getMethod().equals(Distribution.CUSTOM) || distribution.getMethod().equals(Distribution.WEBSITE_CDN)) { distribution.setEtag(updateCustomDistribution(container, distribution).getETag()); } } } catch(AmazonClientException e) { throw new AmazonServiceExceptionMappingService().map("Cannot write CDN configuration", e); } return null; } }, prompt); } CloudFrontDistributionConfiguration(final S3Session session, final X509TrustManager trust, final X509KeyManager key,
                                               final Map<Path, Distribution> distributions); }
CloudFrontDistributionConfiguration implements DistributionConfiguration, Purge, Index, DistributionLogging, Cname { @Override public void write(final Path file, final Distribution distribution, final LoginCallback prompt) throws BackgroundException { final Path container = containerService.getContainer(file); this.authenticated(new Authenticated<Void>() { @Override public Void call() throws BackgroundException { try { if(null == distribution.getId()) { if(log.isDebugEnabled()) { log.debug(String.format("No existing distribution found for method %s", distribution.getMethod())); } if(distribution.getMethod().equals(Distribution.STREAMING)) { distribution.setId(createStreamingDistribution(container, distribution).getId()); } else if(distribution.getMethod().equals(Distribution.DOWNLOAD)) { distribution.setId(createDownloadDistribution(container, distribution).getId()); } else if(distribution.getMethod().equals(Distribution.CUSTOM) || distribution.getMethod().equals(Distribution.WEBSITE_CDN)) { distribution.setId(createCustomDistribution(container, distribution).getId()); } } else { if(distribution.getMethod().equals(Distribution.DOWNLOAD)) { distribution.setEtag(updateDownloadDistribution(container, distribution).getETag()); } else if(distribution.getMethod().equals(Distribution.STREAMING)) { distribution.setEtag(updateStreamingDistribution(container, distribution).getETag()); } else if(distribution.getMethod().equals(Distribution.CUSTOM) || distribution.getMethod().equals(Distribution.WEBSITE_CDN)) { distribution.setEtag(updateCustomDistribution(container, distribution).getETag()); } } } catch(AmazonClientException e) { throw new AmazonServiceExceptionMappingService().map("Cannot write CDN configuration", e); } return null; } }, prompt); } CloudFrontDistributionConfiguration(final S3Session session, final X509TrustManager trust, final X509KeyManager key,
                                               final Map<Path, Distribution> distributions); @Override String getName(); @Override String getName(final Distribution.Method method); @Override String getHostname(); @Override DescriptiveUrlBag toUrl(final Path file); @Override List<Distribution.Method> getMethods(final Path container); @Override Distribution read(final Path file, final Distribution.Method method, final LoginCallback prompt); @Override void write(final Path file, final Distribution distribution, final LoginCallback prompt); @Override @SuppressWarnings("unchecked") T getFeature(final Class<T> type, final Distribution.Method method); @Override void invalidate(final Path container, final Distribution.Method method, final List<Path> files, final LoginCallback prompt); }
CloudFrontDistributionConfiguration implements DistributionConfiguration, Purge, Index, DistributionLogging, Cname { @Override public void write(final Path file, final Distribution distribution, final LoginCallback prompt) throws BackgroundException { final Path container = containerService.getContainer(file); this.authenticated(new Authenticated<Void>() { @Override public Void call() throws BackgroundException { try { if(null == distribution.getId()) { if(log.isDebugEnabled()) { log.debug(String.format("No existing distribution found for method %s", distribution.getMethod())); } if(distribution.getMethod().equals(Distribution.STREAMING)) { distribution.setId(createStreamingDistribution(container, distribution).getId()); } else if(distribution.getMethod().equals(Distribution.DOWNLOAD)) { distribution.setId(createDownloadDistribution(container, distribution).getId()); } else if(distribution.getMethod().equals(Distribution.CUSTOM) || distribution.getMethod().equals(Distribution.WEBSITE_CDN)) { distribution.setId(createCustomDistribution(container, distribution).getId()); } } else { if(distribution.getMethod().equals(Distribution.DOWNLOAD)) { distribution.setEtag(updateDownloadDistribution(container, distribution).getETag()); } else if(distribution.getMethod().equals(Distribution.STREAMING)) { distribution.setEtag(updateStreamingDistribution(container, distribution).getETag()); } else if(distribution.getMethod().equals(Distribution.CUSTOM) || distribution.getMethod().equals(Distribution.WEBSITE_CDN)) { distribution.setEtag(updateCustomDistribution(container, distribution).getETag()); } } } catch(AmazonClientException e) { throw new AmazonServiceExceptionMappingService().map("Cannot write CDN configuration", e); } return null; } }, prompt); } CloudFrontDistributionConfiguration(final S3Session session, final X509TrustManager trust, final X509KeyManager key,
                                               final Map<Path, Distribution> distributions); @Override String getName(); @Override String getName(final Distribution.Method method); @Override String getHostname(); @Override DescriptiveUrlBag toUrl(final Path file); @Override List<Distribution.Method> getMethods(final Path container); @Override Distribution read(final Path file, final Distribution.Method method, final LoginCallback prompt); @Override void write(final Path file, final Distribution distribution, final LoginCallback prompt); @Override @SuppressWarnings("unchecked") T getFeature(final Class<T> type, final Distribution.Method method); @Override void invalidate(final Path container, final Distribution.Method method, final List<Path> files, final LoginCallback prompt);  }