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


Java StandardFileSystemManager类代码示例

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


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

示例1: moveFileWithPattern

import org.apache.commons.vfs2.impl.StandardFileSystemManager; //导入依赖的package包/类
/**
 * @param remoteFile     Location of the file
 * @param destination    New file location
 * @param filePattern    Pattern of the file
 * @param manager        Standard file system manager
 * @param messageContext The message context that is generated for processing the file
 * @throws IOException
 */
private void moveFileWithPattern(FileObject remoteFile, String destination, String filePattern,
                                 StandardFileSystemManager manager, MessageContext messageContext) throws IOException {
    FilePattenMatcher patternMatcher = new FilePattenMatcher(filePattern);
    try {
        if (patternMatcher.validate(remoteFile.getName().getBaseName())) {
            FileObject file = manager.resolveFile(destination, FileConnectorUtils.init(messageContext));
            if (!file.exists()) {
                file.createFolder();
            }
            file = manager.resolveFile(destination + File.separator + remoteFile.getName().getBaseName(),
                    FileConnectorUtils.init(messageContext));
            remoteFile.moveTo(file);
        }
    } catch (IOException e) {
        log.error("Error occurred while moving a file. " + e.getMessage(), e);
    }
}
 
开发者ID:wso2-extensions,项目名称:esb-connector-file,代码行数:26,代码来源:FileMove.java

示例2: copy

import org.apache.commons.vfs2.impl.StandardFileSystemManager; //导入依赖的package包/类
/**
 * @param source      file location
 * @param destination target file location
 * @param filePattern pattern of the file
 * @param opts        FileSystemOptions
 * @throws IOException
 */
private void copy(FileObject source, String destination, String filePattern, FileSystemOptions opts)
        throws IOException {
    StandardFileSystemManager manager = FileConnectorUtils.getManager();
    FileObject souFile = manager.resolveFile(String.valueOf(source), opts);
    FilePattenMatcher patternMatcher = new FilePattenMatcher(filePattern);
    try {
        if (patternMatcher.validate(source.getName().getBaseName())) {
            String name = source.getName().getBaseName();
            FileObject outFile = manager.resolveFile(destination + File.separator + name, opts);
            outFile.copyFrom(souFile, Selectors.SELECT_ALL);
        }
    } catch (IOException e) {
        log.error("Error occurred while copying a file. " + e.getMessage(), e);
    } finally {
        manager.close();
    }
}
 
开发者ID:wso2-extensions,项目名称:esb-connector-file,代码行数:25,代码来源:FileCopy.java

示例3: initializeStandardFileSystemManager

import org.apache.commons.vfs2.impl.StandardFileSystemManager; //导入依赖的package包/类
private StandardFileSystemManager initializeStandardFileSystemManager()
{
    if (!logger.isDebugEnabled()) {
        // TODO: change logging format: org.apache.commons.logging.Log
        System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
    }
    StandardFileSystemManager manager = new StandardFileSystemManager();
    manager.setClassLoader(SftpUtils.class.getClassLoader());
    try {
        manager.init();
    }
    catch (FileSystemException e) {
        logger.error(e.getMessage());
        throw new ConfigException(e);
    }

    return manager;
}
 
开发者ID:embulk,项目名称:embulk-output-sftp,代码行数:19,代码来源:SftpUtils.java

示例4: getFileSystemManager

import org.apache.commons.vfs2.impl.StandardFileSystemManager; //导入依赖的package包/类
/**
 * Returns the global filesystem manager
 *
 * @return the global filesystem manager
 */
public static FileSystemManager getFileSystemManager() {
  aLock.readLock().lock();

  try {
    if (fileSystemManager == null) {
      try {
        StandardFileSystemManager fm = new StandardFileSystemManager();
        fm.setCacheStrategy(CacheStrategy.MANUAL);
        fm.init();
        LOGGER.info("Supported schemes: {} ", Joiner.on(", ").join(fm.getSchemes()));
        fileSystemManager = fm;
      } catch (Exception exc) {
        throw new RuntimeException(exc);
      }
    }

    return fileSystemManager;
  } finally {
    aLock.readLock().unlock();
  }
}
 
开发者ID:otros-systems,项目名称:otroslogviewer,代码行数:27,代码来源:VFSUtils.java

示例5: moveFile

import org.apache.commons.vfs2.impl.StandardFileSystemManager; //导入依赖的package包/类
/**
 * Move the files
 *
 * @param source      Location of the file
 * @param destination Destination of the file
 * @return return a resultStatus
 */
