use of org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl 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.server.model.impl.ProjectConfigImpl in project che by eclipse.
the class JpaWorkspaceDao method doCreate.
@Transactional
protected void doCreate(WorkspaceImpl workspace) {
if (workspace.getConfig() != null) {
workspace.getConfig().getProjects().forEach(ProjectConfigImpl::prePersistAttributes);
}
EntityManager manager = managerProvider.get();
manager.persist(workspace);
manager.flush();
}
use of org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl in project che by eclipse.
the class JpaWorkspaceDao method doUpdate.
@Transactional
protected WorkspaceImpl doUpdate(WorkspaceImpl update) throws NotFoundException {
EntityManager manager = managerProvider.get();
if (manager.find(WorkspaceImpl.class, update.getId()) == null) {
throw new NotFoundException(format("Workspace with id '%s' doesn't exist", update.getId()));
}
if (update.getConfig() != null) {
update.getConfig().getProjects().forEach(ProjectConfigImpl::prePersistAttributes);
}
WorkspaceImpl merged = manager.merge(update);
manager.flush();
return merged;
}
use of org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl in project che by eclipse.
the class TestObjectsFactory method createProjectConfig.
public static ProjectConfigImpl createProjectConfig(String name) {
final ProjectConfigImpl project = new ProjectConfigImpl();
project.setDescription(name + "-description");
project.setName(name);
project.setPath("/" + name);
project.setType(name + "type");
project.setSource(new SourceStorageImpl("source-type", "source-location", ImmutableMap.of("param1", "value", "param2", "value")));
project.setMixins(asList("mixin1", "mixin2"));
project.getAttributes().put("attribute1", singletonList("value1"));
project.getAttributes().put("attribute2", singletonList("value2"));
project.getAttributes().put("attribute3", singletonList("value3"));
return project;
}
use of org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl in project che by eclipse.
the class WorkspaceDaoTest method createsWorkspaceWithAProjectConfigContainingLongAttributeValues.
@Test(dependsOnMethods = "shouldGetWorkspaceById")
public void createsWorkspaceWithAProjectConfigContainingLongAttributeValues() throws Exception {
WorkspaceImpl workspace = createWorkspace("new-workspace", accounts[0], "new-name");
ProjectConfigImpl project = workspace.getConfig().getProjects().get(0);
// long string
char[] chars = new char[100_000];
Arrays.fill(chars, 0, chars.length / 2, 'x');
Arrays.fill(chars, chars.length / 2, chars.length, 'y');
String value = new String(chars);
project.getAttributes().put("long_value1", singletonList(value));
project.getAttributes().put("long_value2", singletonList(value));
workspaceDao.create(workspace);
assertEquals(workspaceDao.get(workspace.getId()), new WorkspaceImpl(workspace));
}
Aggregations