Search in sources :

Example 1 with VirusCheckingFS

use of org.apache.lucene.mockfile.VirusCheckingFS in project lucene-solr by apache.

the class TestUtil method hasVirusChecker.

public static boolean hasVirusChecker(Path path) {
    FileSystem fs = path.getFileSystem();
    while (fs instanceof FilterFileSystem) {
        FilterFileSystem ffs = (FilterFileSystem) fs;
        if (ffs.getParent() instanceof VirusCheckingFS) {
            return true;
        }
        fs = ffs.getDelegate();
    }
    return false;
}
Also used : FileSystem(java.nio.file.FileSystem) FilterFileSystem(org.apache.lucene.mockfile.FilterFileSystem) FilterFileSystem(org.apache.lucene.mockfile.FilterFileSystem) VirusCheckingFS(org.apache.lucene.mockfile.VirusCheckingFS)

Example 2 with VirusCheckingFS

use of org.apache.lucene.mockfile.VirusCheckingFS in project lucene-solr by apache.

the class TestUtil method enableVirusChecker.

public static void enableVirusChecker(Directory in) {
    Directory dir = FilterDirectory.unwrap(in);
    if (dir instanceof FSDirectory) {
        FileSystem fs = ((FSDirectory) dir).getDirectory().getFileSystem();
        while (fs instanceof FilterFileSystem) {
            FilterFileSystem ffs = (FilterFileSystem) fs;
            if (ffs.getParent() instanceof VirusCheckingFS) {
                VirusCheckingFS vfs = (VirusCheckingFS) ffs.getParent();
                vfs.enable();
                return;
            }
            fs = ffs.getDelegate();
        }
    }
}
Also used : FileSystem(java.nio.file.FileSystem) FilterFileSystem(org.apache.lucene.mockfile.FilterFileSystem) FilterFileSystem(org.apache.lucene.mockfile.FilterFileSystem) FSDirectory(org.apache.lucene.store.FSDirectory) VirusCheckingFS(org.apache.lucene.mockfile.VirusCheckingFS) Directory(org.apache.lucene.store.Directory) RAMDirectory(org.apache.lucene.store.RAMDirectory) FSDirectory(org.apache.lucene.store.FSDirectory) FilterDirectory(org.apache.lucene.store.FilterDirectory)

Example 3 with VirusCheckingFS

use of org.apache.lucene.mockfile.VirusCheckingFS in project lucene-solr by apache.

the class TestUtil method disableVirusChecker.

/** Returns true if VirusCheckingFS is in use and was in fact already enabled */
public static boolean disableVirusChecker(Directory in) {
    Directory dir = FilterDirectory.unwrap(in);
    if (dir instanceof FSDirectory) {
        FileSystem fs = ((FSDirectory) dir).getDirectory().getFileSystem();
        while (fs instanceof FilterFileSystem) {
            FilterFileSystem ffs = (FilterFileSystem) fs;
            if (ffs.getParent() instanceof VirusCheckingFS) {
                VirusCheckingFS vfs = (VirusCheckingFS) ffs.getParent();
                boolean isEnabled = vfs.isEnabled();
                vfs.disable();
                return isEnabled;
            }
            fs = ffs.getDelegate();
        }
    }
    return false;
}
Also used : FileSystem(java.nio.file.FileSystem) FilterFileSystem(org.apache.lucene.mockfile.FilterFileSystem) FilterFileSystem(org.apache.lucene.mockfile.FilterFileSystem) FSDirectory(org.apache.lucene.store.FSDirectory) VirusCheckingFS(org.apache.lucene.mockfile.VirusCheckingFS) Directory(org.apache.lucene.store.Directory) RAMDirectory(org.apache.lucene.store.RAMDirectory) FSDirectory(org.apache.lucene.store.FSDirectory) FilterDirectory(org.apache.lucene.store.FilterDirectory)

Example 4 with VirusCheckingFS

use of org.apache.lucene.mockfile.VirusCheckingFS in project lucene-solr by apache.

the class LuceneTestCase method addVirusChecker.

public static Path addVirusChecker(Path path) {
    if (TestUtil.hasVirusChecker(path) == false) {
        VirusCheckingFS fs = new VirusCheckingFS(path.getFileSystem(), random().nextLong());
        FileSystem filesystem = fs.getFileSystem(URI.create("file:///"));
        path = new FilterPath(path, filesystem);
    }
    return path;
}
Also used : FilterPath(org.apache.lucene.mockfile.FilterPath) FileSystem(java.nio.file.FileSystem) VirusCheckingFS(org.apache.lucene.mockfile.VirusCheckingFS)

Aggregations

FileSystem (java.nio.file.FileSystem)4 VirusCheckingFS (org.apache.lucene.mockfile.VirusCheckingFS)4 FilterFileSystem (org.apache.lucene.mockfile.FilterFileSystem)3 Directory (org.apache.lucene.store.Directory)2 FSDirectory (org.apache.lucene.store.FSDirectory)2 FilterDirectory (org.apache.lucene.store.FilterDirectory)2 RAMDirectory (org.apache.lucene.store.RAMDirectory)2 FilterPath (org.apache.lucene.mockfile.FilterPath)1