Search in sources :

Example 6 with VirtualFileSystem

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

the class CProjectGenerator method onCreateProject.

@Override
public void onCreateProject(Path projectPath, Map<String, AttributeValue> attributes, Map<String, String> options) throws ForbiddenException, ConflictException, ServerException {
    VirtualFileSystem vfs = virtualFileSystemProvider.getVirtualFileSystem();
    FolderEntry baseFolder = new FolderEntry(vfs.getRoot().createFolder(projectPath.toString()));
    baseFolder.createFile(FILE_NAME, getClass().getClassLoader().getResourceAsStream("files/default_c_content"));
}
Also used : VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) FolderEntry(org.eclipse.che.api.project.server.FolderEntry)

Example 7 with VirtualFileSystem

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

the class CppProjectGenerator method onCreateProject.

@Override
public void onCreateProject(Path projectPath, Map<String, AttributeValue> attributes, Map<String, String> options) throws ForbiddenException, ConflictException, ServerException {
    VirtualFileSystem vfs = virtualFileSystemProvider.getVirtualFileSystem();
    FolderEntry baseFolder = new FolderEntry(vfs.getRoot().createFolder(projectPath.toString()));
    baseFolder.createFile(FILE_NAME, getClass().getClassLoader().getResourceAsStream("files/default_cpp_content"));
}
Also used : VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) FolderEntry(org.eclipse.che.api.project.server.FolderEntry)

Example 8 with VirtualFileSystem

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

the class SubversionProjectImporterTest method setUp.

@Before
public void setUp() throws Exception {
    // Bind components
    Injector injector = Guice.createInjector(new AbstractModule() {

        @Override
        protected void configure() {
            Multibinder.newSetBinder(binder(), ProjectImporter.class).addBinding().to(SubversionProjectImporter.class);
            Multibinder.newSetBinder(binder(), ProjectTypeDef.class).addBinding().to(SubversionProjectType.class);
            Multibinder.newSetBinder(binder(), ValueProviderFactory.class).addBinding().to(SubversionValueProviderFactory.class);
            bind(SshKeyProvider.class).toInstance(sshKeyProvider);
            bind(ProfileDao.class).toInstance(userProfileDao);
            bind(RepositoryUrlProvider.class).toInstance(repositoryUrlProvider);
        }
    });
    // Init virtual file system
    VirtualFileSystem virtualFileSystem = TestUtils.createVirtualFileSystem();
    root = virtualFileSystem.getRoot();
    // Create the test user
    TestUtils.createTestUser(userProfileDao);
    // Create the Subversion repository
    repoRoot = TestUtils.createGreekTreeRepository();
    projectImporter = injector.getInstance(SubversionProjectImporter.class);
}
Also used : VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) Injector(com.google.inject.Injector) ProjectTypeDef(org.eclipse.che.api.project.server.type.ProjectTypeDef) ValueProviderFactory(org.eclipse.che.api.project.server.type.ValueProviderFactory) AbstractModule(com.google.inject.AbstractModule) ProjectImporter(org.eclipse.che.api.project.server.importer.ProjectImporter) Before(org.junit.Before)

Example 9 with VirtualFileSystem

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

the class MemoryVirtualFileSystemProviderTest method resetsVirtualFileSystemInProviderAfterClosingVirtualFileSystem.

@Test
public void resetsVirtualFileSystemInProviderAfterClosingVirtualFileSystem() throws Exception {
    VirtualFileSystem fileSystem = fileSystemProvider.getVirtualFileSystem(true);
    assertNotNull(fileSystem);
    fileSystem.close();
    assertNull(fileSystemProvider.getVirtualFileSystem(false));
}
Also used : VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) Test(org.junit.Test)

Example 10 with VirtualFileSystem

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

the class JsonExampleCreateProjectHandler method onCreateProject.

@Override
public void onCreateProject(Path projectPath, Map<String, AttributeValue> attributes, Map<String, String> options) throws ForbiddenException, ConflictException, ServerException {
    VirtualFileSystem vfs = virtualFileSystemProvider.getVirtualFileSystem();
    FolderEntry baseFolder = new FolderEntry(vfs.getRoot().createFolder(projectPath.toString()));
    try (InputStream packageJson = getClass().getClassLoader().getResourceAsStream("files/default_package");
        InputStream personJson = getClass().getClassLoader().getResourceAsStream("files/default_person")) {
        FolderEntry myJsonFiles = baseFolder.createFolder("myJsonFiles");
        baseFolder.createFile(FILE_NAME, packageJson);
        myJsonFiles.createFile("person.json", personJson);
    } catch (IOException ioEx) {
        throw new ServerException(ioEx.getLocalizedMessage(), ioEx);
    }
}
Also used : ServerException(org.eclipse.che.api.core.ServerException) VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) InputStream(java.io.InputStream) FolderEntry(org.eclipse.che.api.project.server.FolderEntry) IOException(java.io.IOException)

Aggregations

VirtualFileSystem (org.eclipse.che.api.vfs.VirtualFileSystem)63 MemoryVirtualFileSystem (org.eclipse.che.api.vfs.impl.memory.MemoryVirtualFileSystem)32 Test (org.junit.Test)29 QueryExpression (org.eclipse.che.api.vfs.search.QueryExpression)28 VirtualFile (org.eclipse.che.api.vfs.VirtualFile)27 Test (org.testng.annotations.Test)18 FolderEntry (org.eclipse.che.api.project.server.FolderEntry)9 Searcher (org.eclipse.che.api.vfs.search.Searcher)7 SearchResult (org.eclipse.che.api.vfs.search.SearchResult)6 ServerException (org.eclipse.che.api.core.ServerException)5 Path (java.nio.file.Path)3 SearcherProvider (org.eclipse.che.api.vfs.search.SearcherProvider)3 IOException (java.io.IOException)2 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 File (java.io.File)1 InputStream (java.io.InputStream)1 TimeoutException (java.util.concurrent.TimeoutException)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 ProjectImporter (org.eclipse.che.api.project.server.importer.ProjectImporter)1