Example usage for org.apache.commons.vfs2.util DelegatingFileSystemOptionsBuilder DelegatingFileSystemOptionsBuilder

List of usage examples for org.apache.commons.vfs2.util DelegatingFileSystemOptionsBuilder DelegatingFileSystemOptionsBuilder

Introduction

In this page you can find the example usage for org.apache.commons.vfs2.util DelegatingFileSystemOptionsBuilder DelegatingFileSystemOptionsBuilder.

Prototype

public DelegatingFileSystemOptionsBuilder(final FileSystemManager manager) 

Source Link

Document

Constructor.
Pass in your fileSystemManager instance.

Usage

From source file:org.apache.synapse.commons.vfs.VFSUtils.java

public static FileSystemOptions attachFileSystemOptions(Map<String, String> options,
        FileSystemManager fsManager)/*  w  ww .  j  a  v  a 2s  . c  o m*/
        throws FileSystemException, InstantiationException, IllegalAccessException {
    if (options == null) {
        return null;
    }

    FileSystemOptions opts = new FileSystemOptions();
    DelegatingFileSystemOptionsBuilder delegate = new DelegatingFileSystemOptionsBuilder(fsManager);

    if (VFSConstants.SCHEME_SFTP.equals(options.get(VFSConstants.SCHEME))) {
        for (String key : options.keySet()) {
            for (VFSConstants.SFTP_FILE_OPTION o : VFSConstants.SFTP_FILE_OPTION.values()) {
                if (key.equals(o.toString()) && null != options.get(key)) {
                    delegate.setConfigString(opts, VFSConstants.SCHEME_SFTP, key.toLowerCase(),
                            options.get(key));
                }
            }
        }
    }

    return opts;
}

From source file:org.wso2.carbon.transport.file.connector.server.util.FileTransportUtils.java

public static FileSystemOptions attachFileSystemOptions(Map<String, String> options,
        FileSystemManager fsManager) throws FileServerConnectorException {
    if (options == null) {
        return null; //returning null as this is not an errorneous case.
    }/*from   w w w  .j  a v  a2 s  .c  o  m*/
    FileSystemOptions opts = new FileSystemOptions();
    DelegatingFileSystemOptionsBuilder delegate = new DelegatingFileSystemOptionsBuilder(fsManager);
    if (Constants.SCHEME_SFTP.equals(options.get(Constants.SCHEME))) {
        Iterator itr = options.entrySet().iterator();

        while (itr.hasNext()) {
            Map.Entry<String, String> entry = (Map.Entry<String, String>) itr.next();
            Constants.SftpFileOption[] array = Constants.SftpFileOption.values();
            int length = array.length;

            for (int i = 0; i < length; ++i) {
                Constants.SftpFileOption option = array[i];
                if (entry.getKey().equals(option.toString()) && null != entry.getValue()) {
                    try {
                        delegate.setConfigString(opts, Constants.SCHEME_SFTP,
                                entry.getKey().toLowerCase(Locale.US), entry.getValue());
                    } catch (FileSystemException e) {
                        throw new FileServerConnectorException(
                                "Failed to set file transport configuration for scheme: "
                                        + Constants.SCHEME_SFTP + " and option: " + option.toString(),
                                e);
                    }
                }
            }
        }
    }
    if (options.get(Constants.FILE_TYPE) != null) {
        try {
            delegate.setConfigString(opts, options.get(Constants.SCHEME), Constants.FILE_TYPE,
                    String.valueOf(getFileType(options.get(Constants.FILE_TYPE))));
        } catch (FileSystemException e) {
            throw new FileServerConnectorException("Failed to set file transport configuration for scheme: "
                    + options.get(Constants.SCHEME) + " and option: " + Constants.FILE_TYPE, e);
        }
    }
    return opts;
}

From source file:org.wso2.carbon.transport.filesystem.connector.server.util.FileTransportUtils.java

/**
 * A utility method for setting the relevant configurations for the file system in question
 *
 * @param options   Options to be used with the file system manager
 * @param fsManager File system manager instance
 * @return A FileSystemOptions instance/*from   www.  j  av  a 2 s .c  om*/
 * @throws FileSystemServerConnectorException   Throws an exception if there are any issues in configuring the
 *                                              connector
 */
