use of org.apache.commons.io.filefilter.AndFileFilter in project cas by apereo.
the class UrlResourceMetadataResolver method cleanUpExpiredBackupMetadataFilesFor.
private void cleanUpExpiredBackupMetadataFilesFor(final AbstractResource metadataResource, final SamlRegisteredService service) {
val prefix = getBackupMetadataFilenamePrefix(metadataResource, service);
val backups = FileUtils.listFiles(this.metadataBackupDirectory, new AndFileFilter(CollectionUtils.wrapList(new PrefixFileFilter(prefix, IOCase.INSENSITIVE), new SuffixFileFilter(FILENAME_EXTENSION_XML, IOCase.INSENSITIVE), CanWriteFileFilter.CAN_WRITE, CanReadFileFilter.CAN_READ)), TrueFileFilter.INSTANCE);
backups.forEach(Unchecked.consumer(FileUtils::forceDelete));
}
use of org.apache.commons.io.filefilter.AndFileFilter in project symmetric-ds by JumpMind.
the class FileTrigger method createIOFileFilter.
public IOFileFilter createIOFileFilter() {
String[] includes = StringUtils.isNotBlank(includesFiles) ? includesFiles.split(",") : new String[] { "*" };
String[] excludes = StringUtils.isNotBlank(excludesFiles) ? excludesFiles.split(",") : null;
IOFileFilter filter = new WildcardFileFilter(includes);
if (excludes != null && excludes.length > 0) {
List<IOFileFilter> fileFilters = new ArrayList<IOFileFilter>();
fileFilters.add(filter);
fileFilters.add(new NotFileFilter(new WildcardFileFilter(excludes)));
filter = new AndFileFilter(fileFilters);
}
if (!recurse) {
List<IOFileFilter> fileFilters = new ArrayList<IOFileFilter>();
fileFilters.add(filter);
fileFilters.add(new NotFileFilter(FileFilterUtils.directoryFileFilter()));
filter = new AndFileFilter(fileFilters);
} else {
List<IOFileFilter> fileFilters = new ArrayList<IOFileFilter>();
fileFilters.add(filter);
fileFilters.add(FileFilterUtils.directoryFileFilter());
filter = new OrFileFilter(fileFilters);
}
return filter;
}
Aggregations