Example usage for org.apache.commons.io.filefilter HiddenFileFilter VISIBLE

List of usage examples for org.apache.commons.io.filefilter HiddenFileFilter VISIBLE

Introduction

In this page you can find the example usage for org.apache.commons.io.filefilter HiddenFileFilter VISIBLE.

Prototype

IOFileFilter VISIBLE

To view the source code for org.apache.commons.io.filefilter HiddenFileFilter VISIBLE.

Click Source Link

Document

Singleton instance of visible filter

Usage

From source file:org.sonar.plugins.web.api.ProjectFileManager.java

/**
 * Gets the list of files that are in scope for importing and analysis.
 *//*from  w  w  w. j av a 2  s  .  c o  m*/
public List<InputFile> getFiles() {
    List<InputFile> result = Lists.newArrayList();

    IOFileFilter suffixFilter = getFileSuffixFilter();
    WildcardPattern[] exclusionPatterns = getExclusionPatterns(true);
    IOFileFilter visibleFileFilter = HiddenFileFilter.VISIBLE;

    for (File dir : sourceDirs) {
        if (dir.exists()) {

            // exclusion filter
            IOFileFilter exclusionFilter = new ExclusionFilter(dir, exclusionPatterns);
            // visible filter
            List<IOFileFilter> fileFilters = Lists.newArrayList(visibleFileFilter, suffixFilter,
                    exclusionFilter);
            fileFilters.addAll(this.filters);

            // create DefaultInputFile for each file.
            List<File> files = (List<File>) FileUtils.listFiles(dir, new AndFileFilter(fileFilters),
                    HiddenFileFilter.VISIBLE);
            for (File file : files) {
                String relativePath = getRelativePath(file, dir);
                result.add(new WebInputFile(dir, relativePath));
            }
        }
    }
    return result;
}

From source file:org.sonar.plugins.xml.XmlProjectFileSystem.java

public List<InputFile> getFiles() {
    List<InputFile> result = Lists.newArrayList();
    if (getSourceDirs() == null) {
        return result;
    }//  w  ww  . j  av  a  2s  .  c om

    IOFileFilter suffixFilter = getFileSuffixFilter();
    WildcardPattern[] exclusionPatterns = getExclusionPatterns(true);
    IOFileFilter visibleFileFilter = HiddenFileFilter.VISIBLE;

    for (File dir : getSourceDirs()) {
        if (dir.exists()) {

            // exclusion filter
            IOFileFilter exclusionFilter = new ExclusionFilter(dir, exclusionPatterns);
            // visible filter
            List<IOFileFilter> fileFilters = Lists.newArrayList(visibleFileFilter, suffixFilter,
                    exclusionFilter);
            // inclusion filter
            String inclusionPattern = (String) project.getProperty(XmlPlugin.INCLUDE_FILE_FILTER);
            if (inclusionPattern != null) {
                fileFilters.add(new InclusionFilter(dir, inclusionPattern));
            }
            fileFilters.addAll(this.filters);

            // create DefaultInputFile for each file.
            List<File> files = (List<File>) FileUtils.listFiles(dir, new AndFileFilter(fileFilters),
                    HiddenFileFilter.VISIBLE);
            for (File file : files) {
                String relativePath = DefaultProjectFileSystem.getRelativePath(file, dir);
                result.add(new DefaultInputFile(dir, relativePath));
            }
        }
    }
    return result;
}

From source file:org.sonar.server.batch.BatchIndex.java

@Override
public void start() {
    StringBuilder sb = new StringBuilder();
    batchDir = new File(fs.getHomeDir(), "lib/scanner");
    if (batchDir.exists()) {
        Collection<File> files = FileUtils.listFiles(batchDir, HiddenFileFilter.VISIBLE,
                FileFilterUtils.directoryFileFilter());
        for (File file : files) {
            String filename = file.getName();
            if (StringUtils.endsWith(filename, ".jar")) {
                try (FileInputStream fis = new FileInputStream(file)) {
                    sb.append(filename).append('|').append(DigestUtils.md5Hex(fis)).append(CharUtils.LF);
                } catch (IOException e) {
                    throw new IllegalStateException("Fail to compute hash", e);
                }/*w ww . jav  a 2 s .c  o  m*/
            }
        }
    }
    this.index = sb.toString();
}

From source file:org.sonar.server.plugins.BatchWs.java

@Override
public void start() {
    StringBuilder sb = new StringBuilder();
    batchDir = new File(server.getRootDir(), "lib/batch");
    if (batchDir.exists()) {
        Collection<File> files = FileUtils.listFiles(batchDir, HiddenFileFilter.VISIBLE,
                FileFilterUtils.directoryFileFilter());
        for (File file : files) {
            String filename = file.getName();
            if (StringUtils.endsWith(filename, ".jar")) {
                sb.append(filename).append('|').append(new FileHashes().of(file)).append(CharUtils.LF);
            }/*from w ww  .j a v a  2 s  .  c o m*/
        }
    }
    this.index = sb.toString();
}

From source file:org.sonatype.flexmojos.tests.AbstractFlexMojosTests.java

