Search in sources :

Example 6 with AndFileFilter

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));
}
Also used : lombok.val(lombok.val) AndFileFilter(org.apache.commons.io.filefilter.AndFileFilter) SuffixFileFilter(org.apache.commons.io.filefilter.SuffixFileFilter) PrefixFileFilter(org.apache.commons.io.filefilter.PrefixFileFilter)

Example 7 with AndFileFilter

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;
}
Also used : AndFileFilter(org.apache.commons.io.filefilter.AndFileFilter) OrFileFilter(org.apache.commons.io.filefilter.OrFileFilter) ArrayList(java.util.ArrayList) IOFileFilter(org.apache.commons.io.filefilter.IOFileFilter) NotFileFilter(org.apache.commons.io.filefilter.NotFileFilter) WildcardFileFilter(org.apache.commons.io.filefilter.WildcardFileFilter)

Aggregations

AndFileFilter (org.apache.commons.io.filefilter.AndFileFilter)7 File (java.io.File)5 WildcardFileFilter (org.apache.commons.io.filefilter.WildcardFileFilter)4 PrefixFileFilter (org.apache.commons.io.filefilter.PrefixFileFilter)3 SuffixFileFilter (org.apache.commons.io.filefilter.SuffixFileFilter)3 ArrayList (java.util.ArrayList)2 IOFileFilter (org.apache.commons.io.filefilter.IOFileFilter)2 NotFileFilter (org.apache.commons.io.filefilter.NotFileFilter)2 NSString (com.dd.plist.NSString)1 FileFilter (java.io.FileFilter)1 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 lombok.val (lombok.val)1 FileFileFilter (org.apache.commons.io.filefilter.FileFileFilter)1 NameFileFilter (org.apache.commons.io.filefilter.NameFileFilter)1 OrFileFilter (org.apache.commons.io.filefilter.OrFileFilter)1 RegexFileFilter (org.apache.commons.io.filefilter.RegexFileFilter)1 SimpleCustomProperty (org.gluu.model.SimpleCustomProperty)1