use of java.io.FilenameFilter in project neo4j by neo4j.
the class StoreFilesTest method moveMustIgnoreFilesFilteredOut.
@Test
public void moveMustIgnoreFilesFilteredOut() throws Exception {
File base = getBaseDir();
File src = new File(base, "src");
File a = new File(src, "a");
File b = new File(src, "b");
File ignore = new File(src, "ignore");
File c = new File(ignore, "c");
File d = new File(ignore, "d");
File tgt = new File(base, "tgt");
createOnFileSystem(a);
createOnPageCache(b);
createOnFileSystem(c);
createOnPageCache(d);
// Ensure the 'tgt' directory exists
createOnFileSystem(new File(tgt, ".fs-ignore"));
createOnPageCache(new File(tgt, ".pc-ignore"));
FilenameFilter filter = (directory, name) -> !name.startsWith("ignore");
storeFiles = new StoreFiles(fs, pageCache, filter);
storeFiles.moveTo(src, tgt);
assertFalse(fs.fileExists(a));
assertFalse(pc.fileExists(b));
assertTrue(fs.fileExists(c));
assertTrue(pc.fileExists(d));
assertTrue(fs.fileExists(new File(tgt, "a")));
assertTrue(pc.fileExists(new File(tgt, "b")));
}
use of java.io.FilenameFilter in project neo4j by neo4j.
the class StoreFilesTest method isEmptyMustFindFilesBothOnFileSystemAndPageCache.
@Test
public void isEmptyMustFindFilesBothOnFileSystemAndPageCache() throws Exception {
File dir = getBaseDir();
File ignore = new File(dir, "ignore");
File a = new File(dir, "a");
File b = new File(dir, "b");
File c = new File(dir, "c");
File d = new File(dir, "d");
createOnFileSystem(a);
createOnFileSystem(c);
createOnFileSystem(ignore);
createOnPageCache(b);
createOnPageCache(d);
createOnPageCache(ignore);
FilenameFilter filter = (directory, name) -> !name.startsWith("ignore");
storeFiles = new StoreFiles(fs, pageCache, filter);
List<File> filesOnFilesystem = Arrays.asList(new File[] { a, c });
List<File> fileOnFilesystem = Arrays.asList(new File[] { a });
List<File> filesOnPageCache = Arrays.asList(new File[] { b, d });
List<File> fileOnPageCache = Arrays.asList(new File[] { b });
List<File> ingore = Arrays.asList(new File[] { ignore });
assertFalse(storeFiles.isEmpty(dir, filesOnFilesystem));
assertFalse(storeFiles.isEmpty(dir, fileOnFilesystem));
assertFalse(storeFiles.isEmpty(dir, filesOnPageCache));
assertFalse(storeFiles.isEmpty(dir, fileOnPageCache));
assertTrue(storeFiles.isEmpty(dir, Collections.emptyList()));
assertTrue(storeFiles.isEmpty(dir, ingore));
}
use of java.io.FilenameFilter in project OpenAM by OpenRock.
the class EmbeddedOpenDS method getOpenDSVersion.
public static String getOpenDSVersion() {
Debug debug = Debug.getInstance(SetupConstants.DEBUG_NAME);
String odsRoot = AMSetupServlet.getBaseDir() + "/" + SetupConstants.SMS_OPENDS_DATASTORE;
String version = "unknown";
File configLdif = new File(odsRoot + OPENDS_UPGRADE_DIR);
File buildInfo = new File(odsRoot + "/" + "config" + "/" + SetupConstants.OPENDJ_BUILDINFO);
if (configLdif.exists() && configLdif.isDirectory()) {
String[] configFile = configLdif.list(new FilenameFilter() {
//@Override -- Not Allowed Here.
public boolean accept(File dir, String name) {
return name.startsWith(OPENDS_CONFIG_LDIF);
}
});
if (configFile.length != 0) {
version = configFile[0].substring(configFile[0].lastIndexOf('.') + 1);
} else {
debug.error("Unable to determine OpenDJ version");
}
} else if (buildInfo.exists() && buildInfo.canRead() && buildInfo.isFile()) {
String buildInfoVersionText = getOpenDJBuildInfo(buildInfo);
if ((buildInfoVersionText != null) && (!buildInfoVersionText.isEmpty())) {
version = buildInfoVersionText.trim();
} else {
debug.error("Unable to determine OpenDJ version");
}
} else {
if (debug.warningEnabled()) {
debug.warning("Unable to determine OpenDJ version; could be pre-config");
}
}
if (debug.messageEnabled()) {
debug.message("Found OpenDJ version: " + version);
}
return version;
}
use of java.io.FilenameFilter in project tdi-studio-se by Talend.
the class FilterFileSystemStructureProvider method getChildren.
/*
* (non-Javadoc) Method declared on IImportStructureProvider
*/
public List getChildren(Object element) {
File folder = (File) element;
File[] files = folder.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return !FilesUtils.isSVNFolder(name);
}
});
int childrenLength = files == null ? 0 : files.length;
List<File> result = new ArrayList(childrenLength);
for (int i = 0; i < childrenLength; i++) {
result.add(files[i]);
}
return result;
}
use of java.io.FilenameFilter in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method addSourceCode.
protected void addSourceCode(ExportFileResource[] allResources, ProcessItem processItem, boolean needSource, ExportFileResource resource, String... selectedJobVersion) {
// Get java src
if (!needSource) {
return;
}
try {
String projectName = getCorrespondingProjectName(processItem);
String jobName = processItem.getProperty().getLabel();
String jobVersion = processItem.getProperty().getVersion();
if (!isMultiNodes() && selectedJobVersion != null && selectedJobVersion.length == 1) {
jobVersion = selectedJobVersion[0];
}
String jobFolderName = JavaResourcesHelper.getJobFolderName(jobName, jobVersion);
IPath path = getSrcRootLocation();
path = path.append(projectName).append(jobFolderName);
FilenameFilter filter = new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
//$NON-NLS-1$
return name.toLowerCase().endsWith(".java");
}
};
List<URL> javaFileUrls = new ArrayList<URL>();
File file = path.toFile();
if (file.exists() && file.isDirectory()) {
for (File curFile : file.listFiles(filter)) {
javaFileUrls.add(FileLocator.toFileURL(curFile.toURL()));
}
}
resource.addResources(JOB_SOURCE_FOLDER_NAME + PATH_SEPARATOR + projectName + PATH_SEPARATOR + jobFolderName, javaFileUrls);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
Aggregations