private boolean moveFile(String source, String destination, MessageContext messageContext,
                         boolean includeParentDirectory, String filePattern) {
    boolean resultStatus = false;
    StandardFileSystemManager manager = null;
    try {
        manager = FileConnectorUtils.getManager();
        // Create remote object
        FileObject remoteFile = manager.resolveFile(source, FileConnectorUtils.init(messageContext));
        if (remoteFile.exists()) {
            if (remoteFile.getType() == FileType.FILE) {
                fileMove(destination, remoteFile, messageContext, manager);
            } else {
                folderMove(source, destination, filePattern, includeParentDirectory, messageContext, manager);
            }
            resultStatus = true;
            if (log.isDebugEnabled()) {
                log.debug("File move completed from " + source + " to " + destination);
            }
        } else {
            log.error("The file/folder location does not exist.");
            resultStatus = false;
        }
    } catch (IOException e) {
        handleException("Unable to move a file/folder.", e, messageContext);
    } finally {
        if (manager != null) {
            manager.close();
        }
    }
    return resultStatus;
}
 
开发者ID:wso2-extensions,项目名称:esb-connector-file,代码行数:39,代码来源:FileMove.java

示例6: fileMove

import org.apache.commons.vfs2.impl.StandardFileSystemManager; //导入依赖的package包/类
/**
 * Move the file
 *
 * @param destination    New location of the folder
 * @param remoteFile     Location of the file
 * @param messageContext The message context that is processed by a handler in the handle method
 * @param manager        Standard file system manager
 */
private void fileMove(String destination, FileObject remoteFile, MessageContext messageContext,
                      StandardFileSystemManager manager) throws IOException {
    FileObject file = manager.resolveFile(destination, FileConnectorUtils.init(messageContext));
    if (FileConnectorUtils.isFolder(file)) {
        if (!file.exists()) {
            file.createFolder();
        }
        file = manager.resolveFile(destination + File.separator + remoteFile.getName().getBaseName(),
                FileConnectorUtils.init(messageContext));
    } else if (!file.exists()) {
        file.createFile();
    }
    remoteFile.moveTo(file);
}
 
开发者ID:wso2-extensions,项目名称:esb-connector-file,代码行数:23,代码来源:FileMove.java

示例7: folderMove

import org.apache.commons.vfs2.impl.StandardFileSystemManager; //导入依赖的package包/类
/**
 * Move the folder
 *
 * @param destination            New location of the folder
 * @param source                 Location of the folder
 * @param messageContext         The message context that is processed by a handler in the handle method
 * @param includeParentDirectory Boolean type
 * @param manager                Standard file system manager
 */
private void folderMove(String source, String destination, String filePattern, boolean includeParentDirectory,
                        MessageContext messageContext, StandardFileSystemManager manager) throws IOException {
    FileObject remoteFile = manager.resolveFile(source, FileConnectorUtils.init(messageContext));
    FileObject file = manager.resolveFile(destination, FileConnectorUtils.init(messageContext));
    if (StringUtils.isNotEmpty(filePattern)) {
        FileObject[] children = remoteFile.getChildren();
        for (FileObject child : children) {
            if (child.getType() == FileType.FILE) {
                moveFileWithPattern(child, destination, filePattern, manager, messageContext);
            } else if (child.getType() == FileType.FOLDER) {
                String newSource = source + File.separator + child.getName().getBaseName();
                folderMove(newSource, destination, filePattern, includeParentDirectory, messageContext, manager);
            }
        }
    } else if (includeParentDirectory) {
        file = manager.resolveFile(destination + File.separator + remoteFile.getName().getBaseName(),
                FileConnectorUtils.init(messageContext));
        file.createFolder();
        remoteFile.moveTo(file);
    } else {
        if (!file.exists()) {
            file.createFolder();
        }
        remoteFile.moveTo(file);
        remoteFile.createFolder();
    }
}
 
开发者ID:wso2-extensions,项目名称:esb-connector-file,代码行数:37,代码来源:FileMove.java

示例8: fileSystemManager

