List of usage examples for org.apache.commons.io.filefilter SuffixFileFilter SuffixFileFilter
public SuffixFileFilter(List suffixes)
From source file:org.dataconservancy.ui.services.AtomDepositDocumentParserTest.java
/** * Seeds a {@code MockArchiveUtil} with entities, and constructs a {@code AtomDepositDocumentParser} for testing. * /*from w w w .j av a 2 s .c o m*/ * @throws URISyntaxException * @throws FileNotFoundException * @throws InvalidXmlException */ @Before @SuppressWarnings("unchecked") public void setUp() throws URISyntaxException, FileNotFoundException, InvalidXmlException { // Obtain the valid, production, sample feed URL feedResource = this.getClass().getResource(PRODUCTION_FEED_RESOURCE); assertNotNull("Unable to resolve classpath resource " + PRODUCTION_FEED_RESOURCE); productionFeedIn = this.getClass().getResourceAsStream(PRODUCTION_FEED_RESOURCE); // Instantiate a MockArchiveUtil which we will pre-populate with expected DCS entities. productionMockArchiveUtil = new MockArchiveUtil(); // Set the mapping strategy to entity ids only productionMockArchiveUtil.setMappingStrategy(MockArchiveUtil.ID_MAPPING_STRATEGY.ENTITY_ID); // Populate the MockArchiveUtil with the valid, expected, DCS entities. File feedBaseDir = new File(feedResource.toURI()).getParentFile(); Iterator<File> serializedEntities = FileUtils.iterateFiles(feedBaseDir, new AndFileFilter(new PrefixFileFilter("4260"), new SuffixFileFilter(".xml")), DirectoryFileFilter.DIRECTORY); while (serializedEntities.hasNext()) { Dcp dcp = modelBuilder.buildSip(new FileInputStream(serializedEntities.next())); for (DcsEntity e : dcp) { productionMockArchiveUtil.addEntity(e); } } assertTrue("Error loading expected entities from " + feedBaseDir, productionMockArchiveUtil.getEntities().size() > 0); // Construct the DocumentParser under test underTest = new AtomDepositDocumentParser(productionMockArchiveUtil); }
From source file:org.deegree.maven.ithelper.ServiceIntegrationTestHelper.java
public void testRequestDirectory(String address, File dir) throws MojoFailureException { File[] listed = dir.listFiles((FileFilter) new SuffixFileFilter("kvp")); if (listed != null) { for (File f : listed) { String name = f.getName(); name = name.substring(0, name.length() - 4); log.info("KVP request testing " + name); try { String req = readFileToString(f).trim(); InputStream in1 = new URL(address + (req.startsWith("?") ? "" : "?") + req).openStream(); File response = new File(f.getParentFile(), name + ".response"); InputStream in2 = new FileInputStream(response); double sim = determineSimilarity(name, in1, in2); if (sim != 1) { log.info("Request test " + name + " resulted in similarity of " + sim); }//from w w w . j a va2 s . com } catch (IOException e) { throw new MojoFailureException( "KVP request checking of " + name + " failed: " + e.getLocalizedMessage(), e); } } } listed = dir.listFiles((FileFilter) new SuffixFileFilter("xml")); if (listed != null) { for (File f : listed) { String name = f.getName(); name = name.substring(0, name.length() - 4); log.info("XML request testing " + name); FileInputStream reqIn = null; try { reqIn = new FileInputStream(f); InputStream in1 = post(STREAM, address, reqIn, null); File response = new File(f.getParentFile(), name + ".response"); InputStream in2 = new FileInputStream(response); double sim = determineSimilarity(name, in1, in2); log.info("Request test " + name + " resulted in similarity of " + sim); } catch (IOException e) { throw new MojoFailureException( "KVP request checking of " + name + " failed: " + e.getLocalizedMessage(), e); } finally { closeQuietly(reqIn); } } } }
From source file:org.dspace.EDMExport.service.EDMExportServiceXML.java
/** * Comprueba los formatos disponibles en el war * /*from w w w. ja v a2s.c o m*/ * @param formatsXml cadena con los formatos separados por coma en edmexport.properties * @param path ruta fsica del edmexport desplegado * * @return array de cadenas con los formatos soportados */ public String[] getFormatsXml(String formatsXml, String path) { String[] xmlFormatsArr = formatsXml.split(","); Set<String> setXmlFormats = new HashSet<String>(Arrays.asList(xmlFormatsArr)); List<String> listXmlFormats = new ArrayList<String>(); String suffix = "ExportXMLItem.class"; StringBuilder sb = new StringBuilder(path).append(fileSeparator).append("WEB-INF").append(fileSeparator) .append("classes").append(fileSeparator).append("org").append(fileSeparator).append("dspace") .append(fileSeparator).append("EDMExport").append(fileSeparator).append("service") .append(fileSeparator); String dirXml = sb.toString(); File dir = new File(dirXml); String[] files = dir.list(new SuffixFileFilter(suffix)); for (int i = 0; i < files.length; i++) { String exportXml = files[i].replaceFirst(suffix, ""); File fileExportXml = new File(dirXml + files[i]); if (fileExportXml.canRead() && setXmlFormats.contains(exportXml)) { listXmlFormats.add(exportXml); } } return listXmlFormats.toArray(new String[listXmlFormats.size()]); }
From source file:org.dspace.installer_edm.InstallerManagerCrosswalk.java
/** * Se buscan los crosswalk en el directorio packages, se pide el deseado y se instancia la clase. * Se llama a su configuracin/*from w ww . j a va 2 s .c o m*/ * @return */ public void configure() { String suffix = "Crosswalk.java"; String dirPackages = myInstallerDirPath + fileSeparator + "packages" + fileSeparator; File dir = new File(dirPackages); String[] files = dir.list(new SuffixFileFilter(suffix)); for (int i = 0; i < files.length; i++) { String crosswalk = files[i].replaceFirst(suffix, ""); File fileCrosswalk = new File(dirPackages + files[i]); if (fileCrosswalk.canRead()) { crosswalks.put(crosswalk, fileCrosswalk); } } if (!crosswalks.isEmpty()) { String crosswalk = chooseCrosswalk(); if (crosswalk == null) return; String installerCrosswalk = "org.dspace.installer_edm.Installer" + crosswalk + "Crosswalk"; try { Class installerCrosswalkClass = Class.forName(installerCrosswalk); Constructor ctor = installerCrosswalkClass .getDeclaredConstructor(new Class[] { Integer.class, String.class }); Object crosswalkClass = (InstallerCrosswalk) ctor.newInstance(new Integer(currentStepGlobal), crosswalk); ((InstallerCrosswalk) crosswalkClass).configure(); } catch (ClassNotFoundException e) { showException(e); } catch (InstantiationException e) { showException(e); } catch (IllegalAccessException e) { showException(e); } catch (InvocationTargetException e) { showException(e); } catch (NoSuchMethodException e) { showException(e); } } }
From source file:org.esa.nest.dataio.polsarpro.PolsarProProductReaderPlugIn.java
@Override public DecodeQualification getDecodeQualification(Object input) { if (input instanceof File) { final File folder = (File) input; if (folder.isDirectory()) { final FileFilter filter = new SuffixFileFilter(EnviConstants.HDR_EXTENSION); for (File file : folder.listFiles(filter)) { final DecodeQualification fileQualification = super.getDecodeQualification(file); if (fileQualification != DecodeQualification.UNABLE) return fileQualification; }//from w ww . ja va 2 s . c o m return DecodeQualification.UNABLE; } } return DecodeQualification.UNABLE; //super.getDecodeQualification(input); }
From source file:org.fast.maven.plugin.AssemblyMojoTest.java
public void testIt1() throws Exception { String dir = "target/test-classes/it1"; String outputDir = "target/it1/generated-html"; File fileOutputDir = new File(getBasedir() + "/" + outputDir); FileUtils.deleteDirectory(fileOutputDir); AssemblyMojo mojo = (AssemblyMojo) newAssemblyMojo(dir, outputDir, DEFAULT_CHARSET); mojo.execute();//from w w w . j a v a 2 s .c o m assertSameContent(dir, outputDir, "page1.html"); assertSameContent(dir, outputDir, "page2.html"); assertSameContent(dir, outputDir, "page3.html"); Collection<?> staticFile = FileUtils.listFiles(fileOutputDir, new SuffixFileFilter(".css"), FileFilterUtils.trueFileFilter()); assertFalse("Ressources files were not copied", staticFile.isEmpty()); assertEquals(2, staticFile.size()); }
From source file:org.fast.maven.plugin.AssemblyMojoTest.java
public void testIt1Esi() throws Exception { String dir = "target/test-classes/it1-esi"; String outputDir = "target/it1-esi/generated-html"; File fileOutputDir = new File(getBasedir() + "/" + outputDir); FileUtils.deleteDirectory(fileOutputDir); AssemblyMojo mojo = (AssemblyMojo) newAssemblyMojo(dir, outputDir, DEFAULT_CHARSET); mojo.execute();/* w ww . j a v a 2 s . c om*/ assertSameContent(dir, outputDir, "page1.html"); Collection<?> staticFile = FileUtils.listFiles(fileOutputDir, new SuffixFileFilter(".css"), FileFilterUtils.trueFileFilter()); assertFalse("Ressources files were not copied", staticFile.isEmpty()); assertEquals(2, staticFile.size()); }
From source file:org.geoserver.config.GeoServerLoader.java
void loadStyles(File styles, Catalog catalog, XStreamPersister xp) { for (File sf : list(styles, new SuffixFileFilter(".xml"))) { try {/*from w w w. java2s.c o m*/ //handle the .xml.xml case if (new File(styles, sf.getName() + ".xml").exists()) { continue; } StyleInfo s = depersist(xp, sf, StyleInfo.class); catalog.add(s); LOGGER.info("Loaded style '" + s.getName() + "'"); } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to load style from file '" + sf.getName() + "'", e); } } }
From source file:org.geoserver.config.GeoServerLoader.java
void loadLayerGroups(File layergroups, Catalog catalog, XStreamPersister xp) { for (File lgf : list(layergroups, new SuffixFileFilter(".xml"))) { try {/* www.j av a2s . c o m*/ LayerGroupInfo lg = depersist(xp, lgf, LayerGroupInfo.class); if (lg.getLayers() == null || lg.getLayers().size() == 0) { LOGGER.warning("Skipping empty layer group '" + lg.getName() + "', it is invalid"); continue; } catalog.add(lg); LOGGER.info("Loaded layer group '" + lg.getName() + "'"); } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to load layer group '" + lgf.getName() + "'", e); } } }
From source file:org.geoserver.config.hibernate.HibGeoServerLoader.java
/** * Does some post processing on the catalog to ensure that the "well-known" styles are always * around.//www .j a v a2 s . c o m */ void initializeStyles(Catalog catalog) { if (catalog.getStyleByName(StyleInfo.DEFAULT_POINT) == null) { initializeStyle(catalog, StyleInfo.DEFAULT_POINT, "default_point.sld"); } if (catalog.getStyleByName(StyleInfo.DEFAULT_LINE) == null) { initializeStyle(catalog, StyleInfo.DEFAULT_LINE, "default_line.sld"); } if (catalog.getStyleByName(StyleInfo.DEFAULT_POLYGON) == null) { initializeStyle(catalog, StyleInfo.DEFAULT_POLYGON, "default_line.sld"); } if (catalog.getStyleByName(StyleInfo.DEFAULT_RASTER) == null) { initializeStyle(catalog, StyleInfo.DEFAULT_RASTER, "raster.sld"); } File styleDir = null; try { styleDir = resourceLoader.find("styles"); } catch (IOException ex) { Logger.getLogger(HibGeoServerLoader.class.getName()).log(Level.SEVERE, null, ex); } if (styleDir == null) { LOGGER.severe("Can't find styles dir."); return; } String[] sldlist = styleDir.list(new SuffixFileFilter(".sld")); for (String sldfilename : sldlist) { String stylename = FilenameUtils.getBaseName(sldfilename); if (catalog.getStyleByName(stylename) != null) { LOGGER.info("Style " + stylename + "exists."); continue; } StyleInfo style = this.catalog.getFactory().createStyle(); style.setName(stylename); style.setFilename(FilenameUtils.getName(sldfilename)); try { if (LOGGER.isLoggable(Level.INFO)) LOGGER.info("Importing SLD " + style.getName() + " in file " + sldfilename); catalog.add(style); } catch (Exception e) { LOGGER.severe("Could not import SLD " + style.getName() + " in file " + sldfilename); } } }