@Test public void testGet() throws Exception { final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume)); container.attributes().setRegion("IAD"); assertEquals("https: new SwiftUrlProvider(session).toUrl(new Path(container, "f", EnumSet.of(Path.Type.file))).find(DescriptiveUrl.Type.provider).getUrl()); }
@Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { Region region = null; try { region = regionService.lookup(file); } catch(BackgroundException e) { log.warn(String.format("Failure looking up region for %s %s", file, e.getMessage())); } if(null == region) { list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file)); } else { list.addAll(new WebUrlProvider(session.getHost()).toUrl(file)); list.add(new DescriptiveUrl( URI.create(region.getStorageUrl(containerService.getContainer(file).getName(), containerService.getKey(file)).toString()), DescriptiveUrl.Type.provider, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), session.getHost().getProtocol().getScheme().name().toUpperCase(Locale.ROOT)) )); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.HOURS.toSeconds(1)))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.SECONDS.toSeconds( PreferencesFactory.get().getInteger("s3.url.expire.seconds"))))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.DAYS.toSeconds(7)))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.DAYS.toSeconds(30)))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.DAYS.toSeconds(365)))); } } return list; }
SwiftUrlProvider implements UrlProvider { @Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { Region region = null; try { region = regionService.lookup(file); } catch(BackgroundException e) { log.warn(String.format("Failure looking up region for %s %s", file, e.getMessage())); } if(null == region) { list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file)); } else { list.addAll(new WebUrlProvider(session.getHost()).toUrl(file)); list.add(new DescriptiveUrl( URI.create(region.getStorageUrl(containerService.getContainer(file).getName(), containerService.getKey(file)).toString()), DescriptiveUrl.Type.provider, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), session.getHost().getProtocol().getScheme().name().toUpperCase(Locale.ROOT)) )); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.HOURS.toSeconds(1)))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.SECONDS.toSeconds( PreferencesFactory.get().getInteger("s3.url.expire.seconds"))))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.DAYS.toSeconds(7)))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.DAYS.toSeconds(30)))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.DAYS.toSeconds(365)))); } } return list; } }
SwiftUrlProvider implements UrlProvider { @Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { Region region = null; try { region = regionService.lookup(file); } catch(BackgroundException e) { log.warn(String.format("Failure looking up region for %s %s", file, e.getMessage())); } if(null == region) { list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file)); } else { list.addAll(new WebUrlProvider(session.getHost()).toUrl(file)); list.add(new DescriptiveUrl( URI.create(region.getStorageUrl(containerService.getContainer(file).getName(), containerService.getKey(file)).toString()), DescriptiveUrl.Type.provider, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), session.getHost().getProtocol().getScheme().name().toUpperCase(Locale.ROOT)) )); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.HOURS.toSeconds(1)))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.SECONDS.toSeconds( PreferencesFactory.get().getInteger("s3.url.expire.seconds"))))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.DAYS.toSeconds(7)))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.DAYS.toSeconds(30)))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.DAYS.toSeconds(365)))); } } return list; } SwiftUrlProvider(final SwiftSession session);  SwiftUrlProvider(final SwiftSession session, final Map<Region, AccountInfo> accounts);  SwiftUrlProvider(final SwiftSession session, final Map<Region, AccountInfo> accounts, final SwiftRegionService regionService); }
SwiftUrlProvider implements UrlProvider { @Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { Region region = null; try { region = regionService.lookup(file); } catch(BackgroundException e) { log.warn(String.format("Failure looking up region for %s %s", file, e.getMessage())); } if(null == region) { list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file)); } else { list.addAll(new WebUrlProvider(session.getHost()).toUrl(file)); list.add(new DescriptiveUrl( URI.create(region.getStorageUrl(containerService.getContainer(file).getName(), containerService.getKey(file)).toString()), DescriptiveUrl.Type.provider, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), session.getHost().getProtocol().getScheme().name().toUpperCase(Locale.ROOT)) )); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.HOURS.toSeconds(1)))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.SECONDS.toSeconds( PreferencesFactory.get().getInteger("s3.url.expire.seconds"))))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.DAYS.toSeconds(7)))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.DAYS.toSeconds(30)))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.DAYS.toSeconds(365)))); } } return list; } SwiftUrlProvider(final SwiftSession session);  SwiftUrlProvider(final SwiftSession session, final Map<Region, AccountInfo> accounts);  SwiftUrlProvider(final SwiftSession session, final Map<Region, AccountInfo> accounts, final SwiftRegionService regionService); @Override DescriptiveUrlBag toUrl(final Path file); }
SwiftUrlProvider implements UrlProvider { @Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { Region region = null; try { region = regionService.lookup(file); } catch(BackgroundException e) { log.warn(String.format("Failure looking up region for %s %s", file, e.getMessage())); } if(null == region) { list.addAll(new DefaultUrlProvider(session.getHost()).toUrl(file)); } else { list.addAll(new WebUrlProvider(session.getHost()).toUrl(file)); list.add(new DescriptiveUrl( URI.create(region.getStorageUrl(containerService.getContainer(file).getName(), containerService.getKey(file)).toString()), DescriptiveUrl.Type.provider, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), session.getHost().getProtocol().getScheme().name().toUpperCase(Locale.ROOT)) )); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.HOURS.toSeconds(1)))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.SECONDS.toSeconds( PreferencesFactory.get().getInteger("s3.url.expire.seconds"))))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.DAYS.toSeconds(7)))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.DAYS.toSeconds(30)))); list.addAll(this.sign(region, file, this.getExpiry((int) TimeUnit.DAYS.toSeconds(365)))); } } return list; } SwiftUrlProvider(final SwiftSession session);  SwiftUrlProvider(final SwiftSession session, final Map<Region, AccountInfo> accounts);  SwiftUrlProvider(final SwiftSession session, final Map<Region, AccountInfo> accounts, final SwiftRegionService regionService); @Override DescriptiveUrlBag toUrl(final Path file);  }