import org.apache.commons.vfs2.impl.StandardFileSystemManager; //导入依赖的package包/类
protected FileSystemManager fileSystemManager() throws FileSystemException {
    StandardFileSystemManager fsManager = new StandardFileSystemManager();
    fsManager.setClassLoader(DefaultVfsHelper.class.getClassLoader());
    fsManager.init();

    return fsManager;
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:8,代码来源:DefaultVfsHelper.java

示例9: getStandardFileSystemManager

import org.apache.commons.vfs2.impl.StandardFileSystemManager; //导入依赖的package包/类
/**
 * Gets the standard file system manager.
 * 
 * @return the standard file system manager
 */
public StandardFileSystemManager getStandardFileSystemManager() {
    if (LOG.isDebugEnabled()) {
        LOG.debug("getStandardFileSystemManager() - entering");
    }

    if (LOG.isDebugEnabled()) {
        LOG.debug("getStandardFileSystemManager() - exiting");
    }
    return standardFileSystemManager;
}
 
开发者ID:clstoulouse,项目名称:motu,代码行数:16,代码来源:VFSManager.java

示例10: getFileSystemManager

import org.apache.commons.vfs2.impl.StandardFileSystemManager; //导入依赖的package包/类
/**
 * Returns the global filesystem manager
 * @return the global filesystem manager
 */
public static FileSystemManager getFileSystemManager()
{
    aLock.readLock().lock();

    try
    {
        if (fileSystemManager == null)
        {
            try
            {
                StandardFileSystemManager fm = new StandardFileSystemManager();
                fm.setCacheStrategy(CacheStrategy.MANUAL);
                fm.init();
                fileSystemManager = fm;
            }
            catch (Exception exc)
            {
                throw new RuntimeException(exc);
            }
        }

        return fileSystemManager;
    }
    finally
    {
        aLock.readLock().unlock();
    }
}
 
开发者ID:fracpete,项目名称:vfsjfilechooser2,代码行数:33,代码来源:VFSUtils.java

示例11: VfsTestHelper

import org.apache.commons.vfs2.impl.StandardFileSystemManager; //导入依赖的package包/类
public VfsTestHelper() throws Exception {
    // setup and initialize VFS
    fsManager = new StandardFileSystemManager() {
        protected void configurePlugins() throws FileSystemException {
            // disable automatic loading of potentially unsupported extensions
        }
    };
    fsManager.setConfiguration(getClass().getResource(VFS_CONF).toString());
    fsManager.init();

    // setup and initialize ivy
    ivy = new Ivy();
    ivy.configure(new File(IVY_CONFIG_FILE));
}
 
开发者ID:apache,项目名称:ant-ivy,代码行数:15,代码来源:VfsTestHelper.java

示例12: resolveFile

import org.apache.commons.vfs2.impl.StandardFileSystemManager; //导入依赖的package包/类
/**
 * Resolves a URI to a file, relative to the project's base directory.
 *
 * @param uri The URI to resolve.
 */
protected FileObject resolveFile(final String uri)
    throws FileSystemException
{
    if (manager == null)
    {
        StandardFileSystemManager mngr = new StandardFileSystemManager();
        mngr.setLogger(new AntLogger());
        mngr.init();
        manager = mngr;
        getProject().addBuildListener(new CloseListener());
    }
    return manager.resolveFile(getProject().getBaseDir(), uri);
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:19,代码来源:VfsTask.java

示例13: setUp

import org.apache.commons.vfs2.impl.StandardFileSystemManager; //导入依赖的package包/类
@Override
protected void setUp() throws Exception
{
    super.setUp();

    // get a full blown, fully functional manager
    fsm = new StandardFileSystemManager();
    fsm.init();
}
 
开发者ID:wso2,项目名称:wso2-commons-vfs,代码行数:10,代码来源:DelegatingFileSystemOptionsBuilderTest.java

示例14: newFileSystemManager

import org.apache.commons.vfs2.impl.StandardFileSystemManager; //导入依赖的package包/类
@Nonnull
private static FileSystemManager newFileSystemManager() throws FileSystemException {
    StandardFileSystemManager manager = new StandardFileSystemManager();
    manager.setCacheStrategy(CacheStrategy.MANUAL);
    manager.init();
    return manager;
}
 
开发者ID:shevek,项目名称:vfsjfilechooser,代码行数:8,代码来源:CommonsVfs2FileSystemView.java

示例15: setUp

import org.apache.commons.vfs2.impl.StandardFileSystemManager; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    SourceResolver a = new SourceResolver();
    SourceData data = a.resolveSource(getPath("binkd.cfg.simple1"), getPath("SQAFIX.cfg"), getPath("SQUISH.cfg"), getPath("dmtareas.ini.simple"), "2:5020/1042");

    Converter converter = new Converter();
    TargetData targetData = new TargetData();
    converter.convert(data, targetData);

    List<Link> items = Utils.getItems(targetData.asLinks());
    TestCase.assertEquals(9, items.size());

    Collections.sort(items, new Comparator<Link>() {
        @Override
        public int compare(Link o1, Link o2) {
            return o1.getPassword().compareTo(o2.getPassword());
        }
    });

    StandardFileSystemManager manager = new StandardFileSystemManager();
    manager.init();
    manager.resolveFile("ram://root/file2.txt").createFile();
    fo = manager.resolveFile("ram://root/file2.txt");
    OutputStream os = fo.getContent().getOutputStream();

    out = new OutputStreamWriter(os);

    root = new HashMap<>();
    root.put("links", items);

    List<Subscr> subscrs = Utils.getItems(targetData.asSubscr());
    Collections.sort(subscrs, new SubscrComparator());

    List<Subscr> filesubscrs = Utils.getItems(targetData.asFilesubscr());
    Collections.sort(filesubscrs, new SubscrComparator());

    List<EchoArea> areas = Utils.getItems(targetData.asAreas());
    Collections.sort(areas, new EchoAreaComparator());

    List<EchoArea> fileareas = Utils.getItems(targetData.asFileAreas());
    Collections.sort(areas, new EchoAreaComparator());

    root.put("mainuplink", targetData.getMainUplink());
    root.put("subscr", subscrs.subList(0, 5));
    root.put("filesubscr", filesubscrs);
    root.put("areas", areas.subList(0, 23));
    root.put("fileareas", fileareas);
}
 
开发者ID:Manjago,项目名称:jmigration,代码行数:49,代码来源:ExportTest.java


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