use of org.apache.commons.io.filefilter.SuffixFileFilter in project gocd by gocd.
the class JobResourceImporter method getArtifactFilesOfType.
File[] getArtifactFilesOfType(String artifactsPathFromRoot, String jobArtifactPath, final String fileExtension) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("getArtifactFilesOfType(" + artifactsPathFromRoot + ", " + jobArtifactPath + ", " + fileExtension + ")");
}
File jobArtifactFile = new File(artifactBaseDir, artifactsPathFromRoot + File.separator + jobArtifactPath);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Artifact directory calculated to be " + jobArtifactFile.getAbsolutePath());
}
if (!jobArtifactFile.exists() || !jobArtifactFile.isDirectory()) {
return new File[0];
}
Collection collection = FileUtils.listFiles(jobArtifactFile, new SuffixFileFilter(fileExtension, IOCase.INSENSITIVE), TrueFileFilter.INSTANCE);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("" + collection.size() + " artifact files found.");
}
return (File[]) collection.toArray(new File[0]);
}
use of org.apache.commons.io.filefilter.SuffixFileFilter in project stanbol by apache.
the class ManagedIndexMetadata method loadIndexConfigs.
/**
* Loads the configurations of uninitialised Solr Indexes
*
* @return the map with the index name as key and the properties as values
* @throws IOException
* on any error while loading the configurations
*/
private Map<String, IndexMetadata> loadIndexConfigs() throws IOException {
File uninstalledConfigDir = getIndexConfigDirectory(false);
Map<String, IndexMetadata> configs = new HashMap<String, IndexMetadata>();
synchronized (pid) {
if (uninstalledConfigDir.exists()) {
for (String file : uninstalledConfigDir.list(new SuffixFileFilter(ConfigUtils.SOLR_INDEX_ARCHIVE_EXTENSION + ".ref"))) {
String indexName = file.substring(0, file.indexOf('.'));
File configFile = new File(uninstalledConfigDir, file);
IndexMetadata props = new IndexMetadata();
InputStream is = null;
try {
is = new FileInputStream(configFile);
props.load(is);
//validate Index-Name and Server-Name properties!
if (!indexName.equals(props.getIndexName())) {
throw new IOException("The IndexName '" + props.getIndexName() + "within the IndexConfig file does not correspond to the file name '" + file + "'!");
}
if (!serverName.equals(props.getServerName())) {
throw new IOException("The Name of the Referenced Solr server '" + serverName + " does not correspond with the Server-Name value '" + props.getServerName() + "' within the property file '" + file + "'!");
}
configs.put(indexName, props);
} finally {
IOUtils.closeQuietly(is);
}
}
}
}
return configs;
}
use of org.apache.commons.io.filefilter.SuffixFileFilter in project robovm by robovm.
the class IOSTarget method packageApplication.
private void packageApplication(File appDir) throws IOException {
File ipaFile = new File(config.getInstallDir(), getExecutable() + ".ipa");
config.getLogger().info("Packaging IPA %s from %s", ipaFile.getName(), appDir.getName());
File tmpDir = new File(config.getInstallDir(), "ipabuild");
FileUtils.deleteDirectory(tmpDir);
tmpDir.mkdirs();
File payloadDir = new File(tmpDir, "Payload");
payloadDir.mkdir();
config.getLogger().info("Copying %s to %s", appDir.getName(), payloadDir);
new Executor(config.getLogger(), "cp").args("-Rp", appDir, payloadDir).exec();
File frameworksDir = new File(appDir, "Frameworks");
if (frameworksDir.exists()) {
String[] swiftLibs = frameworksDir.list(new AndFileFilter(new PrefixFileFilter("libswift"), new SuffixFileFilter(".dylib")));
if (swiftLibs.length > 0) {
File swiftSupportDir = new File(tmpDir, "SwiftSupport");
swiftSupportDir.mkdir();
copySwiftLibs(Arrays.asList(swiftLibs), swiftSupportDir);
}
}
config.getLogger().info("Zipping %s to %s", tmpDir, ipaFile);
new Executor(Logger.NULL_LOGGER, "zip").wd(tmpDir).args("--symlinks", "--recurse-paths", ipaFile, ".").exec();
config.getLogger().info("Deleting temp dir %s", tmpDir);
FileUtils.deleteDirectory(tmpDir);
}
use of org.apache.commons.io.filefilter.SuffixFileFilter in project robovm by robovm.
the class InterfaceBuilderClassesPlugin method buildClassToUrlMap.
private Map<String, URL> buildClassToUrlMap(List<File> paths) {
// Reverse the list since classes in the first paths should take
// precedence over classes in latter paths.
Collections.reverse(paths);
Map<String, URL> classToUrlMap = new HashMap<>();
for (File path : paths) {
if (isJarFile(path)) {
try (ZipFile zipFile = new ZipFile(path)) {
for (ZipEntry entry : Collections.list(zipFile.entries())) {
if (!entry.isDirectory()) {
if (FilenameUtils.isExtension(entry.getName(), CLASS_EXTENSION)) {
String className = FilenameUtils.removeExtension(entry.getName()).replace('/', '.');
URL url = new URL("jar", null, -1, path.toURI().toString() + "!/" + entry.getName());
classToUrlMap.put(className, url);
}
}
}
} catch (IOException e) {
logger.warn("Failed to read JAR/ZIP file %s: %s", path.getAbsolutePath(), e.getMessage());
}
} else if (path.isDirectory()) {
path = path.getAbsoluteFile();
for (File f : FileUtils.listFiles(path, new SuffixFileFilter("." + CLASS_EXTENSION), new PackageNameFilter(path.getAbsolutePath()))) {
String className = FilenameUtils.removeExtension(f.getAbsolutePath());
className = className.substring(path.getAbsolutePath().length() + 1);
className = className.replace(File.separatorChar, '.');
try {
classToUrlMap.put(className, f.toURI().toURL());
} catch (MalformedURLException e) {
throw new Error(e);
}
}
}
}
return classToUrlMap;
}
use of org.apache.commons.io.filefilter.SuffixFileFilter in project ddf by codice.
the class ConfigurationFilesPoller method register.
public void register(ChangeListener listener) {
notNull(listener, "ChangeListener cannot be null");
changeListener = listener;
fileAlterationObserver = new FileAlterationObserver(configurationDirectoryPath.toAbsolutePath().toString(), new SuffixFileFilter(fileExtension));
fileAlterationObserver.addListener(this);
watchService = new FileAlterationMonitor(POLLING_INTERVAL, fileAlterationObserver);
try {
watchService.start();
} catch (Exception e) {
logStackAndMessageSeparately(e, "Failed to start, 'Platform :: Migration' must be restarted: ");
}
}
Aggregations