@Override public Distribution initialize() { return new Distribution(method, false); }
@Override public DescriptiveUrlBag toUrl(final Path file) { final Distribution distribution = new Distribution(URI.create(String.format("%s://%s.%s", Distribution.DOWNLOAD.getScheme(), containerService.getContainer(file).getName(), this.getHostname())), Distribution.DOWNLOAD, false); distribution.setUrl(URI.create(String.format("%s://%s.%s", Distribution.DOWNLOAD.getScheme(), containerService.getContainer(file).getName(), this.getHostname()))); return new DistributionUrlProvider(distribution).toUrl(file); }
@Override public Distribution read(final Path container, final Distribution.Method method, final LoginCallback prompt) throws BackgroundException { if(method.equals(Distribution.WEBSITE)) { try { final WebsiteConfig configuration = session.getClient().getWebsiteConfig(container.getName()); final Distribution distribution = new Distribution(this.getOrigin(container, method), method, configuration.isWebsiteConfigActive()); distribution.setStatus(LocaleFactory.localizedString("Deployed", "S3")); // http://example-bucket.s3-website-us-east-1.amazonaws.com/ distribution.setUrl(URI.create(String.format("%s://%s", method.getScheme(), this.getWebsiteHostname(container)))); distribution.setIndexDocument(configuration.getIndexDocumentSuffix()); distribution.setContainers(new S3BucketListService(session, new S3LocationFeature.S3Region(session.getHost().getRegion())).list( new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory)), new DisabledListProgressListener()).toList()); return distribution; } catch(ServiceException e) { // Not found. Website configuration not enabled. final Distribution distribution = new Distribution(this.getOrigin(container, method), method, false); distribution.setStatus(e.getErrorMessage()); distribution.setUrl(URI.create(String.format("%s://%s", method.getScheme(), this.getWebsiteHostname(container)))); return distribution; } } else { return super.read(container, method, prompt); } }
return new Distribution(origin, method, false);
@Override public Distribution read(final Path file, final Distribution.Method method, final LoginCallback prompt) throws BackgroundException { final Path container = containerService.getContainer(file); final URI origin = URI.create(String.format("%s://%s.%s", method.getScheme(), container.getName(), this.getHostname())); try { final WebsiteConfig configuration = session.getClient().getWebsiteConfigImpl(container.getName()); final Distribution distribution = new Distribution( origin, method, configuration.isWebsiteConfigActive()); distribution.setUrl(URI.create(String.format("%s://%s.%s", method.getScheme(), container.getName(), this.getHostname()))); distribution.setStatus(LocaleFactory.localizedString("Deployed", "S3")); distribution.setIndexDocument(configuration.getIndexDocumentSuffix()); final DistributionLogging logging = this.getFeature(DistributionLogging.class, method); if(logging != null) { final LoggingConfiguration c = new GoogleStorageLoggingFeature(session).getConfiguration(container); distribution.setLogging(c.isEnabled()); distribution.setLoggingContainer(c.getLoggingTarget()); 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(ServiceException e) { // Not found. Website configuration is disabled. final Distribution distribution = new Distribution(origin, method, false); distribution.setStatus(e.getErrorMessage()); distribution.setUrl(URI.create(String.format("%s://%s.%s", method.getScheme(), container.getName(), this.getHostname()))); return distribution; } }
final CDNContainer info = session.getClient().getCDNContainerInfo(regionService.lookup(container), container.getName()); final Distribution distribution = new Distribution(regionService.lookup(container).getStorageUrl(container.getName()), method, info.isEnabled()); distribution.setId(info.getName()); log.debug(String.format("No CDN configuration for %s", container)); final Distribution distribution = new Distribution(regionService.lookup(container).getStorageUrl(container.getName()), method, false); distribution.setStatus(LocaleFactory.localizedString("CDN Disabled", "Mosso")); return distribution;
final GetStreamingDistributionConfigResult response = client.getStreamingDistributionConfig(new GetStreamingDistributionConfigRequest(summary.getId())); final StreamingDistributionConfig configuration = response.getStreamingDistributionConfig(); final Distribution distribution = new Distribution(this.getOrigin(container, method), method, summary.isEnabled()); distribution.setId(summary.getId()); distribution.setDeployed("Deployed".equals(summary.getStatus()));
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()));
@Action public void distributionApplyButtonClicked(final ID sender) { if(this.toggleDistributionSettings(false)) { final Distribution.Method method = Distribution.Method.forName(distributionDeliveryPopup.selectedItem().representedObject()); final Distribution configuration = new Distribution(method, distributionEnableButton.state() == NSCell.NSOnState); configuration.setIndexDocument(distributionDefaultRootPopup.selectedItem().representedObject()); configuration.setLogging(distributionLoggingButton.state() == NSCell.NSOnState); configuration.setLoggingContainer(distributionLoggingPopup.selectedItem().representedObject()); configuration.setCNAMEs(StringUtils.split(distributionCnameField.stringValue())); controller.background(new WorkerBackgroundAction<Boolean>(controller, session, new WriteDistributionWorker(files, prompt, configuration) { @Override public void cleanup(final Boolean result) { // Refresh the current distribution status distributionStatusButtonClicked(sender); } })); } }