List of usage examples for org.apache.commons.io.filefilter RegexFileFilter RegexFileFilter
public RegexFileFilter(Pattern pattern)
From source file:adalid.util.meta.sql.MetaFolderSql.java
private IOFileFilter dirFilter() { IOFileFilter makeFileFilter = FileFilterUtils.makeCVSAware(FileFilterUtils.makeSVNAware(null)); IOFileFilter metaFileFilter = new RegexPathFilter( B + X + S + "velocity" + S + "templates" + S + "meta" + S + X + E); IOFileFilter mesaFileFilter = FileFilterUtils.notFileFilter(metaFileFilter); IOFileFilter[] noes = new IOFileFilter[] { new RegexFileFilter(B + "build" + E), new RegexFileFilter(B + "dist" + E), new RegexFileFilter(B + "private" + E), new RegexFileFilter(B + "test" + E) }; IOFileFilter noesFileFilter = FileFilterUtils.notFileFilter(FileFilterUtils.or(noes)); IOFileFilter filter = FileFilterUtils.and(makeFileFilter, mesaFileFilter, noesFileFilter); return filter; }
From source file:edu.stolaf.cs.wmrserver.TransformProcessor.java
private void copyLibraryFiles(SubnodeConfiguration languageConf, File jobTransformDir) throws IOException { // Get the library directory, returning if not specified File libDir = getLibraryDirectory(languageConf); if (libDir == null) return;/*from ww w . jav a 2s. c om*/ // Get the file extension appropriate for the language String scriptExtension = languageConf.getString("extension", ""); if (!scriptExtension.isEmpty()) scriptExtension = "." + scriptExtension; // Create a file filter to exclude prefix/suffix files String pattern = "^(mapper|reducer)-(prefix|suffix)" + Pattern.quote(scriptExtension) + "$"; FileFilter libFilter = new NotFileFilter(new RegexFileFilter(pattern)); // Copy filtered contents of library directory FileUtils.copyDirectory(libDir, jobTransformDir, libFilter); }
From source file:com.redhat.victims.plugin.jenkins.VictimsPostBuildScanner.java
/** * Return a list of all jars in the output directory or the specified * jar as a list. As these files/directory might not prior to the * build we are checking their existence here rather than during the * configuration of the VictimsPostBuildScanner. * // w ww . j a va 2 s . c o m * @return a list of jars to scan for vulnerabilities * @throws AbortException */ public Collection<File> listFiles(String outputDirectory) throws AbortException { File outputFile = new File(outputDirectory); if (!outputFile.exists()) { // Output file/dir should exist by now. throw new AbortException("Output directory/file does not exist"); } if (outputFile.isFile()) { Collection<File> file = new ArrayList<File>(); file.add(outputFile); return file; } if (outputFile.isDirectory()) { Collection<File> files = FileUtils.listFiles(outputFile, new RegexFileFilter("^(.*?)\\.jar"), DirectoryFileFilter.DIRECTORY); return files; } // Something has gone horribly wrong throw new AbortException("Supplied output location is neither a file nor directory"); }
From source file:adalid.util.velocity.MavenArchetypeBuilder.java
protected IOFileFilter binaryFileFilter() { IOFileFilter[] ayes = new IOFileFilter[] { new RegexFileFilter(B + X + D + "gif" + E), new RegexFileFilter(B + X + D + "jpg" + E), new RegexFileFilter(B + X + D + "png" + E) }; return FileFilterUtils.or(ayes); }
From source file:adalid.util.velocity.MavenArchetypeBuilder.java
protected IOFileFilter binaryDirFilter() { IOFileFilter[] noes = new IOFileFilter[] { new RegexFileFilter(B + D + "settings" + E), new RegexFileFilter(B + "target" + E), new RegexFileFilter(B + "test" + E), new RegexFileFilter(B + E) }; return FileFilterUtils.notFileFilter(FileFilterUtils.or(noes)); }
From source file:com.mediaworx.opencms.moduleutils.manifestgenerator.OpenCmsModuleManifestGenerator.java
/** * Generates the manifest.xml for OpenCms modules from meta files (manifest_stub.xml and separate meta files for all * files and folders in the VFS).//w w w.j a v a 2s . c o m * @param manifestRoot file representing the root folder of the manifest meta data (including manifest_stub.xml) * * @throws OpenCmsMetaXmlParseException if the XmlHelper can not be initialized or the manifest stub file or any * meta file can not be read or parsed * @throws OpenCmsMetaXmlFileWriteException if the resulting manifest file can not be written */ public void generateManifest(File manifestRoot) throws OpenCmsMetaXmlParseException, OpenCmsMetaXmlFileWriteException { manifestRootPath = manifestRoot.getPath(); handledSiblingResourceIds = new HashSet<String>(); String manifestStubPath = manifestRoot.getPath() + File.separator + FILENAME_MANIFEST_STUB; String manifestPath = manifestRoot.getPath() + File.separator + FILENAME_MANIFEST; LOG.info("manifestStubPath: {}", manifestStubPath); Node filesNode; Document manifest; try { xmlHelper = new XmlHelper(); Map<String, String> replacements = null; if (replaceMetaVariables) { replacements = new HashMap<String, String>(); replacements.put(META_VAR_CREATEDATE, formatDate((new Date()).getTime())); } manifest = xmlHelper.parseFile(manifestStubPath, replacements); filesNode = xmlHelper.getSingleNodeForXPath(manifest, FILES_NODE_XPATH); } catch (ParserConfigurationException e) { throw new OpenCmsMetaXmlParseException("The XmlHelper could not be initialized", e); } catch (IOException e) { throw new OpenCmsMetaXmlParseException("The manifest stub file could not be read", e); } catch (SAXException e) { throw new OpenCmsMetaXmlParseException("The manifest stub xml could not be parsed (parse error)", e); } catch (XPathExpressionException e) { throw new OpenCmsMetaXmlParseException("The manifest stub xml could not be parsed (xpath error)", e); } // Regular Expression matching anything but Strings ending with the VFS folder meta file suffix (".ocmsfolder.xml") String excludeFolderMetaRegex = "^(?:(?!" + Pattern.quote(FOLDER_META_SUFFIX) + "$).)*$"; // FileFilter filtering all VFS folder meta files (so only VFS file meta files and folders are included) IOFileFilter excludeFolderMetaFilter = new RegexFileFilter(excludeFolderMetaRegex); // read all files and folders excluding VFS folder meta files Collection<File> files = FileUtils.listFilesAndDirs(manifestRoot, excludeFolderMetaFilter, TrueFileFilter.INSTANCE); for (File file : files) { if (file.isDirectory()) { // exclude the manifest root if (file.getPath().equals(manifestRoot.getPath())) { continue; } addFolderToFilesNode(filesNode, file); } else { // exclude the manifest stub file and the manifest file if (file.getPath().equals(manifestPath) || file.getPath().equals(manifestStubPath)) { continue; } addFileToFilesNode(filesNode, file); } } // render the xml string String manifestString = xmlHelper.getXmlStringFromDocument(manifest, CDATA_NODES); // if a specific version is provided, replace the original version if (StringUtils.isNotBlank(moduleVersion)) { manifestString = manifestString.replaceFirst("<version>[^<]*</version>", "<version>" + Matcher.quoteReplacement(moduleVersion) + "</version>"); } // write the manifest to the disk try { writeManifest(manifestPath, manifestString); } catch (IOException e) { throw new OpenCmsMetaXmlFileWriteException("manifest.xml could not be written", e); } }
From source file:ee.ria.xroad.proxy.messagelog.MessageLogTest.java
@SneakyThrows private String getArchiveFilePath() { File outputDir = new File("build"); FileFilter fileFilter = new RegexFileFilter("^mlog-\\d+-\\d+-.\\w+\\.zip$"); File[] files = outputDir.listFiles(fileFilter); File latestModifiedZip = null; for (File eachFile : files) { if (changesLatestModified(latestModifiedZip, eachFile)) { latestModifiedZip = eachFile; }/* w ww . j a v a2 s. c om*/ } if (latestModifiedZip == null) { throw new RuntimeException("No archive files were created."); } return latestModifiedZip.getPath(); }
From source file:adalid.util.velocity.MavenArchetypeBuilder.java
protected IOFileFilter textFileFilter() { IOFileFilter[] noes = new IOFileFilter[] { new RegexPathFilter(B + X + S + "meta" + S + "util" + S + "I18N" + X + E), new RegexPathFilter(B + X + S + "meta" + S + "util" + S + "Meta" + X + E), new RegexPathFilter(B + X + S + "meta" + S + "util" + S + "Velocity" + X + E), new RegexFileFilter(B + D + "gitignore" + E), new RegexFileFilter(B + D + "classpath" + E), new RegexFileFilter(B + D + "project" + E), new RegexFileFilter(B + X + D + "gif" + E), new RegexFileFilter(B + X + D + "jpg" + E), new RegexFileFilter(B + X + D + "lnk" + E), new RegexFileFilter(B + X + D + "log" + E), new RegexFileFilter(B + X + D + "png" + E), new RegexFileFilter(B + "Thumbs" + D + "db" + E), new RegexFileFilter(B + "nb-configuration" + D + "xml" + E), new RegexFileFilter(B + "nbactions" + D + "xml" + E), new RegexFileFilter(B + E) }; return FileFilterUtils.notFileFilter(FileFilterUtils.or(noes)); }
From source file:de.tsystems.mms.apm.performancesignature.PerfSigProjectAction.java
private String getDashboardConfiguration() throws IOException, InterruptedException { final List<FilePath> fileList = getJsonConfigFilePath().list(new RegexFileFilter("gridconfig-.*.json")); final StringBuilder sb = new StringBuilder("["); for (FilePath file : fileList) { final String tmp = file.readToString(); sb.append(tmp.substring(1, tmp.length() - 1)).append(","); }//from w w w .jav a 2s . c om sb.setLength(sb.length() - 1); sb.append("]"); return sb.toString(); }
From source file:net.imagini.cassandra.DumpSSTables.SSTableExport.java
private static void readSSTables(File ssTableFileName, CommandLine cmd) throws IOException { if (ssTableFileName.exists()) { if (ssTableFileName.isDirectory()) { Collection<File> files = org.apache.commons.io.FileUtils.listFiles(ssTableFileName, new RegexFileFilter("^.*Data\\.db"), DirectoryFileFilter.DIRECTORY); for (File file : files) { readSSTables(file, cmd); }//from w w w . j a v a 2 s .com } else if (ssTableFileName.isFile()) { Descriptor descriptor = Descriptor.fromFilename(ssTableFileName.getAbsolutePath()); if (Schema.instance.getCFMetaData(descriptor) == null) { System.err.println(String.format( "The provided column family is not part of this cassandra database: keysapce = %s, column family = %s", descriptor.ksname, descriptor.cfname)); System.exit(1); } if (cmd.hasOption(ENUMERATEKEYS_OPTION)) { enumeratekeys(descriptor, System.out); } else { if ((cmd.getOptionValues(KEY_OPTION) != null) && (cmd.getOptionValues(KEY_OPTION).length > 0)) export(descriptor, System.out, Arrays.asList(cmd.getOptionValues(KEY_OPTION)), cmd.getOptionValues(EXCLUDEKEY_OPTION)); else export(descriptor, cmd.getOptionValues(EXCLUDEKEY_OPTION)); } } } }