use of org.eclipse.che.api.core.model.project.NewProjectConfig in project che by eclipse.
the class ClasspathUpdaterService method updateProjectConfig.
private void updateProjectConfig(String projectPath) throws IOException, ForbiddenException, ConflictException, NotFoundException, ServerException {
RegisteredProject project = projectRegistry.getProject(projectPath);
NewProjectConfig projectConfig = new NewProjectConfigImpl(projectPath, project.getName(), project.getType(), project.getSource());
projectManager.updateProject(projectConfig);
}
use of org.eclipse.che.api.core.model.project.NewProjectConfig in project che by eclipse.
the class ProjectManager method validateProjectConfigurations.
private void validateProjectConfigurations(List<? extends NewProjectConfig> projectConfigList, boolean rewrite) throws NotFoundException, ServerException, ConflictException, ForbiddenException, BadRequestException {
for (NewProjectConfig projectConfig : projectConfigList) {
final String pathToProject = projectConfig.getPath();
if (isNullOrEmpty(pathToProject)) {
throw new BadRequestException("Path for new project should be defined");
}
final String path = ProjectRegistry.absolutizePath(pathToProject);
final RegisteredProject registeredProject = projectRegistry.getProject(path);
if (registeredProject != null && rewrite) {
delete(path);
} else if (registeredProject != null) {
throw new ConflictException(format("Project config already exists for %s", path));
}
final String projectTypeId = projectConfig.getType();
if (isNullOrEmpty(projectTypeId)) {
projectConfig.setType(BaseProjectType.ID);
}
}
}
use of org.eclipse.che.api.core.model.project.NewProjectConfig in project che by eclipse.
the class ProjectManager method moveTo.
/**
* Moves item to the new path
*
* @param itemPath path to the item
* @param newParentPath path of new parent
* @param newName new item's name
* @param overwrite whether existed (if any) item should be overwritten
*
* @return new item
* @throws ServerException
* @throws NotFoundException
* @throws ConflictException
* @throws ForbiddenException
*/
public VirtualFileEntry moveTo(String itemPath, String newParentPath, String newName, boolean overwrite) throws ServerException, NotFoundException, ConflictException, ForbiddenException {
final VirtualFile oldItem = vfs.getRoot().getChild(Path.of(itemPath));
if (oldItem == null) {
throw new NotFoundException("Item not found " + itemPath);
}
final VirtualFile newParent;
if (newParentPath == null) {
// rename only
newParent = oldItem.getParent();
} else {
newParent = vfs.getRoot().getChild(Path.of(newParentPath));
}
if (newParent == null) {
throw new NotFoundException("New parent not found " + newParentPath);
}
// TODO lock token ?
final VirtualFile newItem = oldItem.moveTo(newParent, newName, overwrite, null);
final RegisteredProject owner = projectRegistry.getParentProject(newItem.getPath().toString());
if (owner == null) {
throw new NotFoundException("Parent project not found " + newItem.getPath().toString());
}
final VirtualFileEntry move;
if (newItem.isFile()) {
move = new FileEntry(newItem, projectRegistry);
} else {
move = new FolderEntry(newItem, projectRegistry);
}
if (move.isProject()) {
final RegisteredProject project = projectRegistry.getProject(itemPath);
NewProjectConfig projectConfig = new NewProjectConfigImpl(newItem.getPath().toString(), project.getType(), project.getMixins(), newName, project.getDescription(), project.getAttributes(), null, project.getSource());
if (move instanceof FolderEntry) {
projectRegistry.removeProjects(project.getPath());
updateProject(projectConfig);
}
}
return move;
}
Aggregations