use of org.apache.commons.io.filefilter.IOFileFilter in project pcgen by PCGen.
the class ExportDialog method refreshFiles.
private void refreshFiles() {
if (allTemplates != null) {
String outputSheetsDir;
SheetFilter sheetFilter = (SheetFilter) exportBox.getSelectedItem();
IOFileFilter ioFilter = FileFilterUtils.asFileFilter(sheetFilter);
IOFileFilter prefixFilter;
String defaultSheet = null;
String outputSheetDirectory = SettingsHandler.getGame().getOutputSheetDirectory();
if (outputSheetDirectory == null) {
outputSheetsDir = ConfigurationSettings.getOutputSheetsDir() + "/" + sheetFilter.getPath();
} else {
outputSheetsDir = ConfigurationSettings.getOutputSheetsDir() + "/" + outputSheetDirectory + "/" + sheetFilter.getPath();
}
if (partyBox.isSelected()) {
prefixFilter = FileFilterUtils.prefixFileFilter(Constants.PARTY_TEMPLATE_PREFIX);
} else {
CharacterFacade character = (CharacterFacade) characterBox.getSelectedItem();
prefixFilter = FileFilterUtils.prefixFileFilter(Constants.CHARACTER_TEMPLATE_PREFIX);
defaultSheet = character.getDefaultOutputSheet(sheetFilter == SheetFilter.PDF);
if (StringUtils.isEmpty(defaultSheet)) {
defaultSheet = outputSheetsDir + "/" + SettingsHandler.getGame().getOutputSheetDefault(sheetFilter.getTag());
}
}
IOFileFilter filter = FileFilterUtils.and(prefixFilter, ioFilter);
List<File> files = FileFilterUtils.filterList(filter, allTemplates);
Collections.sort(files);
URI osPath = new File(outputSheetsDir).toURI();
Object[] uriList = new Object[files.size()];
for (int i = 0; i < uriList.length; i++) {
uriList[i] = osPath.relativize(files.get(i).toURI());
}
fileList.setListData(uriList);
if (StringUtils.isNotEmpty(defaultSheet)) {
URI defaultPath = new File(defaultSheet).toURI();
fileList.setSelectedValue(osPath.relativize(defaultPath), true);
}
}
}
use of org.apache.commons.io.filefilter.IOFileFilter in project ignite by apache.
the class CacheGroupMetricsWithIndexTest method testIndexRebuildCountPartitionsLeftInCluster.
/**
* Test number of partitions need to finished indexes rebuilding.
* <p>Case:
* <ul>
* <li>Start cluster, load data with indexes</li>
* <li>Kill single node, delete index.bin, start node.</li>
* <li>Make sure that index rebuild count is in range of total new index size and 0 and decreasing</li>
* <li>Wait until rebuild finished, assert that no index errors</li>
* </ul>
* </p>
*/
@Test
public void testIndexRebuildCountPartitionsLeftInCluster() throws Exception {
pds = true;
Ignite ignite = startGrid(0);
startGrid(1);
ignite.cluster().active(true);
IgniteCache<Object, Object> cache1 = ignite.cache(CACHE_NAME);
for (int i = 0; i < 100_000; i++) {
Long id = (long) i;
BinaryObjectBuilder o = ignite.binary().builder(OBJECT_NAME).setField(KEY_NAME, id).setField(COLUMN1_NAME, i / 2).setField(COLUMN2_NAME, "str" + Integer.toHexString(i));
cache1.put(id, o.build());
}
String consistentId = ignite.cluster().localNode().consistentId().toString();
stopGrid(0);
File dir = U.resolveWorkDirectory(U.defaultWorkDirectory(), DFLT_STORE_DIR, false);
IOFileFilter filter = FileFilterUtils.nameFileFilter("index.bin");
Collection<File> idxBinFiles = FileUtils.listFiles(dir, filter, TrueFileFilter.TRUE);
for (File indexBin : idxBinFiles) if (indexBin.getAbsolutePath().contains(consistentId))
U.delete(indexBin);
startGrid(0);
MetricRegistry metrics = cacheGroupMetrics(0, GROUP_NAME).get2();
LongMetric idxBuildCntPartitionsLeft = metrics.findMetric("IndexBuildCountPartitionsLeft");
assertTrue("Timeout wait start rebuild index", waitForCondition(() -> idxBuildCntPartitionsLeft.value() > 0, 30_000));
assertTrue("Timeout wait finished rebuild index", GridTestUtils.waitForCondition(() -> idxBuildCntPartitionsLeft.value() == 0, 30_000));
}
use of org.apache.commons.io.filefilter.IOFileFilter in project project-build-plugin by axonivy.
the class FileLogForwarder method activate.
public synchronized void activate() throws MojoExecutionException {
IOFileFilter logFilter = FileFilterUtils.and(FileFilterUtils.fileFileFilter(), FileFilterUtils.nameFileFilter(engineLog.getName()));
FileAlterationObserver fileObserver = new FileAlterationObserver(engineLog.getParent(), logFilter);
fileObserver.addListener(new LogModificationListener());
monitor = new FileAlterationMonitor(100);
monitor.addObserver(fileObserver);
try {
monitor.start();
} catch (Exception ex) {
throw new MojoExecutionException("Failed to activate deploy log forwarder", ex);
}
}
use of org.apache.commons.io.filefilter.IOFileFilter in project jo-client-platform by jo-source.
the class TemplateReplacer method list.
private static Collection<File> list(final File dir, final IOFileFilter dirFilter) {
final Collection<File> result = new LinkedList<File>();
final IOFileFilter projectFilter = FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter(".project"));
final IOFileFilter classpathFilter = FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter(".classpath"));
final IOFileFilter checkstyleFilter = FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter(".checkstyle"));
final IOFileFilter excludeFilesFilter = FileFilterUtils.and(projectFilter, classpathFilter, checkstyleFilter);
final IOFileFilter noDirsFilter = FileFilterUtils.notFileFilter(DirectoryFileFilter.INSTANCE);
final IOFileFilter fileFilter = FileFilterUtils.and(excludeFilesFilter, FileFilterUtils.or(noDirsFilter, dirFilter));
listRecursive(result, dir, fileFilter);
return result;
}
use of org.apache.commons.io.filefilter.IOFileFilter in project atlas by alibaba.
the class TPatchTool method doBundleResPatch.
public void doBundleResPatch(String bundleName, File destPatchBundleDir, File newBundleUnzipFolder, File baseBundleUnzipFolder) throws IOException {
// compare resource changes
Collection<File> newBundleResFiles = FileUtils.listFiles(newBundleUnzipFolder, new IOFileFilter() {
@Override
public boolean accept(File file) {
// 不包括dex文件
if (file.getName().endsWith(".dex")) {
return false;
}
String relativePath = PathUtils.toRelative(newBundleUnzipFolder, file.getAbsolutePath());
if (null != ((TpatchInput) (input)).notIncludeFiles && pathMatcher.match(((TpatchInput) (input)).notIncludeFiles, relativePath)) {
return false;
}
return true;
}
@Override
public boolean accept(File file, String s) {
return accept(new File(file, s));
}
}, TrueFileFilter.INSTANCE);
for (File newBundleResFile : newBundleResFiles) {
String resPath = PathUtils.toRelative(newBundleUnzipFolder, newBundleResFile.getAbsolutePath());
File baseBundleResFile = new File(baseBundleUnzipFolder, resPath);
File destResFile = new File(destPatchBundleDir, resPath);
if (baseBundleResFile.exists()) {
if (isFileModify(newBundleResFile, baseBundleResFile, bundleName, resPath)) {
// modify resource
if (baseBundleResFile.getName().endsWith(".so")) {
if (((TpatchInput) input).diffNativeSo && ((TpatchInput) input).diffBundleSo) {
destResFile = new File(destPatchBundleDir, resPath.concat(".patch"));
SoDiffUtils.diffSo(baseBundleResFile.getParentFile(), baseBundleResFile, newBundleResFile, destResFile);
} else {
FileUtils.copyFile(newBundleResFile, destResFile);
}
} else {
FileUtils.copyFile(newBundleResFile, destResFile);
}
}
} else {
// new resource
FileUtils.copyFile(newBundleResFile, destResFile);
}
}
}
Aggregations