use of org.eclipse.che.api.project.server.VirtualFileEntry 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.project.server.VirtualFileEntry 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.project.server.VirtualFileEntry 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.project.server.VirtualFileEntry in project che by eclipse.
the class Workspace method getChildren.
public IResource[] getChildren(IPath path) {
try {
VirtualFileEntry parent = getProjectsRoot().getChild(path.toOSString());
if (parent != null && parent.isFolder()) {
FolderEntry folder = (FolderEntry) parent;
List<VirtualFileEntry> children = folder.getChildren();
if (!children.isEmpty()) {
IResource[] resources = new IResource[children.size()];
for (int i = 0; i < children.size(); i++) {
VirtualFileEntry child = children.get(i);
IPath iPath = new Path(child.getPath().toString());
resources[i] = newResource(iPath, getType(child));
}
resources = Arrays.stream(resources).sorted((o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName())).toArray(IResource[]::new);
return resources;
}
}
} catch (ServerException e) {
LOG.error(e.getMessage(), e);
}
return ICoreConstants.EMPTY_RESOURCE_ARRAY;
}
use of org.eclipse.che.api.project.server.VirtualFileEntry in project che by eclipse.
the class LanguageServerRegistryImpl method extractProjectPath.
protected String extractProjectPath(String filePath) throws LanguageServerException {
FolderEntry root;
try {
root = projectManagerProvider.get().getProjectsRoot();
} catch (ServerException e) {
throw new LanguageServerException("Project not found for " + filePath, e);
}
if (!filePath.startsWith(PROJECT_FOLDER_PATH)) {
throw new LanguageServerException("Project not found for " + filePath);
}
VirtualFileEntry fileEntry;
try {
fileEntry = root.getChild(filePath.substring(PROJECT_FOLDER_PATH.length() + 1));
} catch (ServerException e) {
throw new LanguageServerException("Project not found for " + filePath, e);
}
if (fileEntry == null) {
throw new LanguageServerException("Project not found for " + filePath);
}
return PROJECT_FOLDER_PATH + fileEntry.getProject();
}
Aggregations