use of nl.nn.adapterframework.util.WildCardFilter in project iaf by ibissource.
the class FileSystemUtils method getFilteredStream.
public static <F> Stream<F> getFilteredStream(IBasicFileSystem<F> fileSystem, String folder, String wildCard, String excludeWildCard) throws FileSystemException, IOException {
DirectoryStream<F> ds = fileSystem.listFiles(folder);
if (ds == null) {
return null;
}
Iterator<F> it = ds.iterator();
if (it == null) {
return null;
}
WildCardFilter wildcardfilter = StringUtils.isEmpty(wildCard) ? null : new WildCardFilter(wildCard);
WildCardFilter excludeFilter = StringUtils.isEmpty(excludeWildCard) ? null : new WildCardFilter(excludeWildCard);
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(it, 0), false).filter(F -> (wildcardfilter == null || wildcardfilter.accept(null, fileSystem.getName((F) F))) && (excludeFilter == null || !excludeFilter.accept(null, fileSystem.getName((F) F)))).onClose(() -> {
try {
ds.close();
} catch (IOException e) {
throw Lombok.sneakyThrow(e);
}
});
}
use of nl.nn.adapterframework.util.WildCardFilter in project iaf by ibissource.
the class FileRecordListener method getFileToProcess.
/**
* Gets a file to process.
*/
protected File getFileToProcess() {
WildCardFilter filter = new WildCardFilter(wildcard);
File dir = new File(getInputDirectory());
File[] files = dir.listFiles(filter);
int count = (files == null ? 0 : files.length);
for (int i = 0; i < count; i++) {
File file = files[i];
if (file.isDirectory()) {
continue;
}
return (file);
}
return null;
}
use of nl.nn.adapterframework.util.WildCardFilter in project iaf by ibissource.
the class IbisDailyRollingFileAppender method subAppend.
public void subAppend(LoggingEvent event) {
super.subAppend(event);
String n = DateUtils.format(new Date(), DateUtils.shortIsoFormat);
// cleaning up files is done once a day
if (n.compareTo(nextCheck) > 0) {
nextCheck = n;
long deleteBefore = System.currentTimeMillis() - retentionDays * millisPerDay;
String msgLogFileName = getFile();
File msgLogFile = new File(msgLogFileName);
String dirName = msgLogFile.getParent();
String fileWithoutDirName = msgLogFile.getName();
WildCardFilter filter = new WildCardFilter(fileWithoutDirName + ".*");
File dir = new File(dirName);
File[] files = dir.listFiles(filter);
int count = (files == null ? 0 : files.length);
for (int i = 0; i < count; i++) {
File file = files[i];
if (file.isDirectory()) {
continue;
}
if (file.lastModified() < deleteBefore) {
LogLog.debug("Deleting file " + file);
file.delete();
}
}
}
}
Aggregations