@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) {
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;
}
}