use of org.eclipse.che.api.core.ForbiddenException in project che by eclipse.
the class Workspace method standardMoveFolder.
public void standardMoveFolder(IFolder folder, IFolder destination, int updateFlags, IProgressMonitor monitor) throws CoreException {
VirtualFileEntry child = null;
try {
child = getProjectsRoot().getChild(folder.getFullPath().toOSString());
projectManager.get().moveTo(child.getPath().toString(), destination.getFullPath().removeLastSegments(1).toOSString(), destination.getName(), true);
} catch (ForbiddenException | NotFoundException | ServerException | ConflictException e) {
throw new CoreException(new Status(IStatus.ERROR, "", "Can't move folder: " + folder.getFullPath() + " to: " + destination.getFullPath(), e));
}
}
use of org.eclipse.che.api.core.ForbiddenException in project che by eclipse.
the class Workspace method standardMoveFile.
public void standardMoveFile(IFile file, IFile destination, int updateFlags, IProgressMonitor monitor) throws CoreException {
VirtualFileEntry child = null;
try {
child = getProjectsRoot().getChild(file.getFullPath().toOSString());
projectManager.get().moveTo(child.getPath().toString(), destination.getFullPath().removeLastSegments(1).toOSString(), destination.getName(), true);
} catch (ForbiddenException | ServerException | NotFoundException | ConflictException e) {
throw new CoreException(new Status(IStatus.ERROR, "", "Can't move file: " + file.getFullPath() + " to: " + destination.getFullPath(), e));
}
}
use of org.eclipse.che.api.core.ForbiddenException in project che by eclipse.
the class Workspace method setFileContent.
public void setFileContent(File file, InputStream content) {
try {
VirtualFileEntry child = getProjectsRoot().getChild(file.getFullPath().toOSString());
if (child.isFile()) {
FileEntry f = (FileEntry) child;
f.updateContent(content);
}
} catch (ForbiddenException | ServerException e) {
ResourcesPlugin.log(e);
}
}
use of org.eclipse.che.api.core.ForbiddenException in project che by eclipse.
the class Workspace method write.
void write(File file, InputStream content, int updateFlags, boolean append, IProgressMonitor monitor) throws CoreException {
try {
FolderEntry projectsRoot = getProjectsRoot();
VirtualFileEntry child = projectsRoot.getChild(file.getFullPath().toOSString());
if (child == null) {
projectsRoot.createFile(file.getFullPath().toOSString(), content);
} else {
FileEntry fileEntry = (FileEntry) child;
fileEntry.updateContent(content);
}
} catch (ForbiddenException | ConflictException | ServerException e) {
throw new CoreException(new Status(0, "", e.getMessage(), e));
}
}
use of org.eclipse.che.api.core.ForbiddenException 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());
}
Aggregations