use of org.eclipse.che.api.workspace.shared.dto.WorkspaceDto in project che by eclipse.
the class StartWorkspacePresenter method show.
/**
* Shows special dialog which contains workspaces which can be started at this time.
*
* @param callback
* callback which is necessary to notify that workspace component started or failed
* @param workspaces
* available workspaces which will be displayed
*/
public void show(List<WorkspaceDto> workspaces, Callback<Component, Exception> callback) {
this.callback = callback;
this.workspaces = workspaces;
view.clearWorkspacesPanel();
String workspaceName = browserAddress.getWorkspaceName();
createWsWidgets(workspaces);
for (WorkspaceDto workspace : workspaces) {
if (workspaceName.equals(workspace.getConfig().getName())) {
selectedWorkspace = workspace;
break;
}
}
view.setWsName(workspaceName);
view.show();
}
use of org.eclipse.che.api.workspace.shared.dto.WorkspaceDto in project che by eclipse.
the class BootstrapController method startWsAgentComponents.
@Inject
private void startWsAgentComponents(EventBus eventBus, final Map<String, Provider<WsAgentComponent>> components) {
eventBus.addHandler(WorkspaceStartedEvent.TYPE, new WorkspaceStartedEvent.Handler() {
@Override
public void onWorkspaceStarted(WorkspaceStartedEvent event) {
workspaceService.getWorkspace(event.getWorkspace().getId()).then(new Operation<WorkspaceDto>() {
@Override
public void apply(WorkspaceDto ws) throws OperationException {
MachineDto devMachineDto = ws.getRuntime().getDevMachine();
DevMachine devMachine = new DevMachine(devMachineDto);
if (appContext instanceof AppContextImpl) {
((AppContextImpl) appContext).setProjectsRoot(Path.valueOf(devMachineDto.getRuntime().projectsRoot()));
}
wsAgentStateControllerProvider.get().initialize(devMachine);
wsAgentURLModifier.initialize(devMachine);
SortedMap<String, Provider<WsAgentComponent>> sortedComponents = new TreeMap<>();
sortedComponents.putAll(components);
startWsAgentComponents(sortedComponents.values().iterator());
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError err) throws OperationException {
Log.error(getClass(), err.getCause());
initializationFailed(err.getMessage());
}
});
}
});
}
use of org.eclipse.che.api.workspace.shared.dto.WorkspaceDto in project che by eclipse.
the class WorkspaceService method updateProject.
@PUT
@Path("/{id}/project/{path:.*}")
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Update the workspace project by replacing it with a new one", notes = "This operation can be performed only by the workspace owner")
@ApiResponses({ @ApiResponse(code = 200, message = "The project successfully updated"), @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"), @ApiResponse(code = 403, message = "The user does not have access to update the project"), @ApiResponse(code = 404, message = "The workspace or the project not found"), @ApiResponse(code = 500, message = "Internal server error occurred") })
public WorkspaceDto updateProject(@ApiParam("The workspace id") @PathParam("id") String id, @ApiParam("The path to the project") @PathParam("path") String path, @ApiParam(value = "The project update", required = true) ProjectConfigDto update) throws ServerException, BadRequestException, NotFoundException, ConflictException, ForbiddenException {
requiredNotNull(update, "Project config");
final WorkspaceImpl workspace = workspaceManager.getWorkspace(id);
final List<ProjectConfigImpl> projects = workspace.getConfig().getProjects();
final String normalizedPath = path.startsWith("/") ? path : '/' + path;
if (!projects.removeIf(project -> project.getPath().equals(normalizedPath))) {
throw new NotFoundException(format("Workspace '%s' doesn't contain project with path '%s'", id, normalizedPath));
}
projects.add(new ProjectConfigImpl(update));
validator.validateConfig(workspace.getConfig());
return linksInjector.injectLinks(asDto(workspaceManager.updateWorkspace(id, workspace)), getServiceContext());
}
use of org.eclipse.che.api.workspace.shared.dto.WorkspaceDto in project che by eclipse.
the class MavenProjectTypeTest method testMavenProject.
@Test
public void testMavenProject() throws Exception {
WorkspaceDto usersWorkspaceMock = mock(WorkspaceDto.class);
WorkspaceConfigDto workspaceConfigMock = mock(WorkspaceConfigDto.class);
when(httpJsonRequestFactory.fromLink(eq(DtoFactory.newDto(Link.class).withMethod("GET").withHref("/workspace/")))).thenReturn(httpJsonRequest);
when(httpJsonRequestFactory.fromLink(eq(DtoFactory.newDto(Link.class).withMethod("PUT").withHref("/workspace/" + "/project")))).thenReturn(httpJsonRequest);
when(httpJsonRequest.request()).thenReturn(httpJsonResponse);
when(httpJsonResponse.asDto(WorkspaceDto.class)).thenReturn(usersWorkspaceMock);
final ProjectConfigDto projectConfig = DtoFactory.getInstance().createDto(ProjectConfigDto.class).withName("project").withPath("/myProject").withType(MavenAttributes.MAVEN_ID);
when(usersWorkspaceMock.getConfig()).thenReturn(workspaceConfigMock);
when(workspaceConfigMock.getProjects()).thenReturn(Collections.singletonList(projectConfig));
Map<String, List<String>> attributes = new HashMap<>();
attributes.put(MavenAttributes.ARTIFACT_ID, Collections.singletonList("myartifact"));
attributes.put(MavenAttributes.GROUP_ID, Collections.singletonList("mygroup"));
attributes.put(MavenAttributes.VERSION, Collections.singletonList("1.0"));
attributes.put(MavenAttributes.PACKAGING, Collections.singletonList("jar"));
RegisteredProject project = pm.createProject(DtoFactory.getInstance().createDto(ProjectConfigDto.class).withType("maven").withAttributes(attributes).withPath("/myProject").withName("myProject"), new HashMap<>(0));
for (VirtualFileEntry file : project.getBaseFolder().getChildren()) {
if (file.getName().equals("pom.xml")) {
Model pom = Model.readFrom(file.getVirtualFile().getContent());
Assert.assertEquals(pom.getVersion(), "1.0");
}
}
}
use of org.eclipse.che.api.workspace.shared.dto.WorkspaceDto in project che by eclipse.
the class SimpleGeneratorStrategyTest method prepareProject.
private void prepareProject() throws Exception {
final String vfsUser = "dev";
Set<ProjectTypeDef> pts = new HashSet<>();
final ProjectTypeDef pt = new ProjectTypeDef("mytype", "mytype type", true, false) {
};
pts.add(pt);
final ProjectTypeRegistry projectTypeRegistry = new ProjectTypeRegistry(pts);
final EventService eventService = new EventService();
// final VirtualFileSystemRegistry vfsRegistry = new VirtualFileSystemRegistry();
// final MemoryFileSystemProvider memoryFileSystemProvider =
// new MemoryFileSystemProvider(workspace,
// eventService,
// new VirtualFileSystemUserContext() {
// @Override
// public VirtualFileSystemUser getVirtualFileSystemUser() {
// return new VirtualFileSystemUser(vfsUser, vfsUserGroups);
// }
// },
// vfsRegistry,
// SystemPathsFilter.ANY);
// vfsRegistry.registerProvider(workspace, memoryFileSystemProvider);
WorkspaceDto usersWorkspaceMock = mock(WorkspaceDto.class);
final ProjectConfigDto projectConfigDto = DtoFactory.getInstance().createDto(ProjectConfigDto.class).withPath("/my_project");
WorkspaceConfigDto workspaceConfigMock = mock(WorkspaceConfigDto.class);
when(usersWorkspaceMock.getConfig()).thenReturn(workspaceConfigMock);
when(workspaceConfigMock.getProjects()).thenReturn(Collections.singletonList(projectConfigDto));
ProjectHandlerRegistry handlerRegistry = new ProjectHandlerRegistry(new HashSet<>());
// pm = new ProjectManager(vfsRegistry,
// eventService,
// projectTypeRegistry,
// handlerRegistry,
// filterProvider,
// API_ENDPOINT,
// httpJsonRequestFactory);
// HttpJsonRequest httpJsonRequest = mock(HttpJsonRequest.class, new SelfReturningAnswer());
// when(httpJsonRequestFactory.fromLink(eq(DtoFactory.newDto(Link.class)
// .withMethod("PUT")
// .withHref(API_ENDPOINT + "/workspace/" + workspace + "/project"))))
// .thenReturn(httpJsonRequest);
// when(httpJsonRequestFactory.fromLink(eq(DtoFactory.newDto(Link.class)
// .withMethod("GET")
// .withHref(API_ENDPOINT + "/workspace/" + workspace))))
// .thenReturn(httpJsonRequest);
// when(httpJsonRequest.request()).thenReturn(httpJsonResponse);
when(httpJsonResponse.asDto(WorkspaceDto.class)).thenReturn(usersWorkspaceMock);
pm.createProject(DtoFactory.getInstance().createDto(ProjectConfigDto.class).withType(pt.getId()).withName("my_project").withPath("/my_project"), null);
}
Aggregations