List of usage examples for org.apache.commons.io IOCase INSENSITIVE
IOCase INSENSITIVE
To view the source code for org.apache.commons.io IOCase INSENSITIVE.
Click Source Link
From source file:org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher.java
@Override boolean isMatch(String resourceValue, Map<String, Object> evalContext) { return RangerPathResourceMatcher.isRecursiveWildCardMatch(resourceValue, getExpandedValue(evalContext), levelSeparatorChar, IOCase.INSENSITIVE); }
From source file:org.ballerinalang.composer.service.workspace.local.LocalFSWorkspace.java
/** * {@inheritDoc}//from w w w .j a v a 2 s . c o m */ @Override public JsonArray listFilesInPath(String path, List<String> extensions) throws IOException { Path ioPath = Paths.get(path); JsonArray dirs = new JsonArray(); Iterator<Path> iterator = Files.list(ioPath).iterator(); while (iterator.hasNext()) { Path next = iterator.next(); if ((Files.isDirectory(next) || Files.isRegularFile(next)) && !Files.isHidden(next) && !isWindowsSystemFile(next)) { JsonObject jsnObj = getJsonObjForFile(next, true); if (Files.isRegularFile(next)) { Path fileName = next.getFileName(); SuffixFileFilter fileFilter = new SuffixFileFilter(extensions, IOCase.INSENSITIVE); if (null != fileName && fileFilter.accept(next.toFile())) { dirs.add(jsnObj); } } else { dirs.add(jsnObj); } } } return dirs; }
From source file:org.bonitasoft.platform.setup.command.configure.BundleConfigurator.java
RegexFileFilter getDriverFilter(String dbVendor) {
return new RegexFileFilter(getDriverPattern(dbVendor), IOCase.INSENSITIVE);
}
From source file:org.duracloud.sync.mgmt.FileExclusionManager.java
private void setExcludeList(List<String> excludeList) { fileFilter = new WildcardFileFilter(excludeList, IOCase.INSENSITIVE); }
From source file:org.emonocot.job.dwc.read.ArchiveFactory.java
/** * @param unzippedFolderLocation the location of an expanded archive directory or just a single dwc text file */// ww w. j a v a 2 s .c o m public static Archive openArchive(File unzippedFolderLocation) throws IOException, UnsupportedArchiveException { Archive archive = new Archive(); archive.setLocation(unzippedFolderLocation); File mf = null; // see if we can find a meta.xml descriptor file if (unzippedFolderLocation.isFile()) { String suffix = unzippedFolderLocation.getName() .substring(unzippedFolderLocation.getName().lastIndexOf(".")); if (suffix.equalsIgnoreCase(".xml")) { // could be a metafile on its own pointing to remote data files... mf = unzippedFolderLocation; } } else { mf = new File(unzippedFolderLocation, "meta.xml"); } // read metadata if (mf != null && mf.exists()) { // read metafile readMetaDescriptor(archive, new FileInputStream(mf), true); if (archive.getMetadataLocation() == null) { // search for known metadata filenames File emlFile = new File(mf.getParentFile(), "eml.xml"); if (emlFile.exists()) { archive.setMetadataLocation("eml.xml"); } } } else { // try to detect data files ourselves as best as we can... // currently support a single data file or a folder which contains a single data file if (unzippedFolderLocation.isFile()) { ArchiveFile coreFile = readFileHeaders(unzippedFolderLocation); archive.setCore(coreFile); } else { // folder. see if we got only 1 file in there... List<File> dataFiles = new ArrayList<File>(); FilenameFilter ff = new SuffixFileFilter(".csv", IOCase.INSENSITIVE); dataFiles.addAll(Arrays.asList(unzippedFolderLocation.listFiles(ff))); ff = new SuffixFileFilter(".txt", IOCase.INSENSITIVE); dataFiles.addAll(Arrays.asList(unzippedFolderLocation.listFiles(ff))); if (dataFiles.size() == 1) { // set pointer to data file File dataFile = new File(unzippedFolderLocation, dataFiles.get(0).getName()); archive.setLocation(unzippedFolderLocation); if (archive.getMetadataLocation() == null && unzippedFolderLocation.isDirectory()) { // search for known metadata filenames File emlFile = new File(unzippedFolderLocation, "eml.xml"); if (emlFile.exists()) { archive.setMetadataLocation("eml.xml"); } } ArchiveFile coreFile = readFileHeaders(dataFile); coreFile.getLocations().clear(); coreFile.addLocation(dataFile.getName()); archive.setCore(coreFile); } else { throw new UnsupportedArchiveException( "The archive given is a folder with more or less than 1 data files having a txt or csv suffix"); } } } // final validation validateArchive(archive); // report basic stats LOG.debug("Archive contains " + archive.getExtensions().size() + " described extension files"); LOG.debug("Archive contains " + archive.getCore().getFields().size() + " core properties"); return archive; }
From source file:org.exoplatform.contact.service.impl.ContactServiceImpl.java
private List<String> excludeWildCardMatchs(List<String> sourceList, List<String> wildCards) throws Exception { List<String> groupIds = new ArrayList<String>(); if (sourceList != null && !sourceList.isEmpty()) { for (String object : sourceList) { groupIds.add(object);/*from w w w.j av a 2 s . c o m*/ } } if (wildCards == null || wildCards.isEmpty() || sourceList == null || sourceList.isEmpty()) { return groupIds; } for (String wildCard : wildCards) { for (String s : sourceList) { if (FilenameUtils.wildcardMatch(s, wildCard, IOCase.INSENSITIVE)) { groupIds.remove(s); } } } return groupIds; }
From source file:org.gbif.dwca.io.ArchiveFactory.java
/** * @param dwcaFolder the location of an expanded dwc archive directory or just a single dwc text file *//*from www.j a va 2s.c om*/ public static Archive openArchive(File dwcaFolder) throws IOException, UnsupportedArchiveException { if (!dwcaFolder.exists()) { throw new FileNotFoundException("Archive folder not existing: " + dwcaFolder.getAbsolutePath()); } // delegate to open data file method if its a single file, not a folder if (dwcaFolder.isFile()) { return openArchiveDataFile(dwcaFolder); } Archive archive = new Archive(); archive.setLocation(dwcaFolder); // Accommodate archives coming from legacy IPTs which put a "\" before each filename // http://dev.gbif.org/issues/browse/POR-2396 // https://code.google.com/p/gbif-providertoolkit/issues/detail?id=1015 Iterator<File> iter = FileUtils.iterateFiles(dwcaFolder, new String[] { "xml", "txt" }, false); while (iter.hasNext()) { File f = iter.next(); if (f.getName().startsWith("\\")) { String orig = f.getName(); String replacement = f.getName().replaceFirst("\\\\", ""); LOG.info("Renaming file from {} to {}", orig, replacement); f.renameTo(new File(dwcaFolder, replacement)); } } // read metadata File mf = new File(dwcaFolder, Archive.META_FN); if (mf.exists()) { // read metafile readMetaDescriptor(archive, new FileInputStream(mf)); } else { // meta.xml lacking. // Try to detect data files ourselves as best as we can. // look for a single, visible text data file List<File> dataFiles = new ArrayList<File>(); for (String suffix : Lists.newArrayList(".csv", ".txt", ".tab", ".text", ".data")) { FileFilter ff = FileFilterUtils.and(FileFilterUtils.suffixFileFilter(suffix, IOCase.INSENSITIVE), HiddenFileFilter.VISIBLE); dataFiles.addAll(Arrays.asList(dwcaFolder.listFiles(ff))); } if (dataFiles.size() == 1) { File dataFile = new File(dwcaFolder, dataFiles.get(0).getName()); ArchiveFile coreFile = readFileHeaders(dataFile); coreFile.getLocations().clear(); coreFile.addLocation(dataFile.getName()); archive.setCore(coreFile); } else { throw new UnsupportedArchiveException( "The archive given is a folder with more or less than 1 data files having a csv, txt or tab suffix"); } } // check if we also have a metadata file next to this data file discoverMetadataFile(archive, mf.getParentFile()); // final validation return validateArchive(archive); }
From source file:org.geoserver.csw.store.simple.SimpleRecordIterator.java
public SimpleRecordIterator(File root, int offset) { File[] fileArray = root.listFiles((FilenameFilter) new SuffixFileFilter(".xml", IOCase.INSENSITIVE)); files = Arrays.asList(fileArray).iterator(); parser = new Parser(new CSWConfiguration()); this.offset = offset; }
From source file:org.geoserver.web.netcdf.layer.NetCDFParserBean.java
public NetCDFParserBean() { Resource cfStandardTable = null; // Check if an external file has been defined if (netcdfFile != null) { cfStandardTable = netcdfFile;/*from w ww.j av a2 s. com*/ } // Checking if it is contained in the NetCDF Data Directory if (cfStandardTable == null && NetCDFUtilities.EXTERNAL_DATA_DIR != null) { // Getting the directory file File netCDFDir = new File(NetCDFUtilities.EXTERNAL_DATA_DIR); // Creating a File filter FileFilter filter = FileFilterUtils.nameFileFilter(NETCDF_STANDARD_NAME, IOCase.INSENSITIVE); // Getting the filtered file array File[] files = netCDFDir.listFiles(filter); // Getting the file if present if (files != null && files.length > 0) { cfStandardTable = Files.asResource(files[0]); } } if (cfStandardTable == null) { // Getting geoServer data dir GeoServerDataDirectory datadir = GeoServerExtensions.bean(GeoServerDataDirectory.class); // Checking if the standard table is present try { cfStandardTable = datadir.get(NETCDF_STANDARD_NAME); } catch (IllegalStateException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } } // Check if the file can be parsed if (cfStandardTable != null && cfStandardTable.getType() != Resource.Type.UNDEFINED) { NetCDFCFParser parser = null; try { parser = NetCDFCFParser.unmarshallXml(cfStandardTable.file()); } catch (JAXBException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } catch (IllegalStateException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } // If so set it as global attribute if (parser != null) { this.parser = parser; } } else { LOGGER.log(Level.WARNING, "No CF-Standard File found"); } }
From source file:org.geotools.gce.imagemosaic.catalogbuilder.CatalogBuilder.java
/** * @return/*from w ww.j av a2 s. c om*/ */ private IOFileFilter createGranuleFilterRules() { final IOFileFilter specialWildCardFileFilter = new WildcardFileFilter(runConfiguration.getWildcard(), IOCase.INSENSITIVE); IOFileFilter dirFilter = FileFilterUtils.andFileFilter(FileFilterUtils.directoryFileFilter(), HiddenFileFilter.VISIBLE); IOFileFilter fileFilter = Utils.excludeFilters( FileFilterUtils.makeSVNAware(FileFilterUtils.makeFileOnly( FileFilterUtils.andFileFilter(specialWildCardFileFilter, HiddenFileFilter.VISIBLE))), FileFilterUtils.suffixFileFilter("shp"), FileFilterUtils.suffixFileFilter("dbf"), FileFilterUtils.suffixFileFilter("shx"), FileFilterUtils.suffixFileFilter("qix"), FileFilterUtils.suffixFileFilter("lyr"), FileFilterUtils.suffixFileFilter("prj"), FileFilterUtils.nameFileFilter("error.txt"), FileFilterUtils.nameFileFilter("error.txt.lck"), FileFilterUtils.suffixFileFilter("properties"), FileFilterUtils.suffixFileFilter("svn-base")); // exclude common extensions Set<String> extensions = WorldImageFormat.getWorldExtension("png"); for (String ext : extensions) { fileFilter = FileFilterUtils.andFileFilter(fileFilter, FileFilterUtils.notFileFilter(FileFilterUtils.suffixFileFilter(ext.substring(1)))); } extensions = WorldImageFormat.getWorldExtension("gif"); for (String ext : extensions) { fileFilter = FileFilterUtils.andFileFilter(fileFilter, FileFilterUtils.notFileFilter(FileFilterUtils.suffixFileFilter(ext.substring(1)))); } extensions = WorldImageFormat.getWorldExtension("jpg"); for (String ext : extensions) { fileFilter = FileFilterUtils.andFileFilter(fileFilter, FileFilterUtils.notFileFilter(FileFilterUtils.suffixFileFilter(ext.substring(1)))); } extensions = WorldImageFormat.getWorldExtension("tiff"); for (String ext : extensions) { fileFilter = FileFilterUtils.andFileFilter(fileFilter, FileFilterUtils.notFileFilter(FileFilterUtils.suffixFileFilter(ext.substring(1)))); } extensions = WorldImageFormat.getWorldExtension("bmp"); for (String ext : extensions) { fileFilter = FileFilterUtils.andFileFilter(fileFilter, FileFilterUtils.notFileFilter(FileFilterUtils.suffixFileFilter(ext.substring(1)))); } //sdw fileFilter = FileFilterUtils.andFileFilter(fileFilter, FileFilterUtils.notFileFilter(FileFilterUtils.suffixFileFilter("sdw"))); //aux fileFilter = FileFilterUtils.andFileFilter(fileFilter, FileFilterUtils.notFileFilter(FileFilterUtils.suffixFileFilter("aux"))); //wld fileFilter = FileFilterUtils.andFileFilter(fileFilter, FileFilterUtils.notFileFilter(FileFilterUtils.suffixFileFilter("wld"))); //svn fileFilter = FileFilterUtils.andFileFilter(fileFilter, FileFilterUtils.notFileFilter(FileFilterUtils.suffixFileFilter("svn"))); final IOFileFilter finalFilter = FileFilterUtils.orFileFilter(dirFilter, fileFilter); return finalFilter; }