use of org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto in project che by eclipse.
the class ProjectService method createBatchProjects.
@POST
@Path("/batch")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Creates batch of projects according to their configurations", notes = "A project will be created by importing when project configuration contains source object. " + "For creating a project by generator options should be specified.", response = ProjectConfigDto.class)
@ApiResponses({ @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 400, message = "Path for new project should be defined"), @ApiResponse(code = 403, message = "Operation is forbidden"), @ApiResponse(code = 409, message = "Project with specified name already exist in workspace"), @ApiResponse(code = 500, message = "Server error") })
@GenerateLink(rel = LINK_REL_CREATE_BATCH_PROJECTS)
public List<ProjectConfigDto> createBatchProjects(@Description("list of descriptors for projects") List<NewProjectConfigDto> projectConfigList, @ApiParam(value = "Force rewrite existing project", allowableValues = "true,false") @QueryParam("force") boolean rewrite) throws ConflictException, ForbiddenException, ServerException, NotFoundException, IOException, UnauthorizedException, BadRequestException {
List<ProjectConfigDto> result = new ArrayList<>(projectConfigList.size());
final ProjectOutputLineConsumerFactory outputOutputConsumerFactory = new ProjectOutputLineConsumerFactory(workspace, 300);
for (RegisteredProject registeredProject : projectManager.createBatchProjects(projectConfigList, rewrite, outputOutputConsumerFactory)) {
ProjectConfigDto projectConfig = injectProjectLinks(asDto(registeredProject));
result.add(projectConfig);
eventService.publish(new ProjectCreatedEvent(workspace, registeredProject.getPath()));
}
return result;
}
use of org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto in project che by eclipse.
the class ProjectService method createProject.
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Creates new project", response = ProjectConfigDto.class)
@ApiResponses({ @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 403, message = "Operation is forbidden"), @ApiResponse(code = 409, message = "Project with specified name already exist in workspace"), @ApiResponse(code = 500, message = "Server error") })
@GenerateLink(rel = LINK_REL_CREATE_PROJECT)
public /**
* NOTE: parentPath is added to make a module
*/
ProjectConfigDto createProject(@ApiParam(value = "Add to this project as module", required = false) @Context UriInfo uriInfo, @Description("descriptor of project") ProjectConfigDto projectConfig) throws ConflictException, ForbiddenException, ServerException, NotFoundException {
Map<String, String> options = new HashMap<>();
MultivaluedMap<String, String> map = uriInfo.getQueryParameters();
for (String key : map.keySet()) {
options.put(key, map.get(key).get(0));
}
String pathToProject = projectConfig.getPath();
String pathToParent = pathToProject.substring(0, pathToProject.lastIndexOf("/"));
if (!pathToParent.equals("/")) {
VirtualFileEntry parentFileEntry = projectManager.getProjectsRoot().getChild(pathToParent);
if (parentFileEntry == null) {
throw new NotFoundException("The parent folder with path " + pathToParent + " does not exist.");
}
}
final RegisteredProject project = projectManager.createProject(projectConfig, options);
final ProjectConfigDto configDto = asDto(project);
eventService.publish(new ProjectCreatedEvent(workspace, project.getPath()));
return injectProjectLinks(configDto);
}
use of org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto in project che by eclipse.
the class FactoryBuilderTest method prepareFactory.
private static FactoryDto prepareFactory() {
ProjectConfigDto project = dto.createDto(ProjectConfigDto.class).withSource(dto.createDto(SourceStorageDto.class).withType("git").withLocation("location")).withType("type").withAttributes(singletonMap("key", singletonList("value"))).withDescription("description").withName("name").withPath("/path");
EnvironmentDto environment = dto.createDto(EnvironmentDto.class).withRecipe(newDto(EnvironmentRecipeDto.class).withType("compose").withContentType("application/x-yaml").withContent("some content")).withMachines(singletonMap("devmachine", newDto(ExtendedMachineDto.class).withAgents(singletonList("org.eclipse.che.ws-agent")).withAttributes(singletonMap("memoryLimitBytes", "" + 512L * 1024L * 1024L))));
WorkspaceConfigDto workspaceConfig = dto.createDto(WorkspaceConfigDto.class).withProjects(singletonList(project)).withCommands(singletonList(dto.createDto(CommandDto.class).withName("command1").withType("maven").withCommandLine("mvn test"))).withDefaultEnv("env1").withEnvironments(singletonMap("test", environment));
IdeDto ide = dto.createDto(IdeDto.class).withOnAppClosed(dto.createDto(OnAppClosedDto.class).withActions(singletonList(dto.createDto(IdeActionDto.class).withId("warnOnClose")))).withOnAppLoaded(dto.createDto(OnAppLoadedDto.class).withActions(asList(dto.createDto(IdeActionDto.class).withId("newProject"), dto.createDto(IdeActionDto.class).withId("openWelcomePage").withProperties(ImmutableMap.of("authenticatedTitle", "Greeting title for authenticated users", "authenticatedContentUrl", "http://example.com/content.url"))))).withOnProjectsLoaded(dto.createDto(OnProjectsLoadedDto.class).withActions(asList(dto.createDto(IdeActionDto.class).withId("openFile").withProperties(singletonMap("file", "pom.xml")), dto.createDto(IdeActionDto.class).withId("run"), dto.createDto(IdeActionDto.class).withId("findReplace").withProperties(ImmutableMap.of("in", "src/main/resources/consts2.properties", "find", "OLD_VALUE_2", "replace", "NEW_VALUE_2", "replaceMode", "mode")))));
return dto.createDto(FactoryDto.class).withV("4.0").withWorkspace(workspaceConfig).withCreator(dto.createDto(AuthorDto.class).withEmail("email").withName("name")).withPolicies(dto.createDto(PoliciesDto.class).withReferer("referrer").withSince(123L).withUntil(123L)).withButton(dto.createDto(ButtonDto.class).withType(Button.Type.LOGO).withAttributes(dto.createDto(ButtonAttributesDto.class).withColor("color").withCounter(true).withLogo("logo").withStyle("style"))).withIde(ide);
}
use of org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto in project che by eclipse.
the class WorkspaceServiceTest method shouldUpdateProject.
@Test
public void shouldUpdateProject() throws Exception {
final WorkspaceImpl workspace = createWorkspace(createConfigDto());
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
when(wsManager.updateWorkspace(any(), any())).thenReturn(workspace);
final ProjectConfigDto projectDto = createProjectDto();
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(projectDto).when().put(SECURE_PATH + "/workspace/" + workspace.getId() + "/project" + projectDto.getPath());
assertEquals(response.getStatusCode(), 200);
verify(validator).validateConfig(workspace.getConfig());
verify(wsManager).updateWorkspace(any(), any());
}
use of org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto in project che by eclipse.
the class StackLoaderTest method dtoShouldBeSerialized.
@Test
public void dtoShouldBeSerialized() {
StackDto stackDtoDescriptor = newDto(StackDto.class).withName("nameWorkspaceConfig");
StackComponentDto stackComponentDto = newDto(StackComponentDto.class).withName("java").withVersion("1.8");
stackDtoDescriptor.setComponents(Collections.singletonList(stackComponentDto));
stackDtoDescriptor.setTags(Arrays.asList("some teg1", "some teg2"));
stackDtoDescriptor.setDescription("description");
stackDtoDescriptor.setId("someId");
stackDtoDescriptor.setScope("scope");
stackDtoDescriptor.setCreator("Created in Codenvy");
Map<String, String> attributes = new HashMap<>();
attributes.put("attribute1", "valute attribute1");
Link link = newDto(Link.class).withHref("some url").withMethod("get").withRel("someRel").withConsumes("consumes").withProduces("produces");
HashMap<String, List<String>> projectMap = new HashMap<>();
projectMap.put("test", Arrays.asList("test", "test2"));
ProjectProblemDto projectProblem = newDto(ProjectProblemDto.class).withCode(100).withMessage("message");
SourceStorageDto sourceStorageDto = newDto(SourceStorageDto.class).withType("some type").withParameters(attributes).withLocation("location");
ProjectConfigDto projectConfigDto = newDto(ProjectConfigDto.class).withName("project").withPath("somePath").withAttributes(projectMap).withType("maven type").withDescription("some project description").withLinks(Collections.singletonList(link)).withMixins(Collections.singletonList("mixin time")).withProblems(Collections.singletonList(projectProblem)).withSource(sourceStorageDto);
EnvironmentRecipeDto environmentRecipe = newDto(EnvironmentRecipeDto.class).withContent("some content").withContentType("some content type").withType("someType");
Map<String, ServerConf2Dto> servers = new HashMap<>();
servers.put("server1Ref", newDto(ServerConf2Dto.class).withPort("8080/tcp").withProtocol("http").withProperties(singletonMap("key", "value")));
Map<String, ExtendedMachineDto> machines = new HashMap<>();
machines.put("someMachineName", newDto(ExtendedMachineDto.class).withAgents(Arrays.asList("agent1", "agent2")).withServers(servers).withAttributes(singletonMap("memoryLimitBytes", "" + 512L * 1024L * 1024L)));
EnvironmentDto environmentDto = newDto(EnvironmentDto.class).withRecipe(environmentRecipe).withMachines(machines);
CommandDto commandDto = newDto(CommandDto.class).withType("command type").withName("command name").withCommandLine("command line");
WorkspaceConfigDto workspaceConfigDto = newDto(WorkspaceConfigDto.class).withName("SomeWorkspaceConfig").withDescription("some workspace").withLinks(Collections.singletonList(link)).withDefaultEnv("some Default Env name").withProjects(Collections.singletonList(projectConfigDto)).withEnvironments(singletonMap("name", environmentDto)).withCommands(Collections.singletonList(commandDto));
stackDtoDescriptor.setWorkspaceConfig(workspaceConfigDto);
Gson GSON = new GsonBuilder().create();
GSON.fromJson(stackDtoDescriptor.toString(), StackImpl.class);
}
Aggregations