use of org.eclipse.che.api.project.server.VirtualFileEntry in project che by eclipse.
the class PomReconcilerTest method testReconcilePomWhenPomContainsDependecyWithIncorrectGroupId.
@Test
public void testReconcilePomWhenPomContainsDependecyWithIncorrectGroupId() throws Exception {
String brokenDependency = " <dependency>\n" + " <groupId>junittttt</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(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.VirtualFileEntry in project che by eclipse.
the class SimpleGeneratorStrategyTest method testGeneratingProject.
@Test
public void testGeneratingProject() throws Exception {
prepareProject();
final Path pomXml = Paths.get(Thread.currentThread().getContextClassLoader().getResource("test-pom.xml").toURI());
Map<String, AttributeValue> attributeValues = new HashMap<>();
attributeValues.put(MavenAttributes.ARTIFACT_ID, new AttributeValue("my_artifact"));
attributeValues.put(MavenAttributes.GROUP_ID, new AttributeValue("my_group"));
attributeValues.put(MavenAttributes.PACKAGING, new AttributeValue("jar"));
attributeValues.put(MavenAttributes.VERSION, new AttributeValue("1.0-SNAPSHOT"));
attributeValues.put(SOURCE_FOLDER, new AttributeValue("src/main/java"));
attributeValues.put(MavenAttributes.TEST_SOURCE_FOLDER, new AttributeValue("src/test/java"));
pm.getProject("my_project").getBaseFolder();
simple.generateProject(org.eclipse.che.api.vfs.Path.of("my_project"), attributeValues, null);
VirtualFileEntry pomFile = pm.getProject("my_project").getBaseFolder().getChild("pom.xml");
Assert.assertTrue(pomFile.isFile());
Assert.assertEquals(new String(((FileEntry) pomFile).contentAsBytes()), new String(Files.readAllBytes(pomXml)));
VirtualFileEntry srcFolder = pm.getProject("my_project").getBaseFolder().getChild("src/main/java");
Assert.assertTrue(srcFolder.isFolder());
VirtualFileEntry testFolder = pm.getProject("my_project").getBaseFolder().getChild("src/test/java");
Assert.assertTrue(testFolder.isFolder());
}
use of org.eclipse.che.api.project.server.VirtualFileEntry in project che by eclipse.
the class SubversionValueProviderFactory method isSvn.
private boolean isSvn(final FolderEntry project) throws ForbiddenException, ServerException {
LOG.debug("Searching for '.svn' in {}.", project.getPath());
final VirtualFileEntry svn = project.getChild(".svn");
if (svn != null && svn instanceof FolderEntry) {
LOG.debug("Found it.");
return true;
} else {
LOG.debug("Didn't find it.");
return false;
}
}
use of org.eclipse.che.api.project.server.VirtualFileEntry in project che by eclipse.
the class Workspace method createResource.
public void createResource(IResource resource, int updateFlags) throws CoreException {
try {
IPath path = resource.getFullPath();
switch(resource.getType()) {
case IResource.FILE:
String newName = path.lastSegment();
VirtualFileEntry child = getProjectsRoot().getChild(path.removeLastSegments(1).toOSString());
if (child == null) {
throw new NotFoundException("Can't find parent folder: " + path.removeLastSegments(1).toOSString());
}
FolderEntry entry = (FolderEntry) child;
entry.createFile(newName, new byte[0]);
break;
case IResource.FOLDER:
getProjectsRoot().createFolder(path.toOSString());
break;
case IResource.PROJECT:
ProjectConfigImpl projectConfig = new ProjectConfigImpl();
projectConfig.setPath(resource.getName());
projectConfig.setName(resource.getName());
projectConfig.setType(BaseProjectType.ID);
projectManager.get().createProject(projectConfig, new HashMap<>());
break;
default:
throw new UnsupportedOperationException();
}
} catch (ForbiddenException | ConflictException | ServerException | NotFoundException e) {
throw new CoreException(new Status(0, ResourcesPlugin.getPluginId(), e.getMessage(), e));
}
}
use of org.eclipse.che.api.project.server.VirtualFileEntry in project che by eclipse.
the class Workspace method standardMoveFolder.
public void standardMoveFolder(IFolder folder, IFolder destination, int updateFlags, IProgressMonitor monitor) throws CoreException {
VirtualFileEntry child = null;
try {
child = getProjectsRoot().getChild(folder.getFullPath().toOSString());
projectManager.get().moveTo(child.getPath().toString(), destination.getFullPath().removeLastSegments(1).toOSString(), destination.getName(), true);
} catch (ForbiddenException | NotFoundException | ServerException | ConflictException e) {
throw new CoreException(new Status(IStatus.ERROR, "", "Can't move folder: " + folder.getFullPath() + " to: " + destination.getFullPath(), e));
}
}
Aggregations