Search in sources :

Example 31 with VirtualFile

use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.

the class MemoryLuceneSearcherTest method initializesIndexForExistedFiles.

@Test
public void initializesIndexForExistedFiles() throws Exception {
    VirtualFileSystem virtualFileSystem = virtualFileSystem();
    VirtualFile folder = virtualFileSystem.getRoot().createFolder("folder");
    folder.createFile("xxx.txt", TEST_CONTENT[2]);
    folder.createFile("zzz.txt", TEST_CONTENT[1]);
    searcher.init(virtualFileSystem);
    List<String> paths = searcher.search(new QueryExpression().setText("think")).getFilePaths();
    assertEquals(newArrayList("/folder/zzz.txt"), paths);
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) MemoryVirtualFileSystem(org.eclipse.che.api.vfs.impl.memory.MemoryVirtualFileSystem) VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) QueryExpression(org.eclipse.che.api.vfs.search.QueryExpression) Test(org.junit.Test)

Example 32 with VirtualFile

use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.

the class WorkspaceTest method testAddingNewModule.

@Test
public void testAddingNewModule() throws Exception {
    String pom = "<groupId>test</groupId>" + "<artifactId>testArtifact</artifactId>" + "<version>42</version>" + "<modules>" + "    <module>module1</module>" + "</modules>";
    FolderEntry parentFolder = createTestProject("parent", pom);
    String pomModule1 = "<groupId>test</groupId>" + "<artifactId>testModule1</artifactId>" + "<version>1</version>" + "<dependencies>" + "    <dependency>" + "        <groupId>junit</groupId>" + "        <artifactId>junit</artifactId>" + "        <version>4.12</version>" + "    </dependency>" + "</dependencies>";
    createTestProject("parent/module1", pomModule1);
    IProject parent = ResourcesPlugin.getWorkspace().getRoot().getProject("parent");
    mavenWorkspace.update(Collections.singletonList(parent));
    mavenWorkspace.waitForUpdate();
    assertThat(projectRegistry.getProjects()).hasSize(2).onProperty("path").containsOnly("/parent", "/parent/module1");
    VirtualFile parentPom = parentFolder.getChild("pom.xml").getVirtualFile();
    Model model = Model.readFrom(parentPom);
    List<String> modules = new ArrayList<>(model.getModules());
    modules.add("module2");
    model.setModules(modules);
    model.writeTo(parentPom);
    String pomModule2 = "<groupId>module2</groupId>" + "<artifactId>testModule2</artifactId>" + "<version>2</version>" + "<dependencies>" + "    <dependency>" + "        <groupId>junit</groupId>" + "        <artifactId>junit</artifactId>" + "        <version>4.12</version>" + "    </dependency>" + "</dependencies>";
    createTestProject("parent/module2", pomModule2);
    mavenWorkspace.update(Collections.singletonList(parent));
    mavenWorkspace.waitForUpdate();
    assertThat(projectRegistry.getProjects()).hasSize(3).onProperty("path").containsOnly("/parent", "/parent/module1", "/parent/module2");
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) FolderEntry(org.eclipse.che.api.project.server.FolderEntry) Model(org.eclipse.che.ide.maven.tools.Model) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Example 33 with VirtualFile

use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.

the class FolderEntry method getChildren.

public List<VirtualFileEntry> getChildren(VirtualFileFilter filter) throws ServerException {
    final List<VirtualFile> vfChildren = getVirtualFile().getChildren(filter);
    final List<VirtualFileEntry> children = new ArrayList<>();
    for (VirtualFile vf : vfChildren) {
        if (vf.isFile()) {
            children.add(new FileEntry(vf, projectRegistry));
        } else {
            children.add(new FolderEntry(vf, projectRegistry));
        }
    }
    return children;
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) ArrayList(java.util.ArrayList)

Example 34 with VirtualFile

use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.

the class FolderEntry method getChildFiles.

/**
     * Get child files of this folder. If current user doesn't have read access to some child they aren't added in result list.
     *
     * @throws ServerException
     *         if an error occurs
     */
public List<FileEntry> getChildFiles() throws ServerException {
    List<VirtualFile> vfChildren = getVirtualFile().getChildren(FILES_FILTER);
    final List<FileEntry> children = new ArrayList<>();
    for (VirtualFile c : vfChildren) {
        children.add(new FileEntry(c, projectRegistry));
    }
    return children;
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) ArrayList(java.util.ArrayList)

Example 35 with VirtualFile

use of org.eclipse.che.api.vfs.VirtualFile in project che by eclipse.

the class FolderEntry method getChildFolders.

/**
     * Gets child folders of this folder. If current user doesn't have read access to some child they aren't added in result list.
     *
     * @throws ServerException
     *         if an error occurs
     */
public List<FolderEntry> getChildFolders() throws ServerException {
    List<VirtualFile> vfChildren = getVirtualFile().getChildren(FOLDER_FILTER);
    final List<FolderEntry> children = new ArrayList<>();
    for (VirtualFile c : vfChildren) {
        children.add(new FolderEntry(c, projectRegistry));
    }
    return children;
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) ArrayList(java.util.ArrayList)

Aggregations

VirtualFile (org.eclipse.che.api.vfs.VirtualFile)321 Test (org.junit.Test)267 Path (org.eclipse.che.api.vfs.Path)62 ForbiddenException (org.eclipse.che.api.core.ForbiddenException)54 ByteArrayInputStream (java.io.ByteArrayInputStream)32 ConflictException (org.eclipse.che.api.core.ConflictException)28 VirtualFileSystem (org.eclipse.che.api.vfs.VirtualFileSystem)27 MemoryVirtualFileSystem (org.eclipse.che.api.vfs.impl.memory.MemoryVirtualFileSystem)22 QueryExpression (org.eclipse.che.api.vfs.search.QueryExpression)22 ServerException (org.eclipse.che.api.core.ServerException)18 Test (org.testng.annotations.Test)18 File (java.io.File)17 Archiver (org.eclipse.che.api.vfs.Archiver)14 InputStream (java.io.InputStream)10 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)7 OutputStream (java.io.OutputStream)6 LockedFileFinder (org.eclipse.che.api.vfs.LockedFileFinder)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 Map (java.util.Map)5