当前位置: 首页>>代码示例>>Java>>正文


Java FtpFileSystemConfigBuilder类代码示例

本文整理汇总了Java中org.apache.commons.vfs2.provider.ftp.FtpFileSystemConfigBuilder的典型用法代码示例。如果您正苦于以下问题:Java FtpFileSystemConfigBuilder类的具体用法?Java FtpFileSystemConfigBuilder怎么用?Java FtpFileSystemConfigBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FtpFileSystemConfigBuilder类属于org.apache.commons.vfs2.provider.ftp包,在下文中一共展示了FtpFileSystemConfigBuilder类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: WatchFTPRunner

import org.apache.commons.vfs2.provider.ftp.FtpFileSystemConfigBuilder; //导入依赖的package包/类
public WatchFTPRunner(FTPConfig config) {
    this.config = config;
    try { 
        fsManager = VFS.getManager();
       
        UserAuthenticator auth = new StaticUserAuthenticator("", config.getConnection().getUsername(), config.getConnection().getPassword()); 
        DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); 
        FtpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts,true);
        FtpFileSystemConfigBuilder.getInstance().setPassiveMode(opts, true);
       
        resolvedAbsPath = fsManager.resolveFile(config.getFolder() + config.getConnection().getPathtomonitor() , opts);
        
        log.info("Connection successfully established to " +  resolvedAbsPath.getPublicURIString());        
        log.debug("Exists: " + resolvedAbsPath.exists());
        log.debug("Type  : " + resolvedAbsPath.getType());       
    } catch (FileSystemException e) {
        log.error("File system exception for " + config.getFolder(), e);
        //throw here?
    }
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:21,代码来源:WatchFTPRunner.java

示例2: resolveFileObject

import org.apache.commons.vfs2.provider.ftp.FtpFileSystemConfigBuilder; //导入依赖的package包/类
/**
 * Returns a file representation
 *
 * @param filePath The file path
 * @return a file representation
 * @throws FileSystemException
 */
public static FileObject resolveFileObject(String filePath) throws FileSystemException {
  LOGGER.info("Resolving file: {}", filePath);
  if (filePath.startsWith("sftp://")) {
    SftpFileSystemConfigBuilder builder = SftpFileSystemConfigBuilder.getInstance();
    builder.setStrictHostKeyChecking(opts, "no");
    builder.setUserDirIsRoot(opts, false);
    builder.setCompression(opts, "zlib,none");

  } else if (filePath.startsWith("smb://")) {

  } else if (filePath.startsWith("ftp://")) {
    FtpFileSystemConfigBuilder.getInstance().setPassiveMode(opts, true);
  }
  UserAuthenticatorFactory factory = new UserAuthenticatorFactory();

  OtrosUserAuthenticator authenticator = factory.getUiUserAuthenticator(persistentAuthStore, sessionAuthStore, filePath, opts);

  if (pathContainsCredentials(filePath)) {
    authenticator = null;
  }
  return resolveFileObject(filePath, opts, authenticator, persistentAuthStore, sessionAuthStore);
}
 
开发者ID:otros-systems,项目名称:otroslogviewer,代码行数:30,代码来源:VFSUtils.java

示例3: createDefaultOptions

import org.apache.commons.vfs2.provider.ftp.FtpFileSystemConfigBuilder; //导入依赖的package包/类
/**
 * Get the default options for File system
 *
 * @return
 * @throws FileSystemException
 */
public static FileSystemOptions createDefaultOptions() throws FileSystemException {
    FileSystemOptions opts = new FileSystemOptions();

    // SSH Key checking
    SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts, "no");

    // Root directory set to user home
    SftpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, false);

    // Timeout is count by Milliseconds

    SftpFileSystemConfigBuilder.getInstance().setTimeout(opts, 100000);

    FtpFileSystemConfigBuilder.getInstance().setPassiveMode(opts, true);

    FtpFileSystemConfigBuilder.getInstance().setSoTimeout(opts, 100000);

    FtpsFileSystemConfigBuilder.getInstance().setPassiveMode(opts, true);

    return opts;

}
 
开发者ID:wso2-extensions,项目名称:esb-connector-file,代码行数:29,代码来源:FTPSiteUtils.java

示例4: createStorageProvider