public static FileSystemOptions attachFileSystemOptions(Map<String, String> options,
        FileSystemManager fsManager) throws FileSystemServerConnectorException {
    if (options == null) {
        return null; //returning null as this is not an errorneous case.
    }
    FileSystemOptions opts = new FileSystemOptions();
    DelegatingFileSystemOptionsBuilder delegate = new DelegatingFileSystemOptionsBuilder(fsManager);
    if (Constants.SCHEME_SFTP.equals(options.get(Constants.SCHEME))) {
        Iterator itr = options.entrySet().iterator();

        while (itr.hasNext()) {
            Map.Entry<String, String> entry = (Map.Entry<String, String>) itr.next();
            Constants.SftpFileOption[] array = Constants.SftpFileOption.values();
            int length = array.length;

            for (int i = 0; i < length; ++i) {
                Constants.SftpFileOption option = array[i];
                if (entry.getKey().equals(option.toString()) && null != entry.getValue()) {
                    try {
                        delegate.setConfigString(opts, Constants.SCHEME_SFTP,
                                entry.getKey().toLowerCase(Locale.US), entry.getValue());
                    } catch (FileSystemException e) {
                        throw new FileSystemServerConnectorException(
                                "Failed to set file transport configuration for scheme: "
                                        + Constants.SCHEME_SFTP + " and option: " + option.toString(),
                                e);
                    }
                }
            }
        }
    }
    if (options.get(Constants.FILE_TYPE) != null) {
        try {
            delegate.setConfigString(opts, options.get(Constants.SCHEME), Constants.FILE_TYPE,
                    String.valueOf(getFileType(options.get(Constants.FILE_TYPE))));
        } catch (FileSystemException e) {
            throw new FileSystemServerConnectorException(
                    "Failed to set file transport configuration for scheme: " + options.get(Constants.SCHEME)
                            + " and option: " + Constants.FILE_TYPE,
                    e);
        }
    }
    return opts;
}

From source file:org.wso2.carbon.transport.remotefilesystem.server.util.FileTransportUtils.java

/**
 * A utility method for setting the relevant configurations for the file system in question
 *
 * @param options   Options to be used with the file system manager
 * @param fsManager File system manager instance
 * @return A FileSystemOptions instance/*ww w  .j a v  a2 s. c o  m*/
 * @throws RemoteFileSystemConnectorException   Throws an exception if there are any issues in configuring the
 *                                              connector
 */
public static FileSystemOptions attachFileSystemOptions(Map<String, String> options,
        FileSystemManager fsManager) throws RemoteFileSystemConnectorException {
    if (options == null) {
        return null; //returning null as this is not an erroneous case.
    }
    FileSystemOptions opts = new FileSystemOptions();
    DelegatingFileSystemOptionsBuilder delegate = new DelegatingFileSystemOptionsBuilder(fsManager);
    if (Constants.SCHEME_SFTP.equals(options.get(Constants.SCHEME))) {
        Constants.SftpFileOption[] array = Constants.SftpFileOption.values();
        outer: for (Constants.SftpFileOption fileOption : array) {
            for (Map.Entry<String, String> entry : options.entrySet()) {
                if (entry.getValue() != null && entry.getKey().equals(fileOption.toString())) {
                    try {
                        delegate.setConfigString(opts, Constants.SCHEME_SFTP,
                                entry.getKey().toLowerCase(Locale.getDefault()), entry.getValue());
                        continue outer;
                    } catch (FileSystemException e) {
                        throw new RemoteFileSystemConnectorException(
                                "Failed to set file transport configuration for scheme: "
                                        + Constants.SCHEME_SFTP + " and option: " + fileOption.toString(),
                                e);
                    }
                }
            }
        }
    }
    if (options.get(Constants.FILE_TYPE) != null) {
        try {
            delegate.setConfigString(opts, options.get(Constants.SCHEME), Constants.FILE_TYPE,
                    String.valueOf(getFileType(options.get(Constants.FILE_TYPE))));
        } catch (FileSystemException e) {
            throw new RemoteFileSystemConnectorException(
                    "Failed to set file transport configuration for scheme: " + options.get(Constants.SCHEME)
                            + " and option: " + Constants.FILE_TYPE,
                    e);
        }
    }
    return opts;
}