Search in sources :

Example 6 with DescriptiveUrlBag

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"))));
}
Also used : Path(ch.cyberduck.core.Path) TestProtocol(ch.cyberduck.core.TestProtocol) DescriptiveUrl(ch.cyberduck.core.DescriptiveUrl) DescriptiveUrlBag(ch.cyberduck.core.DescriptiveUrlBag) Host(ch.cyberduck.core.Host) Test(org.junit.Test)

Example 7 with DescriptiveUrlBag

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();
    }
}
Also used : Path(ch.cyberduck.core.Path) DescriptiveUrl(ch.cyberduck.core.DescriptiveUrl) HostUrlProvider(ch.cyberduck.core.HostUrlProvider) DescriptiveUrlBag(ch.cyberduck.core.DescriptiveUrlBag) BackgroundException(ch.cyberduck.core.exception.BackgroundException)

Example 8 with DescriptiveUrlBag

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;
}
Also used : DescriptiveUrl(ch.cyberduck.core.DescriptiveUrl) HostUrlProvider(ch.cyberduck.core.HostUrlProvider) DescriptiveUrlBag(ch.cyberduck.core.DescriptiveUrlBag)

Example 9 with DescriptiveUrlBag

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());
}
Also used : Path(ch.cyberduck.core.Path) DescriptiveUrl(ch.cyberduck.core.DescriptiveUrl) DescriptiveUrlBag(ch.cyberduck.core.DescriptiveUrlBag) Host(ch.cyberduck.core.Host) Test(org.junit.Test)

Example 10 with DescriptiveUrlBag

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());
}
Also used : Path(ch.cyberduck.core.Path) DescriptiveUrl(ch.cyberduck.core.DescriptiveUrl) DescriptiveUrlBag(ch.cyberduck.core.DescriptiveUrlBag) Host(ch.cyberduck.core.Host) Test(org.junit.Test)

Aggregations

DescriptiveUrlBag (ch.cyberduck.core.DescriptiveUrlBag)17 DescriptiveUrl (ch.cyberduck.core.DescriptiveUrl)16 Path (ch.cyberduck.core.Path)7 Test (org.junit.Test)6 Host (ch.cyberduck.core.Host)5 HostUrlProvider (ch.cyberduck.core.HostUrlProvider)5 HostWebUrlProvider (ch.cyberduck.core.HostWebUrlProvider)3 Distribution (ch.cyberduck.core.cdn.Distribution)3 DistributionUrlProvider (ch.cyberduck.core.cdn.DistributionUrlProvider)3 DefaultUrlProvider (ch.cyberduck.core.shared.DefaultUrlProvider)3 SimplePathPredicate (ch.cyberduck.core.SimplePathPredicate)2 TestProtocol (ch.cyberduck.core.TestProtocol)2 BackgroundException (ch.cyberduck.core.exception.BackgroundException)2 HostPreferences (ch.cyberduck.core.preferences.HostPreferences)2 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)2 AccountInfo (ch.iterate.openstack.swift.model.AccountInfo)2 Region (ch.iterate.openstack.swift.model.Region)2 Map (java.util.Map)2 Set (java.util.Set)2 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)1