public int compareTo(Object o) { FileSystemKey fk = (FileSystemKey) o; int ret = key.compareTo(fk.key); if (ret != 0) { // other filesystem return ret; } return fileSystemOptions.compareTo(fk.fileSystemOptions); } }
protected Object getParam(FileSystemOptions opts, String name) { if (opts == null) { return null; } return opts.getOption(getConfigClass(), name); }
protected boolean hasParam(FileSystemOptions opts, String name) { if (opts == null) { return false; } return opts.hasOption(getConfigClass(), name); }
protected void sendFiles() { if (fileInfoByTable.size() > 0) { try { String sftpUri = buildUri(); FileSystemOptions opts = new FileSystemOptions(); FtpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, true); SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts, "no"); SftpFileSystemConfigBuilder.getInstance().setTimeout(opts, 60000); Collection<FileInfo> fileInfos = fileInfoByTable.values(); for (FileInfo fileInfo : fileInfos) { FileObject fileObject = manager.resolveFile( sftpUri + "/" + fileInfo.outputFile.getName(), opts); FileObject localFileObject = manager.resolveFile(fileInfo.outputFile .getAbsolutePath()); fileObject.copyFrom(localFileObject, Selectors.SELECT_SELF); fileObject.close(); } } catch (FileSystemException e) { logger.warn("If you have not configured your ftp connection it should be configured in conf/ftp-extensions.xml"); throw new IoException(e); } catch (Exception e) { throw new IoException(e); } finally { manager.close(); } } }
protected void setParam(FileSystemOptions opts, String name, Object value) { opts.setOption(getConfigClass(), name, value); }
protected void login() throws TinkException, IOException { URI location = getConfig().getRemote(); StaticUserAuthenticator auth = new StaticUserAuthenticator(null, getConfig().getUser(), getConfig().getPassword()); FileSystemOptions opts = new FileSystemOptions(); FtpFileSystemConfigBuilder.getInstance().setPassiveMode(opts, true); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); remote = VFS.getManager().resolveFile(location.toString(), opts); }