Search in sources :

Example 1 with ProjectInitHandler

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

the class ExtensionCasesTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    new File(root, "/project1").mkdir();
    List<ProjectConfig> projects = new ArrayList<>();
    projects.add(DtoFactory.newDto(ProjectConfigDto.class).withPath("/project1").withName("project1Name").withType("primary1"));
    workspaceHolder = new TestWorkspaceHolder(projects);
    ProjectTypeRegistry projectTypeRegistry = new ProjectTypeRegistry(new HashSet<>());
    projectTypeRegistry.registerProjectType(new PT1());
    //projectTypeRegistry.registerProjectType(new PT3());
    //ProjectHandlerRegistry projectHandlerRegistry = new ProjectHandlerRegistry(new HashSet<>());
    projectRegistry = new ProjectRegistry(workspaceHolder, vfsProvider, projectTypeRegistry, projectHandlerRegistry, eventService);
    projectRegistry.initProjects();
    pm = new ProjectManager(vfsProvider, projectTypeRegistry, projectRegistry, projectHandlerRegistry, null, fileWatcherNotificationHandler, fileTreeWatcher, workspaceHolder, fileWatcherManager);
    pm.initWatcher();
    projectHandlerRegistry.register(new ProjectInitHandler() {

        @Override
        public void onProjectInitialized(ProjectRegistry registry, FolderEntry projectFolder) throws ServerException, NotFoundException, ConflictException, ForbiddenException {
            projectFolder.createFile("generated", "test".getBytes());
            projectFolder.createFolder("project2");
            projectRegistry.setProjectType("/project1/project2", BaseProjectType.ID, false);
        //System.out.println(">>S>>> "+projectRegistry);
        }

        @Override
        public String getProjectType() {
            return "primary1";
        }
    });
}
Also used : ProjectTypeRegistry(org.eclipse.che.api.project.server.type.ProjectTypeRegistry) ProjectInitHandler(org.eclipse.che.api.project.server.handlers.ProjectInitHandler) ForbiddenException(org.eclipse.che.api.core.ForbiddenException) ServerException(org.eclipse.che.api.core.ServerException) ConflictException(org.eclipse.che.api.core.ConflictException) ArrayList(java.util.ArrayList) NotFoundException(org.eclipse.che.api.core.NotFoundException) ProjectConfig(org.eclipse.che.api.core.model.project.ProjectConfig) File(java.io.File) Before(org.junit.Before)

Aggregations

File (java.io.File)1 ArrayList (java.util.ArrayList)1 ConflictException (org.eclipse.che.api.core.ConflictException)1 ForbiddenException (org.eclipse.che.api.core.ForbiddenException)1 NotFoundException (org.eclipse.che.api.core.NotFoundException)1 ServerException (org.eclipse.che.api.core.ServerException)1 ProjectConfig (org.eclipse.che.api.core.model.project.ProjectConfig)1 ProjectInitHandler (org.eclipse.che.api.project.server.handlers.ProjectInitHandler)1 ProjectTypeRegistry (org.eclipse.che.api.project.server.type.ProjectTypeRegistry)1 Before (org.junit.Before)1