use of ch.cyberduck.core.DescriptiveUrlBag in project cyberduck by iterate-ch.
the class CustomSchemeUrlProviderTest method testCustomSchemes.
@Test
public void testCustomSchemes() {
Host host = new Host(new TestProtocol() {
public String[] getSchemes() {
return new String[] { "c1", "c2" };
}
}, "localhost");
Path path = new Path("/file", EnumSet.of(Path.Type.file));
final DescriptiveUrlBag list = new CustomSchemeUrlProvider(host).toUrl(path).filter(DescriptiveUrl.Type.provider);
assertEquals(2, list.size());
assertTrue(list.contains(new DescriptiveUrl(URI.create("c1://localhost/file"))));
assertTrue(list.contains(new DescriptiveUrl(URI.create("c2://localhost/file"))));
}
use of ch.cyberduck.core.DescriptiveUrlBag in project cyberduck by iterate-ch.
the class CryptoUrlProvider method toUrl.
@Override
public DescriptiveUrlBag toUrl(final Path file) {
try {
final DescriptiveUrlBag set = delegate.toUrl(file);
final Path encrypt = vault.encrypt(session, file);
set.add(new DescriptiveUrl(URI.create(String.format("%s%s", new HostUrlProvider().withUsername(false).get(session.getHost()), URIEncoder.encode(encrypt.getAbsolute()))), DescriptiveUrl.Type.encrypted, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), LocaleFactory.localizedString("Encrypted", "Cryptomator"))));
return set;
} catch (BackgroundException e) {
log.warn(String.format("Failure encrypting filename. %s", e.getMessage()));
return DescriptiveUrlBag.empty();
}
}
use of ch.cyberduck.core.DescriptiveUrlBag in project cyberduck by iterate-ch.
the class DropboxUrlProvider method toUrl.
@Override
public DescriptiveUrlBag toUrl(final Path file) {
final DescriptiveUrlBag list = new DescriptiveUrlBag();
list.add(new DescriptiveUrl(URI.create(String.format("%s/home%s", new HostUrlProvider().withUsername(false).get(session.getHost()), URIEncoder.encode(file.getAbsolute()))), DescriptiveUrl.Type.http, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), session.getHost().getProtocol().getScheme().toString().toUpperCase(Locale.ROOT))));
return list;
}
use of ch.cyberduck.core.DescriptiveUrlBag in project cyberduck by iterate-ch.
the class FreenetUrlProviderTest method testToUrlFile.
@Test
public void testToUrlFile() {
final FreenetUrlProvider provider = new FreenetUrlProvider(new Host(new FreenetProtocol(), "dav.freenet.de", 443, "/webdav"));
final DescriptiveUrlBag urls = provider.toUrl(new Path("/webdav/d/f", EnumSet.of(Path.Type.file)));
assertEquals(1, urls.size());
final DescriptiveUrl url = urls.find(DescriptiveUrl.Type.http);
assertNotEquals(DescriptiveUrl.EMPTY, url);
assertEquals(DescriptiveUrl.Type.http, url.getType());
assertEquals("https://webmail.freenet.de/web/?goTo=share&path=/d#cloud", url.getUrl());
}
use of ch.cyberduck.core.DescriptiveUrlBag in project cyberduck by iterate-ch.
the class FreenetUrlProviderTest method testToUrlRoot.
@Test
public void testToUrlRoot() {
final FreenetUrlProvider provider = new FreenetUrlProvider(new Host(new FreenetProtocol(), "dav.freenet.de", 443, "/webdav"));
final DescriptiveUrlBag urls = provider.toUrl(new Path("/webdav", EnumSet.of(Path.Type.directory)));
assertEquals(1, urls.size());
final DescriptiveUrl url = urls.find(DescriptiveUrl.Type.http);
assertNotEquals(DescriptiveUrl.EMPTY, url);
assertEquals(DescriptiveUrl.Type.http, url.getType());
assertEquals("https://webmail.freenet.de/web/?goTo=share&path=/#cloud", url.getUrl());
}
Aggregations