Search in sources :

Example 11 with Searcher

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

the class FSLuceneSearcherProviderTest method returnsSameInstanceOfSearcherOnceItWasCreated.

@Test
public void returnsSameInstanceOfSearcherOnceItWasCreated() throws Exception {
    VirtualFileSystem virtualFileSystem = mockVirtualFileSystem();
    Searcher searcher = fsLuceneSearcherProvider.getSearcher(virtualFileSystem, true);
    assertNotNull(searcher);
    assertSame(searcher, fsLuceneSearcherProvider.getSearcher(virtualFileSystem, true));
}
Also used : VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) Searcher(org.eclipse.che.api.vfs.search.Searcher) Test(org.junit.Test)

Example 12 with Searcher

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

the class MemoryLuceneSearcherProviderTest method closesSearcherWhenProviderIsClosed.

@Test
public void closesSearcherWhenProviderIsClosed() throws Exception {
    Searcher searcher = mock(Searcher.class);
    memoryLuceneSearcherProvider.searcherReference.set(searcher);
    memoryLuceneSearcherProvider.close();
    verify(searcher).close();
}
Also used : Searcher(org.eclipse.che.api.vfs.search.Searcher) Test(org.junit.Test)

Example 13 with Searcher

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

the class MemoryLuceneSearcherProviderTest method returnsSameInstanceOfSearcherOnceItWasCreated.

@Test
public void returnsSameInstanceOfSearcherOnceItWasCreated() throws Exception {
    VirtualFileSystem virtualFileSystem = mockVirtualFileSystem();
    Searcher searcher = memoryLuceneSearcherProvider.getSearcher(virtualFileSystem, true);
    assertNotNull(searcher);
    assertSame(searcher, memoryLuceneSearcherProvider.getSearcher(virtualFileSystem, false));
}
Also used : VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) Searcher(org.eclipse.che.api.vfs.search.Searcher) Test(org.junit.Test)

Example 14 with Searcher

use of org.eclipse.che.api.vfs.search.Searcher 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 15 with Searcher

use of org.eclipse.che.api.vfs.search.Searcher 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)

Aggregations

Searcher (org.eclipse.che.api.vfs.search.Searcher)18 SearcherProvider (org.eclipse.che.api.vfs.search.SearcherProvider)9 VirtualFileSystem (org.eclipse.che.api.vfs.VirtualFileSystem)7 Before (org.junit.Before)6 Test (org.junit.Test)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 ArchiverFactory (org.eclipse.che.api.vfs.ArchiverFactory)2 LocalVirtualFileSystem (org.eclipse.che.api.vfs.impl.file.LocalVirtualFileSystem)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 ArrayList (java.util.ArrayList)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 ConflictException (org.eclipse.che.api.core.ConflictException)1 NotFoundException (org.eclipse.che.api.core.NotFoundException)1 ItemReference (org.eclipse.che.api.project.shared.dto.ItemReference)1