Search in sources :

Example 21 with NewProjectConfig

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);
}
Also used : NewProjectConfigImpl(org.eclipse.che.api.project.server.NewProjectConfigImpl) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) NewProjectConfig(org.eclipse.che.api.core.model.project.NewProjectConfig)

Example 22 with NewProjectConfig

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);
        }
    }
}
Also used : ConflictException(org.eclipse.che.api.core.ConflictException) BadRequestException(org.eclipse.che.api.core.BadRequestException) NewProjectConfig(org.eclipse.che.api.core.model.project.NewProjectConfig)

Example 23 with NewProjectConfig

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;
}
Also used : VirtualFile(org.eclipse.che.api.vfs.VirtualFile) NotFoundException(org.eclipse.che.api.core.NotFoundException) NewProjectConfig(org.eclipse.che.api.core.model.project.NewProjectConfig)

Aggregations

NewProjectConfig (org.eclipse.che.api.core.model.project.NewProjectConfig)23 ArrayList (java.util.ArrayList)17 Test (org.junit.Test)14 NewProjectConfigDto (org.eclipse.che.api.workspace.shared.dto.NewProjectConfigDto)8 SourceStorageDto (org.eclipse.che.api.workspace.shared.dto.SourceStorageDto)8 ConflictException (org.eclipse.che.api.core.ConflictException)6 BadRequestException (org.eclipse.che.api.core.BadRequestException)5 NotFoundException (org.eclipse.che.api.core.NotFoundException)4 Problem (org.eclipse.che.api.project.server.RegisteredProject.Problem)4 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 List (java.util.List)3 ForbiddenException (org.eclipse.che.api.core.ForbiddenException)3 ServerException (org.eclipse.che.api.core.ServerException)3 AttributeValue (org.eclipse.che.api.project.server.type.AttributeValue)3 SourceStorage (org.eclipse.che.api.core.model.project.SourceStorage)2 Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)1 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 String.format (java.lang.String.format)1 PathMatcher (java.nio.file.PathMatcher)1