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);
}
}
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);
}
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();
}
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();
}
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();
}
Aggregations