public static SessionPool create(final Controller controller, final Cache<Path> cache, final Host bookmark, final ProgressListener listener, final Usage... usage) { return create(cache, bookmark, PasswordStoreFactory.get(), LoginCallbackFactory.get(controller), HostKeyCallbackFactory.get(controller, bookmark.getProtocol()), listener, controller, usage); }
@Override public String get(final Host bookmark) { switch(bookmark.getProtocol().getScheme()) { case sftp: return super.get(Scheme.ftp, bookmark.getPort(), bookmark.getCredentials().getUsername(), bookmark.getHostname(), bookmark.getDefaultPath()); } return super.get(bookmark); } }
public OAuth2RequestInterceptor(final HttpClient client, final Host host) { this(client, Scheme.isURL(host.getProtocol().getOAuthTokenUrl()) ? host.getProtocol().getOAuthTokenUrl() : new HostUrlProvider().withUsername(false).withPath(true).get( host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getOAuthTokenUrl()), Scheme.isURL(host.getProtocol().getOAuthAuthorizationUrl()) ? host.getProtocol().getOAuthAuthorizationUrl() : new HostUrlProvider().withUsername(false).withPath(true).get( host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getOAuthAuthorizationUrl()), host.getProtocol().getOAuthClientId(), host.getProtocol().getOAuthClientSecret(), host.getProtocol().getOAuthScopes()); }
@Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); final DescriptiveUrl base = this.toUrl(); list.add(new DescriptiveUrl(URI.create(String.format("%s%s", base.getUrl(), URIEncoder.encode( PathNormalizer.normalize(PathRelativizer.relativize(PathNormalizer.normalize(host.getDefaultPath(), true), file.getAbsolute())) ))).normalize(), base.getType(), base.getHelp()) ); return list; }
@Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { if(file.attributes().getLink() != null) { list.add(file.attributes().getLink()); } } return list; } }
/** * @param source Source file or folder * @param target Target file or folder * @return False if not supported for given files */ default boolean isSupported(Path source, Path target) { return target.getParent().attributes().getPermission().isWritable(); }
@Override public Acl getPermission(final Path file) { if(containerService.isContainer(file)) { return containerService.getContainer(file).attributes().getAcl(); } return Acl.EMPTY; }
@Override protected int compareFirst(final Path p1, final Path p2) { if(p1.attributes().getSize() > p2.attributes().getSize()) { return ascending ? 1 : -1; } else if(p1.attributes().getSize() < p2.attributes().getSize()) { return ascending ? -1 : 1; } return 0; } }
/** * @param workdir Working directory in browser * @param name Folder name or null if unknown * @return True if creating directory will succeed */ default boolean isSupported(Path workdir, String name) { return workdir.attributes().getPermission().isWritable(); }
@Override protected String help() { return ProviderHelpServiceFactory.get().help(host.getProtocol()); } }
@Override public boolean test(final Path test) { if(test.attributes().isDuplicate()) { // Ignore trashed files return false; } return super.test(test); } }
private <T> T connected(final Connected<T> run, final LoginCallback prompt) throws BackgroundException { new LoginConnectionService(prompt, new DisabledHostKeyCallback(), PasswordStoreFactory.get(), new DisabledProgressListener()) .check(session, PathCache.empty(), new DisabledCancelCallback()); return run.call(); }
public boolean isValid(final T reference) { if(this.isCached(reference)) { return !this.get(reference).attributes().isInvalid(); } return false; }
@Override public void collectionItemChanged(final Host bookmark) { this.save(bookmark); super.collectionItemChanged(bookmark); }
@Override public void collectionItemChanged(final Transfer transfer) { try { this.save(transfer); } finally { super.collectionItemChanged(transfer); } }
/** * @return URL */ public String get(final Host bookmark) { final Scheme scheme = bookmark.getProtocol().getScheme(); final int port = bookmark.getPort(); final String username = bookmark.getCredentials().getUsername(); final String hostname = bookmark.getHostname(); final String path = bookmark.getDefaultPath(); return this.get(scheme, port, username, hostname, path); }
@Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.attributes().getLink() != null) { list.add(file.attributes().getLink()); } return list; } }
/** * @param workdir Working directory * @return True if creating an empty file is possible. */ default boolean isSupported(Path workdir) { return workdir.attributes().getPermission().isWritable(); }