Search in sources :

Example 6 with VirtualFileEntry

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

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());
}
Also used : Path(java.nio.file.Path) AttributeValue(org.eclipse.che.api.project.server.type.AttributeValue) HashMap(java.util.HashMap) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) FileEntry(org.eclipse.che.api.project.server.FileEntry) Test(org.junit.Test)

Example 8 with VirtualFileEntry

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;
    }
}
Also used : FolderEntry(org.eclipse.che.api.project.server.FolderEntry) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry)

Example 9 with VirtualFileEntry

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));
    }
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IResourceStatus(org.eclipse.core.resources.IResourceStatus) ForbiddenException(org.eclipse.che.api.core.ForbiddenException) ServerException(org.eclipse.che.api.core.ServerException) IPath(org.eclipse.core.runtime.IPath) ConflictException(org.eclipse.che.api.core.ConflictException) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) NotFoundException(org.eclipse.che.api.core.NotFoundException) CoreException(org.eclipse.core.runtime.CoreException) FolderEntry(org.eclipse.che.api.project.server.FolderEntry) ProjectConfigImpl(org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl)

Example 10 with VirtualFileEntry

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));
    }
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IResourceStatus(org.eclipse.core.resources.IResourceStatus) ForbiddenException(org.eclipse.che.api.core.ForbiddenException) ServerException(org.eclipse.che.api.core.ServerException) CoreException(org.eclipse.core.runtime.CoreException) ConflictException(org.eclipse.che.api.core.ConflictException) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) NotFoundException(org.eclipse.che.api.core.NotFoundException)

Aggregations

VirtualFileEntry (org.eclipse.che.api.project.server.VirtualFileEntry)21 FolderEntry (org.eclipse.che.api.project.server.FolderEntry)11 ServerException (org.eclipse.che.api.core.ServerException)9 Problem (org.eclipse.che.ide.ext.java.shared.dto.Problem)7 ForbiddenException (org.eclipse.che.api.core.ForbiddenException)6 MavenServerService (org.eclipse.che.plugin.maven.server.rest.MavenServerService)6 MavenServerManagerTest (org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)6 Test (org.testng.annotations.Test)6 NotFoundException (org.eclipse.che.api.core.NotFoundException)5 IProject (org.eclipse.core.resources.IProject)5 ConflictException (org.eclipse.che.api.core.ConflictException)4 FileEntry (org.eclipse.che.api.project.server.FileEntry)3 RegisteredProject (org.eclipse.che.api.project.server.RegisteredProject)3 IResourceStatus (org.eclipse.core.resources.IResourceStatus)3 CoreException (org.eclipse.core.runtime.CoreException)3 IStatus (org.eclipse.core.runtime.IStatus)3 MultiStatus (org.eclipse.core.runtime.MultiStatus)3 Status (org.eclipse.core.runtime.Status)3 HashMap (java.util.HashMap)2 List (java.util.List)2