import org.apache.commons.vfs2.provider.ftp.FtpFileSystemConfigBuilder; //导入依赖的package包/类
@Override
public StorageProvider createStorageProvider(Map<String, ? extends Object> properties) {
	String ftpUrl = normalize(properties);
	
	try {
		FileSystemManager fsManager = VFS.getManager();
		FileSystemOptions opts = new FileSystemOptions();
		FtpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, false);
		FileObject fileObject = fsManager.resolveFile(ftpUrl, opts);
		
		boolean createDirectory = getBoolean(properties, FtpStorage.CREATE_DIRECTORY_PROPERTY, false);
		
		fsManager.getFilesCache().clear(fileObject.getFileSystem());
		if (!fileObject.exists()) {
			if (createDirectory) {
				fileObject.createFolder();
			} else {
				throw new StorageException("The given base path does not resolve to an existing directory: " + ftpUrl);
			}
		}
		
		if (fileObject.getType() != FileType.FOLDER) {
			throw new StorageException("The given base path does not resolve to an existing directory: " + ftpUrl);
		}
		
		// TODO: Maybe try to create a little test object so we can self check if writing is allowed
		boolean supportsWriting = true;
		
		return new FtpStorageProvider(fileObject, supportsWriting);
	} catch (FileSystemException ex) {
		throw new StorageException("Could not connect to the ftp storage at: " + ftpUrl, ex);
	}
}
 
开发者ID:Blazebit,项目名称:blaze-storage,代码行数:34,代码来源:FtpStorageProviderFactory.java

示例5: VFSClientConnectorImpl

import org.apache.commons.vfs2.provider.ftp.FtpFileSystemConfigBuilder; //导入依赖的package包/类
public VFSClientConnectorImpl(Map<String, String> connectorConfig,
                              RemoteFileSystemListener remoteFileSystemListener) {
    this.connectorConfig = connectorConfig;
    this.remoteFileSystemListener = remoteFileSystemListener;

    if (Constants.PROTOCOL_FTP.equals(connectorConfig.get(Constants.PROTOCOL))) {
        connectorConfig.forEach((property, value) -> {
            // TODO: Add support for other FTP related configurations
            if (Constants.FTP_PASSIVE_MODE.equals(property)) {
                FtpFileSystemConfigBuilder.getInstance().setPassiveMode(opts, Boolean.parseBoolean(value));
            }
        });
    }
}
 
开发者ID:wso2,项目名称:carbon-transports,代码行数:15,代码来源:VFSClientConnectorImpl.java

示例6: RemoteFileSystemConsumer

import org.apache.commons.vfs2.provider.ftp.FtpFileSystemConfigBuilder; //导入依赖的package包/类
/**
 * Constructor for the RemoteFileSystemConsumer.
 *
 * @param id                Name of the service that creates the consumer
 * @param fileProperties    Map of property values
 * @param listener  RemoteFileSystemListener instance to send callback
 * @throws RemoteFileSystemConnectorException if unable to start the connect to the remote server
 */
public RemoteFileSystemConsumer(String id, Map<String, String> fileProperties, RemoteFileSystemListener listener)
        throws RemoteFileSystemConnectorException {
    this.serviceName = id;
    this.fileProperties = fileProperties;
    this.remoteFileSystemListener = listener;
    setupParams();
    try {
        fsManager = VFS.getManager();
        Map<String, String> options = parseSchemeFileOptions(listeningDirURI);
        fso = FileTransportUtils.attachFileSystemOptions(options, fsManager);
        // TODO: Make this and other file related configurations configurable
        if (options != null && Constants.SCHEME_FTP.equals(options.get(Constants.SCHEME))) {
            FtpFileSystemConfigBuilder.getInstance().setPassiveMode(fso, true);
        }
        listeningDir = fsManager.resolveFile(listeningDirURI, fso);
        if (!listeningDir.isWriteable()) {
            postProcessAction = Constants.ACTION_NONE;
        }
        FileType fileType = getFileType(listeningDir);
        if (fileType != FileType.FOLDER) {
            String errorMsg = "[" + serviceName + "] File system server connector is used to " +
                    "listen to a folder. But the given path does not refer to a folder.";
            final RemoteFileSystemConnectorException exception
                    = new RemoteFileSystemConnectorException(errorMsg);
            remoteFileSystemListener.onError(exception);
            throw exception;
        }
        //Initialize the thread executor based on properties
        threadPool = new ThreadPoolFactory(threadPoolSize);
    } catch (FileSystemException e) {
        remoteFileSystemListener.onError(e);
        throw new RemoteFileSystemConnectorException("[" + serviceName + "] Unable to initialize " +
                "the connection with server.", e);
    }
}
 
开发者ID:wso2,项目名称:carbon-transports,代码行数:44,代码来源:RemoteFileSystemConsumer.java

示例7: init

