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