use of org.apache.commons.io.filefilter.NameFileFilter in project MtgDesktopCompanion by nicho92.
the class FileDAO method listCollectionFromCards.
@Override
public List<MagicCollection> listCollectionFromCards(MagicCard mc) throws SQLException {
String id = IDGenerator.generate(mc);
File f = new File(directory, CARDSDIR);
List<MagicCollection> ret = new ArrayList<>();
Collection<File> res = FileUtils.listFiles(f, new NameFileFilter(id), TrueFileFilter.INSTANCE);
for (File result : res) ret.add(new MagicCollection(result.getParentFile().getParentFile().getName()));
return ret;
}
use of org.apache.commons.io.filefilter.NameFileFilter in project pentaho-platform by pentaho.
the class FileSystemXmlPluginProvider method processDirectory.
@Override
protected void processDirectory(List<IPlatformPlugin> plugins, File folder, IPentahoSession session) throws PlatformPluginRegistrationException {
// see if there is a plugin.xml file
// $NON-NLS-1$
FilenameFilter filter = new NameFileFilter("plugin.xml", IOCase.SENSITIVE);
File[] kids = folder.listFiles(filter);
if (kids == null || kids.length == 0) {
return;
}
boolean hasLib = false;
// $NON-NLS-1$
filter = new NameFileFilter("lib", IOCase.SENSITIVE);
kids = folder.listFiles(filter);
if (kids != null && kids.length > 0) {
hasLib = kids[0].exists() && kids[0].isDirectory();
}
// we have found a plugin.xml file
// get the file from the repository
// $NON-NLS-1$ //$NON-NLS-2$
String path = "system" + File.separatorChar + folder.getName() + File.separatorChar + "plugin.xml";
Document doc;
try {
File f = new File(PentahoSystem.getApplicationContext().getSolutionPath(path));
InputStream in = new FileInputStream(f);
SAXReader reader = XMLParserFactoryProducer.getSAXReader(null);
doc = reader.read(in);
if (doc != null) {
plugins.add(createPlugin(doc, session, folder.getName(), hasLib));
}
} catch (Exception e) {
throw new PlatformPluginRegistrationException(Messages.getInstance().getErrorString("PluginManager.ERROR_0005_CANNOT_PROCESS_PLUGIN_XML", path), // $NON-NLS-1$
e);
}
if (doc == null) {
throw new PlatformPluginRegistrationException(Messages.getInstance().getErrorString("PluginManager.ERROR_0005_CANNOT_PROCESS_PLUGIN_XML", // $NON-NLS-1$
path));
}
}
Aggregations