Search in sources :

Example 1 with FolderEntry

use of org.eclipse.che.api.project.server.FolderEntry 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)

Example 2 with FolderEntry

use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.

the class GitService method deleteRepository.

@DELETE
@Path("repository")
public void deleteRepository(@Context UriInfo uriInfo) throws ApiException {
    final RegisteredProject project = projectRegistry.getProject(projectPath);
    final FolderEntry gitFolder = project.getBaseFolder().getChildFolder(".git");
    gitFolder.getVirtualFile().delete();
    projectRegistry.removeProjectType(projectPath, GitProjectType.TYPE_ID);
}
Also used : FolderEntry(org.eclipse.che.api.project.server.FolderEntry) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 3 with FolderEntry

use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.

the class PomReconcilerTest method testReconcilePomWhenPomContainsDependecyWithIncorrectVersion.

@Test
public void testReconcilePomWhenPomContainsDependecyWithIncorrectVersion() throws Exception {
    String brokenDependency = "    <dependency>\n" + "        <groupId>junit</groupId>\n" + "        <artifactId>junit</artifactId>\n" + "        <version>33333333.8.1</version>\n" + "        <scope>test</scope>\n" + "    </dependency>\n";
    MavenServerService serverService = new MavenServerService(null, projectRegistry, pm, projectManager, null, null);
    FolderEntry testProject = createTestProject(PROJECT_NAME, getPomContentWithDependency(brokenDependency));
    VirtualFileEntry pom = testProject.getChild("pom.xml");
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
    mavenWorkspace.update(Collections.singletonList(project));
    mavenWorkspace.waitForUpdate();
    List<Problem> problems = serverService.reconcilePom(String.format("/%s/pom.xml", PROJECT_NAME));
    assertThat(problems).hasSize(1);
    assertThat(problems.get(0).isError()).isTrue();
    assertThat(pom).isNotNull();
}
Also used : FolderEntry(org.eclipse.che.api.project.server.FolderEntry) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) MavenServerService(org.eclipse.che.plugin.maven.server.rest.MavenServerService) Problem(org.eclipse.che.ide.ext.java.shared.dto.Problem) IProject(org.eclipse.core.resources.IProject) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Example 4 with FolderEntry

use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.

the class PomReconcilerTest method testReconcilePomWhenMavenProjectIsNotFound.

@Test
public void testReconcilePomWhenMavenProjectIsNotFound() throws Exception {
    MavenServerService serverService = new MavenServerService(null, projectRegistry, pm, projectManager, null, null);
    FolderEntry testProject = createTestProject(PROJECT_NAME, "");
    VirtualFileEntry pom = testProject.getChild("pom.xml");
    List<Problem> problems = serverService.reconcilePom(String.format("/%s/pom.xml", PROJECT_NAME));
    assertThat(problems).isEmpty();
    assertThat(pom).isNotNull();
}
Also used : FolderEntry(org.eclipse.che.api.project.server.FolderEntry) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) MavenServerService(org.eclipse.che.plugin.maven.server.rest.MavenServerService) Problem(org.eclipse.che.ide.ext.java.shared.dto.Problem) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Example 5 with FolderEntry

use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.

the class PomReconcilerTest method testReconcilePomWhenPomContainsCorrectDependency.

@Test
public void testReconcilePomWhenPomContainsCorrectDependency() throws Exception {
    String dependency = "    <dependency>\n" + "        <groupId>junit</groupId>\n" + "        <artifactId>junit</artifactId>\n" + "        <version>3.8.1</version>\n" + "        <scope>test</scope>\n" + "    </dependency>\n";
    MavenServerService serverService = new MavenServerService(null, projectRegistry, pm, projectManager, null, null);
    FolderEntry testProject = createTestProject(PROJECT_NAME, getPomContentWithDependency(dependency));
    VirtualFileEntry pom = testProject.getChild("pom.xml");
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
    mavenWorkspace.update(Collections.singletonList(project));
    mavenWorkspace.waitForUpdate();
    List<Problem> problems = serverService.reconcilePom(String.format("/%s/pom.xml", PROJECT_NAME));
    assertThat(problems).isEmpty();
    assertThat(pom).isNotNull();
}
Also used : FolderEntry(org.eclipse.che.api.project.server.FolderEntry) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) MavenServerService(org.eclipse.che.plugin.maven.server.rest.MavenServerService) Problem(org.eclipse.che.ide.ext.java.shared.dto.Problem) IProject(org.eclipse.core.resources.IProject) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Aggregations

FolderEntry (org.eclipse.che.api.project.server.FolderEntry)33 VirtualFileEntry (org.eclipse.che.api.project.server.VirtualFileEntry)11 Test (org.testng.annotations.Test)11 VirtualFileSystem (org.eclipse.che.api.vfs.VirtualFileSystem)9 MavenServerManagerTest (org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)8 IProject (org.eclipse.core.resources.IProject)7 Problem (org.eclipse.che.ide.ext.java.shared.dto.Problem)6 MavenServerService (org.eclipse.che.plugin.maven.server.rest.MavenServerService)6 ServerException (org.eclipse.che.api.core.ServerException)5 FileEntry (org.eclipse.che.api.project.server.FileEntry)4 VirtualFile (org.eclipse.che.api.vfs.VirtualFile)4 ConflictException (org.eclipse.che.api.core.ConflictException)3 ValueProvider (org.eclipse.che.api.project.server.type.ValueProvider)3 Model (org.eclipse.che.ide.maven.tools.Model)3 ArrayList (java.util.ArrayList)2 ForbiddenException (org.eclipse.che.api.core.ForbiddenException)2 ProjectCreatedEvent (org.eclipse.che.api.project.server.ProjectCreatedEvent)2 ResourceChangedEvent (org.eclipse.che.jdt.core.resources.ResourceChangedEvent)2 TestUtils (org.eclipse.che.plugin.svn.server.utils.TestUtils)2 IResourceStatus (org.eclipse.core.resources.IResourceStatus)2