Search in sources :

Example 1 with CreateProjectHandler

use of org.eclipse.che.api.project.server.handlers.CreateProjectHandler in project che by eclipse.

the class ProjectManager method doCreateProject.

/** Note: Use {@link FileWatcherManager#suspend()} and {@link FileWatcherManager#resume()} while creating a project */
private RegisteredProject doCreateProject(ProjectConfig projectConfig, Map<String, String> options) throws ConflictException, ForbiddenException, ServerException, NotFoundException {
    final String path = ProjectRegistry.absolutizePath(projectConfig.getPath());
    final CreateProjectHandler generator = handlers.getCreateProjectHandler(projectConfig.getType());
    FolderEntry projectFolder;
    if (generator != null) {
        Map<String, AttributeValue> valueMap = new HashMap<>();
        Map<String, List<String>> attributes = projectConfig.getAttributes();
        if (attributes != null) {
            for (Map.Entry<String, List<String>> entry : attributes.entrySet()) {
                valueMap.put(entry.getKey(), new AttributeValue(entry.getValue()));
            }
        }
        if (options == null) {
            options = new HashMap<>();
        }
        Path projectPath = Path.of(path);
        generator.onCreateProject(projectPath, valueMap, options);
        projectFolder = new FolderEntry(vfs.getRoot().getChild(projectPath), projectRegistry);
    } else {
        projectFolder = new FolderEntry(vfs.getRoot().createFolder(path), projectRegistry);
    }
    final RegisteredProject project = projectRegistry.putProject(projectConfig, projectFolder, true, false);
    workspaceProjectsHolder.sync(projectRegistry);
    projectRegistry.fireInitHandlers(project);
    return project;
}
Also used : Path(org.eclipse.che.api.vfs.Path) CreateProjectHandler(org.eclipse.che.api.project.server.handlers.CreateProjectHandler) AttributeValue(org.eclipse.che.api.project.server.type.AttributeValue) HashMap(java.util.HashMap) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 CreateProjectHandler (org.eclipse.che.api.project.server.handlers.CreateProjectHandler)1 AttributeValue (org.eclipse.che.api.project.server.type.AttributeValue)1 Path (org.eclipse.che.api.vfs.Path)1