Search in sources :

Example 6 with SearcherProvider

use of org.eclipse.che.api.vfs.search.SearcherProvider in project che by eclipse.

the class IndexedFileCreateConsumer method accept.

@Override
public void accept(Path path) {
    try {
        VirtualFileSystem virtualFileSystem = vfsProvider.getVirtualFileSystem();
        SearcherProvider searcherProvider = virtualFileSystem.getSearcherProvider();
        Searcher searcher = searcherProvider.getSearcher(virtualFileSystem);
        Path innerPath = root.toPath().relativize(path);
        org.eclipse.che.api.vfs.Path vfsPath = org.eclipse.che.api.vfs.Path.of(innerPath.toString());
        VirtualFile child = virtualFileSystem.getRoot().getChild(vfsPath);
        if (child != null) {
            searcher.add(child);
        }
    } catch (ServerException e) {
        LOG.error("Issue happened during adding created file to index", e);
    }
}
Also used : Path(java.nio.file.Path) VirtualFile(org.eclipse.che.api.vfs.VirtualFile) ServerException(org.eclipse.che.api.core.ServerException) VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) Searcher(org.eclipse.che.api.vfs.search.Searcher) SearcherProvider(org.eclipse.che.api.vfs.search.SearcherProvider)

Example 7 with SearcherProvider

use of org.eclipse.che.api.vfs.search.SearcherProvider in project che by eclipse.

the class IndexedFileDeleteConsumer method accept.

@Override
public void accept(Path path) {
    try {
        VirtualFileSystem virtualFileSystem = vfsProvider.getVirtualFileSystem();
        SearcherProvider searcherProvider = virtualFileSystem.getSearcherProvider();
        Searcher searcher = searcherProvider.getSearcher(virtualFileSystem);
        Path innerPath = root.toPath().relativize(path);
        searcher.delete("/" + innerPath.toString(), true);
    } catch (ServerException e) {
        LOG.error("Issue happened during removing deleted file from index", e);
    }
}
Also used : Path(java.nio.file.Path) ServerException(org.eclipse.che.api.core.ServerException) VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) Searcher(org.eclipse.che.api.vfs.search.Searcher) SearcherProvider(org.eclipse.che.api.vfs.search.SearcherProvider)

Example 8 with SearcherProvider

use of org.eclipse.che.api.vfs.search.SearcherProvider in project che by eclipse.

the class MemoryVirtualFileSystemTest method setUp.

@Before
public void setUp() throws Exception {
    SearcherProvider searcherProvider = mock(SearcherProvider.class);
    searcher = mock(Searcher.class);
    closeCallback = mock(AbstractVirtualFileSystemProvider.CloseCallback.class);
    fileSystem = new MemoryVirtualFileSystem(mock(ArchiverFactory.class), searcherProvider, closeCallback);
    when(searcherProvider.getSearcher(eq(fileSystem), anyBoolean())).thenReturn(searcher);
}
Also used : Searcher(org.eclipse.che.api.vfs.search.Searcher) SearcherProvider(org.eclipse.che.api.vfs.search.SearcherProvider) Before(org.junit.Before)

Example 9 with SearcherProvider

use of org.eclipse.che.api.vfs.search.SearcherProvider in project che by eclipse.

the class MemoryVirtualFileTest method setUp.

@Before
public void setUp() throws Exception {
    archiverFactory = mock(ArchiverFactory.class);
    SearcherProvider searcherProvider = mock(SearcherProvider.class);
    fileSystem = new MemoryVirtualFileSystem(archiverFactory, searcherProvider);
    searcher = mock(Searcher.class);
    when(searcherProvider.getSearcher(eq(fileSystem), eq(true))).thenReturn(searcher);
    when(searcherProvider.getSearcher(eq(fileSystem))).thenReturn(searcher);
}
Also used : Searcher(org.eclipse.che.api.vfs.search.Searcher) ArchiverFactory(org.eclipse.che.api.vfs.ArchiverFactory) SearcherProvider(org.eclipse.che.api.vfs.search.SearcherProvider) Before(org.junit.Before)

Aggregations

Searcher (org.eclipse.che.api.vfs.search.Searcher)9 SearcherProvider (org.eclipse.che.api.vfs.search.SearcherProvider)9 Before (org.junit.Before)6 File (java.io.File)4 Path (java.nio.file.Path)3 ServerException (org.eclipse.che.api.core.ServerException)3 VirtualFile (org.eclipse.che.api.vfs.VirtualFile)3 VirtualFileSystem (org.eclipse.che.api.vfs.VirtualFileSystem)3 ArchiverFactory (org.eclipse.che.api.vfs.ArchiverFactory)2 LocalVirtualFileSystem (org.eclipse.che.api.vfs.impl.file.LocalVirtualFileSystem)2 AbstractVirtualFileSystemProvider (org.eclipse.che.api.vfs.AbstractVirtualFileSystemProvider)1