@SuppressWarnings("unchecked")
protected static File getProject(String projectName, String... filesToInterpolate) throws IOException {
    if (filesToInterpolate == null || filesToInterpolate.length == 0) {
        filesToInterpolate = new String[] { "pom.xml" };
    }//from  w  w w .j a  v  a  2  s .c o  m

    copyProjectLock.writeLock().lock();
    try {
        File projectFolder = new File(projectsSource, projectName);
        AssertJUnit.assertTrue(
                "Project " + projectName + " folder not found.\n" + projectFolder.getAbsolutePath(),
                projectFolder.isDirectory());

        File destDir = new File(projectsWorkdir, projectName + "_" + getTestName());

        FileUtils.copyDirectory(projectFolder, destDir, HiddenFileFilter.VISIBLE);

        // projects filtering
        Collection<File> poms = FileUtils.listFiles(destDir, new WildcardFileFilter(filesToInterpolate),
                TrueFileFilter.INSTANCE);
        for (File pom : poms) {
            String pomContent = FileUtils.readFileToString(pom);
            pomContent = pomContent.replace("%{flexmojos.version}", getFlexmojosVersion());
            pomContent = pomContent.replace("%{flex.version}", getFlexSDKVersion());
            FileUtils.writeStringToFile(pom, pomContent);
        }

        return destDir;
    } finally {
        copyProjectLock.writeLock().unlock();
    }
}

From source file:org.wso2.carbon.registry.extensions.handlers.scm.ExternalContentHandler.java

private void loadRegistryResources(Registry registry, File directory, String workingDir, String mountPoint)
        throws RegistryException {
    File[] files = directory.listFiles((FileFilter) new AndFileFilter(HiddenFileFilter.VISIBLE,
            new OrFileFilter(DirectoryFileFilter.INSTANCE, FileFileFilter.FILE)));
    if (files == null) {
        return;//from w w  w  .  j a  v a2s .  c o m
    }
    for (File file : files) {
        if (file.isDirectory()) {
            loadRegistryResources(registry, file, workingDir, mountPoint);
        } else {
            // convert windows paths so that it fits into the Unix-like registry path structure.
            String path = mountPoint + file.getAbsolutePath().substring(workingDir.length()).replace("\\", "/");
            if (!registry.resourceExists(path)) {
                registry.put(path, registry.newResource());
            }
        }
    }
}

From source file:org.wso2.carbon.registry.extensions.handlers.scm.FilesystemManager.java

public String[] getDirectoryContent(String path) throws RegistryException {
    File directory = new File(baseDir, path);
    if (!directory.exists() || !directory.isDirectory()) {
        throw new RegistryException("A directory does not exist at path: " + directory.getAbsolutePath());
    }//from  w w w.  j a v a  2s. com
    return directory.list(new AndFileFilter(HiddenFileFilter.VISIBLE,
            new OrFileFilter(DirectoryFileFilter.INSTANCE, FileFileFilter.FILE)));
}

From source file:pt.ua.tm.neji.batch.FileBatchExecutor.java

private static FileFilter newFileFilter(String wildcardFilter, boolean compressed) {
    List<String> wildcards = new ArrayList<>();

    if (StringUtils.isNotBlank(wildcardFilter)) {
        wildcards.add(wildcardFilter);/*w w  w  .j  a  v  a 2s.  c  o m*/
    }
    if (compressed) {
        wildcards.add("*.gz");
    }
    if (wildcards.isEmpty()) {
        wildcards.add("*");
    }

    return new AndFileFilter(new WildcardFileFilter(wildcards), HiddenFileFilter.VISIBLE);
}

From source file:xmlconverter.tools.CompressionZIP.java

public boolean zipIt(File target, File output) {

    byte[] buffer = new byte[1024];

    try (FileOutputStream fos = new FileOutputStream(output); ZipOutputStream zos = new ZipOutputStream(fos);) {

        Collection<File> fileCollection = FileUtils.listFilesAndDirs(target, HiddenFileFilter.VISIBLE,
                DirectoryFileFilter.DIRECTORY);
        for (File file : fileCollection) {
            if (!file.isDirectory()) {
                String srcFile = file.getAbsolutePath().substring(
                        target.getParentFile().getAbsolutePath().length() + 1, file.getAbsolutePath().length());
                ZipEntry ze = new ZipEntry(srcFile);
                zos.putNextEntry(ze);// w w w. j a v  a2 s  . co m
                try (FileInputStream in = new FileInputStream(file);) {
                    int len;
                    while ((len = in.read(buffer)) > 0) {
                        zos.write(buffer, 0, len);
                    }
                }
            }
        }
        zos.closeEntry();
        log.info("Zip created succesfully!");
        return true;
    } catch (Exception e) {
        log.error("Error while compressing", e);
        return false;
    }
}

From source file:za.co.massdosage.scrobble.FileScrobbler.java

List<ScrobbleData> extractScrobbles(File scrobbleFolder) throws CannotReadException, IOException, TagException,
        ReadOnlyFileException, InvalidAudioFrameException {
    List<ScrobbleData> scrobbles = new ArrayList<>();
    File folders[] = scrobbleFolder.listFiles((FileFilter) DirectoryFileFilter.INSTANCE);
    if (folders != null) {
        for (File folder : folders) {
            scrobbles.addAll(extractScrobbles(folder));
        }//w ww . ja v a  2s. c o m
    }
    FileFilter fileFilter = new AndFileFilter(HiddenFileFilter.VISIBLE,
            new SuffixFileFilter(supportedFileTypes));
    File files[] = scrobbleFolder.listFiles(fileFilter);
    if (files != null) {
        List<File> sortedFiles = Arrays.asList(files);
        Collections.sort(sortedFiles, new FileNameComparator());
        ScrobbleData scrobbleData;
        for (Iterator<File> iterator = sortedFiles.iterator(); iterator.hasNext(); scrobbles
                .add(scrobbleData)) {
            File file = iterator.next();
            scrobbleData = extractScrobble(file);
        }

    }
    return scrobbles;
}