Search in sources :

Example 26 with FolderEntry

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

the class CreateBaseProjectTypeHandler 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(README_FILE_NAME, getReadmeContent());
}
Also used : VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) FolderEntry(org.eclipse.che.api.project.server.FolderEntry)

Example 27 with FolderEntry

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

the class PythonProjectGenerator 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_python_content"));
}
Also used : VirtualFileSystem(org.eclipse.che.api.vfs.VirtualFileSystem) FolderEntry(org.eclipse.che.api.project.server.FolderEntry)

Example 28 with FolderEntry

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

the class SimpleGeneratorStrategy method generateProject.

@Override
public void generateProject(Path projectPath, Map<String, AttributeValue> attributes, Map<String, String> options) throws ForbiddenException, ConflictException, ServerException {
    AttributeValue artifactId = attributes.get(ARTIFACT_ID);
    AttributeValue groupId = attributes.get(GROUP_ID);
    AttributeValue version = attributes.get(VERSION);
    if (artifactId == null) {
        throw new ConflictException("Missed required attribute artifactId");
    }
    if (groupId == null) {
        throw new ConflictException("Missed required attribute groupId");
    }
    if (version == null) {
        throw new ConflictException("Missed required attribute version");
    }
    Model model = Model.createModel();
    model.setModelVersion("4.0.0");
    final FolderEntry baseFolder = new FolderEntry(vfs.getRoot().createFolder(projectPath.toString()));
    if (baseFolder.getChild("pom.xml") == null) {
        baseFolder.createFile("pom.xml", new byte[0]);
    }
    AttributeValue parentArtifactId = attributes.get(PARENT_ARTIFACT_ID);
    if (parentArtifactId != null) {
        model.setArtifactId(parentArtifactId.getString());
    }
    AttributeValue parentGroupId = attributes.get(PARENT_GROUP_ID);
    if (parentGroupId != null) {
        model.setGroupId(parentGroupId.getString());
    }
    AttributeValue parentVersion = attributes.get(PARENT_VERSION);
    if (parentVersion != null) {
        model.setVersion(parentVersion.getString());
    }
    model.setArtifactId(artifactId.getString());
    model.setGroupId(groupId.getString());
    model.setVersion(version.getString());
    AttributeValue packaging = attributes.get(PACKAGING);
    if (packaging != null) {
        model.setPackaging(packaging.getString());
    }
    AttributeValue sourceFolders = attributes.get(SOURCE_FOLDER);
    if (sourceFolders != null) {
        final String sourceFolder = sourceFolders.getString();
        baseFolder.createFolder(sourceFolder);
        if (!DEFAULT_SOURCE_FOLDER.equals(sourceFolder)) {
            model.setBuild(new Build().setSourceDirectory(sourceFolder));
        }
    }
    AttributeValue testSourceFolders = attributes.get(TEST_SOURCE_FOLDER);
    if (testSourceFolders != null) {
        final String testSourceFolder = testSourceFolders.getString();
        baseFolder.createFolder(testSourceFolder);
        if (!DEFAULT_TEST_SOURCE_FOLDER.equals(testSourceFolder)) {
            Build build = model.getBuild();
            if (build != null) {
                build.setTestSourceDirectory(testSourceFolder);
            } else {
                model.setBuild(new Build().setTestSourceDirectory(testSourceFolder));
            }
        }
    }
    model.writeTo(baseFolder.getChild("pom.xml").getVirtualFile());
}
Also used : AttributeValue(org.eclipse.che.api.project.server.type.AttributeValue) ConflictException(org.eclipse.che.api.core.ConflictException) Build(org.eclipse.che.ide.maven.tools.Build) FolderEntry(org.eclipse.che.api.project.server.FolderEntry) Model(org.eclipse.che.ide.maven.tools.Model)

Example 29 with FolderEntry

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

the class WorkspaceTest method testRemovingModule.

@Test
public void testRemovingModule() throws Exception {
    FolderEntry parentFolder = createMultimoduleProject();
    IProject parent = ResourcesPlugin.getWorkspace().getRoot().getProject("parent");
    mavenWorkspace.update(Collections.singletonList(parent));
    mavenWorkspace.waitForUpdate();
    assertThat(projectRegistry.getProjects()).hasSize(3).onProperty("path").containsOnly("/parent", "/parent/module1", "/parent/module2");
    VirtualFile parentPom = parentFolder.getChild("pom.xml").getVirtualFile();
    Model model = Model.readFrom(parentPom);
    List<String> modules = new ArrayList<>(model.getModules());
    ListIterator<String> listIterator = modules.listIterator();
    while (listIterator.hasNext()) {
        if ("module2".equals(listIterator.next())) {
            listIterator.remove();
            break;
        }
    }
    model.setModules(modules);
    model.writeTo(parentPom);
    mavenWorkspace.update(Collections.singletonList(parent));
    mavenWorkspace.waitForUpdate();
    assertThat(projectRegistry.getProjects()).hasSize(2).onProperty("path").containsOnly("/parent", "/parent/module1");
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) FolderEntry(org.eclipse.che.api.project.server.FolderEntry) Model(org.eclipse.che.ide.maven.tools.Model) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Example 30 with FolderEntry

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

the class BaseTest method createTestProjectWithPackages.

protected void createTestProjectWithPackages(String projectName, String pom, String... packages) throws ForbiddenException, ConflictException, NotFoundException, ServerException {
    FolderEntry testProject = createTestProject(projectName, pom);
    FolderEntry src = testProject.createFolder("src/main/java");
    for (String aPackage : packages) {
        src.createFolder(aPackage.replace(".", "/"));
    }
}
Also used : FolderEntry(org.eclipse.che.api.project.server.FolderEntry)

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