Exemplo n.º 1
0
 public static FileObject resolveFile(String fileUri, UserAuthenticator userAuthenticator)
     throws FileSystemException {
   FileSystemOptions opts = null;
   if (VFS.getManager().getBaseFile() != null) {
     opts = VFS.getManager().getBaseFile().getFileSystem().getFileSystemOptions();
   }
   if (opts == null) {
     opts = new FileSystemOptions();
   }
   DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, userAuthenticator);
   FileObject file = resolveFile(fileUri, opts);
   return file;
 }
Exemplo n.º 2
0
 protected AbstractFileSystem(
     final FileName rootName,
     final FileObject parentLayer,
     final FileSystemOptions fileSystemOptions) {
   // this.parentLayer = parentLayer;
   this.parentLayer = parentLayer;
   this.rootName = rootName;
   this.fileSystemOptions = fileSystemOptions;
   FileSystemConfigBuilder builder = DefaultFileSystemConfigBuilder.getInstance();
   String uri = builder.getRootURI(fileSystemOptions);
   if (uri == null) {
     uri = rootName.getURI();
   }
   this.rootURI = uri;
 }
Exemplo n.º 3
0
 public FileObject connectAndChangeToWorkDir() throws FileSystemException {
   StaticUserAuthenticator auth =
       new StaticUserAuthenticator(null, ftpConfig.getUsername(), ftpConfig.getPassword());
   FileSystemOptions opts = new FileSystemOptions();
   switch (ftpConfig.getType()) {
     case FTP:
       FtpFileSystemConfigBuilder.getInstance().setSoTimeout(opts, SOCKET_TIMEOUT);
       FtpFileSystemConfigBuilder.getInstance().setDataTimeout(opts, DATA_TIMEOUT);
       FtpFileSystemConfigBuilder.getInstance().setConnectTimeout(opts, CONNET_TIMEOUT);
       break;
     case FTPS:
       FtpsFileSystemConfigBuilder.getInstance().setSoTimeout(opts, SOCKET_TIMEOUT);
       FtpsFileSystemConfigBuilder.getInstance().setDataTimeout(opts, DATA_TIMEOUT);
       FtpsFileSystemConfigBuilder.getInstance().setConnectTimeout(opts, CONNET_TIMEOUT);
       break;
     case SFTP:
       SftpFileSystemConfigBuilder.getInstance().setTimeout(opts, SOCKET_TIMEOUT);
       break;
   }
   DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth);
   FileObject fo = VFS.getManager().resolveFile(connectionString, opts);
   LOG.info("connected at {} #{}", connectionString, ftpConfig.getId());
   return fo;
 }