Example usage for org.apache.commons.vfs2 Selectors SELECT_CHILDREN

List of usage examples for org.apache.commons.vfs2 Selectors SELECT_CHILDREN

Introduction

In this page you can find the example usage for org.apache.commons.vfs2 Selectors SELECT_CHILDREN.

Prototype

FileSelector SELECT_CHILDREN

To view the source code for org.apache.commons.vfs2 Selectors SELECT_CHILDREN.

Click Source Link

Document

A FileSelector that selects only the direct children of the base folder.

Usage

From source file:com.collective.celos.ci.mode.test.TestRunCelosServerModeEmbedded.java

public void copyRemoteDefaultsToLocal(String username, URI defaultsDirUri)
        throws URISyntaxException, FileSystemException {
    JScpWorker worker = new JScpWorker(username);
    if (defaultsDirUri != null) {
        FileObject remoteDefaultsDir = worker.getFileObjectByUri(defaultsDirUri);
        if (remoteDefaultsDir.exists()) {
            FileObject localDefaultsDir = worker.getFileObjectByUri(getCelosDefaultsDir());
            localDefaultsDir.copyFrom(remoteDefaultsDir, Selectors.SELECT_CHILDREN);
        }/*from w  ww .j  ava2s  .c o m*/
    }
}

From source file:org.ow2.proactive_grid_cloud_portal.dataspace.FileSystem.java

public static ListFile list(FileObject fo, List<String> includes, List<String> excludes)
        throws FileSystemException {
    fo.refresh();/* w  ww .  j  a va2  s .  c  o m*/
    ListFile answer = new ListFile();
    List<String> dirList = Lists.newArrayList();
    List<String> fileList = Lists.newArrayList();
    List<String> fullList = Lists.newArrayList();
    List<FileObject> foundFileObjects = new LinkedList<>();
    if (isNullOrEmpty(includes) && isNullOrEmpty(excludes)) {
        fo.findFiles(Selectors.SELECT_CHILDREN, false, foundFileObjects);
    } else {
        FileSelector selector = new org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector(
                includes, excludes);
        fo.findFiles(selector, false, foundFileObjects);
    }

    for (FileObject child : foundFileObjects) {
        FileType type = child.getType();
        FileName childName = child.getName();
        switch (type) {
        case FOLDER:
            if (!child.equals(fo)) {
                // exclude root directory from the list
                String relativePath = fo.getName().getRelativeName(childName);
                dirList.add(relativePath);
                fullList.add(relativePath);
            }
            break;
        case FILE:
            String relativePath = fo.getName().getRelativeName(childName);
            fileList.add(relativePath);
            fullList.add(relativePath);
            break;
        default:
            throw new RuntimeException("Unknown : " + type);
        }
    }
    Collections.sort(dirList);
    Collections.sort(fileList);
    Collections.sort(fullList);
    answer.setDirectoryListing(dirList);
    answer.setFileListing(fileList);
    answer.setFullListing(fullList);
    return answer;
}