use of org.eclipse.che.api.workspace.shared.dto.SourceStorageDto in project che by eclipse.
the class ResourceManager method asDto.
private NewProjectConfigDto asDto(MutableProjectConfig config) {
final SourceStorage source = config.getSource();
final SourceStorageDto sourceStorageDto = dtoFactory.createDto(SourceStorageDto.class).withType(source.getType()).withLocation(source.getLocation()).withParameters(source.getParameters());
return dtoFactory.createDto(NewProjectConfigDto.class).withName(config.getName()).withPath(config.getPath()).withDescription(config.getDescription()).withSource(sourceStorageDto).withType(config.getType()).withMixins(config.getMixins()).withAttributes(config.getAttributes()).withOptions(config.getOptions());
}
use of org.eclipse.che.api.workspace.shared.dto.SourceStorageDto in project che by eclipse.
the class ProjectServiceClientImpl method importProject.
/** {@inheritDoc} */
@Override
public Promise<Void> importProject(final Path path, final SourceStorageDto source) {
return createFromAsyncRequest(callback -> {
final String url = PROJECT + IMPORT + path(path.toString());
final Message message = new MessageBuilder(POST, url).data(dtoFactory.toJson(source)).header(CONTENTTYPE, APPLICATION_JSON).build();
wsAgentStateController.getMessageBus().then(messageBus -> {
try {
messageBus.send(message, new RequestCallback<Void>() {
@Override
protected void onSuccess(Void result) {
callback.onSuccess(result);
}
@Override
protected void onFailure(Throwable exception) {
callback.onFailure(exception);
}
});
} catch (WebSocketException e) {
callback.onFailure(e);
}
}).catchError(error -> {
callback.onFailure(error.getCause());
});
});
}
use of org.eclipse.che.api.workspace.shared.dto.SourceStorageDto in project che by eclipse.
the class ProjectManagerWriteTest method shouldThrowBadRequestExceptionAtCreatingBatchProjectsWhenConfigNotContainsPath.
@Test
public void shouldThrowBadRequestExceptionAtCreatingBatchProjectsWhenConfigNotContainsPath() throws Exception {
//Path is mandatory field for NewProjectConfig
final SourceStorageDto source = DtoFactory.newDto(SourceStorageDto.class).withLocation("someLocation").withType("importType");
final NewProjectConfig config = createProjectConfigObject("project", null, BaseProjectType.ID, source);
final List<NewProjectConfig> configs = new ArrayList<>(1);
configs.add(config);
try {
pm.createBatchProjects(configs, false, new ProjectOutputLineConsumerFactory("ws", 300));
fail("BadRequestException should be thrown : path field is mandatory");
} catch (BadRequestException e) {
assertEquals(0, projectRegistry.getProjects().size());
}
}
use of org.eclipse.che.api.workspace.shared.dto.SourceStorageDto in project che by eclipse.
the class ProjectManagerWriteTest method testCreateProjectWhenSourceCodeIsNotReachable.
@Test
public void testCreateProjectWhenSourceCodeIsNotReachable() throws Exception {
final String projectPath = "/testProject";
final SourceStorageDto source = DtoFactory.newDto(SourceStorageDto.class).withLocation("someLocation").withType("importType");
final NewProjectConfigDto config = createProjectConfigObject("testProject1", projectPath, BaseProjectType.ID, source);
final List<NewProjectConfig> configs = new ArrayList<>(1);
configs.add(config);
try {
pm.createBatchProjects(configs, false, new ProjectOutputLineConsumerFactory("ws", 300));
fail("Exception should be thrown when source code is not reachable");
} catch (Exception e) {
assertEquals(0, projectRegistry.getProjects().size());
assertNull(projectRegistry.getProject(projectPath));
assertNull(pm.getProjectsRoot().getChild(projectPath));
}
}
use of org.eclipse.che.api.workspace.shared.dto.SourceStorageDto in project che by eclipse.
the class ProjectManagerWriteTest method testCreateBatchProjectsWithInnerProject.
@Test
public void testCreateBatchProjectsWithInnerProject() throws Exception {
final String rootProjectPath = "/testProject1";
final String innerProjectPath = "/testProject1/innerProject";
final String importType = "importType1";
final String innerProjectType = "pt2";
Map<String, List<String>> attributes = new HashMap<>();
attributes.put("pt2-var2", new AttributeValue("test").getList());
final String[] paths1 = { "folder1/", "folder1/file1.txt" };
final String[] paths2 = { "innerProject/", "innerProject/folder2/", "innerProject/folder2/file2.txt" };
final List<String> children1 = Arrays.asList(paths1);
final List<String> children2 = Arrays.asList(paths2);
final List<String> children = new ArrayList<>(children1);
children.addAll(children2);
registerImporter(importType, prepareZipArchiveBasedOn(children));
SourceStorageDto source = DtoFactory.newDto(SourceStorageDto.class).withLocation("someLocation").withType(importType);
NewProjectConfigDto config1 = createProjectConfigObject("testProject1", rootProjectPath, BaseProjectType.ID, source);
NewProjectConfigDto config2 = createProjectConfigObject("innerProject", innerProjectPath, innerProjectType, null);
config2.setAttributes(attributes);
List<NewProjectConfig> configs = new ArrayList<>(2);
configs.add(config1);
configs.add(config2);
pm.createBatchProjects(configs, false, new ProjectOutputLineConsumerFactory("ws", 300));
RegisteredProject rootProject = projectRegistry.getProject(rootProjectPath);
FolderEntry rootProjectFolder = rootProject.getBaseFolder();
RegisteredProject innerProject = projectRegistry.getProject(innerProjectPath);
FolderEntry innerProjectFolder = innerProject.getBaseFolder();
assertNotNull(rootProject);
assertTrue(rootProjectFolder.getVirtualFile().exists());
assertEquals(rootProjectPath, rootProject.getPath());
checkChildrenFor(rootProjectFolder, children1);
assertNotNull(innerProject);
assertTrue(innerProjectFolder.getVirtualFile().exists());
assertEquals(innerProjectPath, innerProject.getPath());
assertEquals(innerProjectType, innerProject.getType());
checkChildrenFor(rootProjectFolder, children2);
}
Aggregations