import org.apache.commons.vfs2.provider.ftp.FtpFileSystemConfigBuilder; //导入依赖的package包/类
@Override
public Object init(CarbonMessage cMsg, CarbonCallback callback, Map<String, Object> properties)
        throws ClientConnectorException {
    //TODO: Handle FS options configuration for other protocols as well
    if (Constants.PROTOCOL_FTP.equals(properties.get("PROTOCOL"))) {
        properties.forEach((property, value) -> {
            // TODO: Add support for other FTP related configurations
            if (Constants.FTP_PASSIVE_MODE.equals(property)) {
                FtpFileSystemConfigBuilder.getInstance().setPassiveMode(opts, (Boolean) value);
            }
        });
    }

    return Boolean.TRUE;
}
 
开发者ID:wso2,项目名称:carbon-transports,代码行数:16,代码来源:VFSClientConnector.java

示例8: FileToFtpCommandHandler

import org.apache.commons.vfs2.provider.ftp.FtpFileSystemConfigBuilder; //导入依赖的package包/类
public FileToFtpCommandHandler(String ftpPath) {
    this.ftpPath = ftpPath;
    FtpFileSystemConfigBuilder builder = FtpFileSystemConfigBuilder.getInstance();
    FileSystemOptions opts = new FileSystemOptions();
    builder.setPassiveMode(opts, true);
    builder.setUserDirIsRoot(opts, true);
    try {
        this.fileSystemManager = VFS.getManager();
    } catch (FileSystemException e) {
        LOGGER.error("failed create fileSystemManager");
        throw new RuntimeException("failed create fileSystemManager");
    }
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:14,代码来源:FileToFtpCommandHandler.java

示例9: execute

import org.apache.commons.vfs2.provider.ftp.FtpFileSystemConfigBuilder; //导入依赖的package包/类
@Override
public void execute() {
    FtpFileSystemConfigBuilder builder = FtpFileSystemConfigBuilder.getInstance();
    FileSystemOptions opts = new FileSystemOptions();
    builder.setPassiveMode(opts, true);
    builder.setUserDirIsRoot(opts, true);
    try {
        FileSystemManager fileSystemManager = VFS.getManager();
        dest.copyFrom(src, Selectors.SELECT_SELF);
        System.out.println("upload " + src.getName().getBaseName());
    } catch (FileSystemException e) {
        e.printStackTrace();
    }
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:15,代码来源:FileUploadCommand.java

示例10: testFileObject

import org.apache.commons.vfs2.provider.ftp.FtpFileSystemConfigBuilder; //导入依赖的package包/类
@Test
public void testFileObject() throws IOException {
    FtpFileSystemConfigBuilder builder = FtpFileSystemConfigBuilder.getInstance();
    FileSystemOptions opts = new FileSystemOptions();
    builder.setPassiveMode(opts, true);
    builder.setUserDirIsRoot(opts, true);
    FileSystemManager fileSystemManager = VFS.getManager();

    FileObject srcFolder = fileSystemManager.resolveFile("file://f:/camelinaction-master");
    if (!FileType.FOLDER.equals(srcFolder.getType())) {
        throw new IllegalArgumentException("源路径必须是文件夹");
    }
    FileObject destFile = fileSystemManager.resolveFile("ftp://10.4.14.14/temp/zyz/", opts);
    destFile.copyFrom(srcFolder, Selectors.EXCLUDE_SELF);
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:16,代码来源:FileObjectTest.java

示例11: getBaseTestFolder

import org.apache.commons.vfs2.provider.ftp.FtpFileSystemConfigBuilder; //导入依赖的package包/类
/**
 * Returns the base folder for tests.
 */
@Override
public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception
{
    final String uri = System.getProperty(TEST_URI);
    FileSystemOptions opts = new FileSystemOptions();
    FtpFileSystemConfigBuilder.getInstance().setPassiveMode(opts, true);
    return manager.resolveFile(uri, opts);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:12,代码来源:FtpProviderTestCase.java

示例12: authSetup

import org.apache.commons.vfs2.provider.ftp.FtpFileSystemConfigBuilder; //导入依赖的package包/类
@Override
public final void authSetup(final ConnectionDescription description, final FileSystemOptions options) throws FileSystemException {
	String username = description.getParameter(ConnectionDescription.PARAMETER_USERNAME);
	String password = description.getSecretParameter(ConnectionDescription.PARAMETER_PASSWORD);
	StaticUserAuthenticator auth = new StaticUserAuthenticator(null, username, password);
	FtpFileSystemConfigBuilder.getInstance().setPassiveMode(options, true);
	DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth);
}
 
开发者ID:fullsync,项目名称:fullsync,代码行数:9,代码来源:FTPAuthenticationProvider.java


注:本文中的org.apache.commons.vfs2.provider.ftp.FtpFileSystemConfigBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。