@Override protected List<DescriptiveUrl> getURLs(final Path selected) { final ArrayList<DescriptiveUrl> list = new ArrayList<DescriptiveUrl>(); final SessionPool pool = this.getSession(); final UrlProvider provider = pool.getFeature(UrlProvider.class); if(provider != null) { list.addAll(provider.toUrl(selected)); } final DistributionConfiguration feature = pool.getFeature(DistributionConfiguration.class); if(feature != null) { list.addAll(feature.toUrl(selected)); } return list; }
private void write(final DistributionConfiguration feature, final Path file) throws BackgroundException { feature.write(file, configuration, prompt); }
@Override protected Map<Path, Distribution> operate(final PasswordCallback callback, final Path file) throws BackgroundException { final DistributionConfiguration feature = session.getFeature(DistributionConfiguration.class); if(null == feature) { return Collections.emptyMap(); } final AttributedList<Path> containers = new SwiftContainerListService(session, new SwiftLocationFeature.SwiftRegion(session.getHost().getRegion())).list(file, new DisabledListProgressListener()); final Map<Path, Distribution> distributions = new ConcurrentHashMap<>(); for(Path container : containers) { for(Distribution.Method method : feature.getMethods(container)) { final Distribution distribution = feature.read(container, method, new DisabledLoginCallback()); if(log.isInfoEnabled()) { log.info(String.format("Cache distribution %s", distribution)); } distributions.put(container, distribution); } } return distributions; } }
@Override public Distribution run(final Session<?> session) throws BackgroundException { final DistributionConfiguration cdn = session.getFeature(DistributionConfiguration.class); for(Path file : this.getContainers(files)) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } final Distribution distribution = cdn.read(file, method, prompt); if(cdn.getFeature(Index.class, distribution.getMethod()) != null) { // Make sure container items are cached for default root object. distribution.setRootDocuments(session.getFeature(ListService.class).list(containerService.getContainer(file), new DisabledListProgressListener()).toList()); } return distribution; } return this.initialize(); }
final DistributionConfiguration cdn = session.getFeature(DistributionConfiguration.class); distributionEnableButton.setTitle(MessageFormat.format(LocaleFactory.localizedString("Enable {0} Distribution", "Status"), cdn.getName(distribution.getMethod()))); distributionEnableButton.setState(distribution.isEnabled() ? NSCell.NSOnState : NSCell.NSOffState); distributionStatusField.setAttributedStringValue(NSMutableAttributedString.create(distribution.getStatus(), TRUNCATE_MIDDLE_ATTRIBUTES)); final AnalyticsProvider analyticsFeature = cdn.getFeature(AnalyticsProvider.class, method); final IdentityConfiguration identityFeature = cdn.getFeature(IdentityConfiguration.class, method); if(analyticsFeature != null && identityFeature != null) { final Credentials credentials = identityFeature.getCredentials(analyticsFeature.getName()); if(credentials != null) { distributionAnalyticsSetupUrlField.setAttributedStringValue( HyperlinkAttributedStringFactory.create(analyticsFeature.getSetup(cdn.getHostname(), distribution.getMethod().getScheme(), file, credentials)) ); final DescriptiveUrl origin = cdn.toUrl(file).find(DescriptiveUrl.Type.origin); if(!origin.equals(DescriptiveUrl.EMPTY)) { distributionOriginField.setAttributedStringValue(HyperlinkAttributedStringFactory.create(origin)); final DescriptiveUrl url = cdn.toUrl(file).find(DescriptiveUrl.Type.cdn); if(!url.equals(DescriptiveUrl.EMPTY)) { distributionUrlField.setAttributedStringValue(HyperlinkAttributedStringFactory.create(url)); final DescriptiveUrl url = cdn.toUrl(file).find(DescriptiveUrl.Type.cname); if(!url.equals(DescriptiveUrl.EMPTY)) { if(cdn.getFeature(Index.class, distribution.getMethod()) != null) {
cdn.getName())); distributionDeliveryPopup.removeItemWithTitle(LocaleFactory.localizedString("None")); for(Distribution.Method method : cdn.getMethods(file)) { distributionDeliveryPopup.addItemWithTitle(method.toString()); distributionDeliveryPopup.itemWithTitle(method.toString()).setRepresentedObject(method.toString()); if(null == distributionDeliveryPopup.selectedItem()) { Distribution.Method method = cdn.getMethods(file).iterator().next(); distributionDeliveryPopup.selectItemWithTitle(method.toString());
@Override public Boolean run(final Session<?> session) throws BackgroundException { final DistributionConfiguration cdn = session.getFeature(DistributionConfiguration.class); final Purge feature = cdn.getFeature(Purge.class, method); for(Path file : this.getContainers(files)) { if(this.isCanceled()) { throw new ConnectionCanceledException(); } feature.invalidate(file, method, files, prompt); } return true; }
@Override protected Map<Path, Distribution> operate(final PasswordCallback callback, final Path file) throws BackgroundException { final DistributionConfiguration feature = session.getFeature(DistributionConfiguration.class); if(null == feature) { return Collections.emptyMap(); } final AttributedList<Path> containers = new S3BucketListService(session, new S3LocationFeature.S3Region(session.getHost().getRegion())).list(file, new DisabledListProgressListener()); final Map<Path, Distribution> distributions = new ConcurrentHashMap<>(); for(Path container : containers) { for(Distribution.Method method : feature.getMethods(container)) { if(Distribution.WEBSITE.equals(method)) { continue; } if(Distribution.WEBSITE_CDN.equals(method)) { continue; } final Distribution distribution = feature.read(container, method, new DisabledLoginCallback()); if(distribution.isEnabled()) { if(log.isInfoEnabled()) { log.info(String.format("Cache distribution %s", distribution)); } distributions.put(container, distribution); } } } return distributions; } }
distributionEnableButton.setEnabled(stop && enable); distributionDeliveryPopup.setEnabled(stop && enable); distributionLoggingButton.setEnabled(stop && enable && cdn.getFeature(DistributionLogging.class, method) != null); if(enable) { final AnalyticsProvider analyticsFeature = cdn.getFeature(AnalyticsProvider.class, method); final IdentityConfiguration identityFeature = cdn.getFeature(IdentityConfiguration.class, method); if(null == analyticsFeature || null == identityFeature) { distributionAnalyticsButton.setEnabled(false); distributionAnalyticsButton.setEnabled(false); distributionLoggingPopup.setEnabled(stop && enable && cdn.getFeature(DistributionLogging.class, method) != null); distributionCnameField.setEnabled(stop && enable && cdn.getFeature(Cname.class, method) != null); distributionInvalidateObjectsButton.setEnabled(stop && enable && cdn.getFeature(Purge.class, method) != null); distributionDefaultRootPopup.setEnabled(stop && enable && cdn.getFeature(Index.class, method) != null); if(stop) { distributionProgress.stopAnimation(null);
@Override protected List<DescriptiveUrl> getURLs(final Path selected) { final ArrayList<DescriptiveUrl> list = new ArrayList<DescriptiveUrl>(); final SessionPool pool = this.getSession(); final UrlProvider provider = pool.getFeature(UrlProvider.class); if(provider != null) { list.addAll(provider.toUrl(selected).filter( DescriptiveUrl.Type.http, DescriptiveUrl.Type.cname, DescriptiveUrl.Type.cdn, DescriptiveUrl.Type.signed, DescriptiveUrl.Type.authenticated, DescriptiveUrl.Type.torrent)); } final DistributionConfiguration feature = pool.getFeature(DistributionConfiguration.class); if(feature != null) { list.addAll(feature.toUrl(selected)); } return list; }