gpt4 book ai didi

org.eclipse.che.api.fs.server.WsPathUtils类的使用及代码示例

转载 作者:知者 更新时间:2024-03-26 11:05:05 27 4
gpt4 key购买 nike

本文整理了Java中org.eclipse.che.api.fs.server.WsPathUtils类的一些代码示例,展示了WsPathUtils类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WsPathUtils类的具体详情如下:
包路径:org.eclipse.che.api.fs.server.WsPathUtils
类名称:WsPathUtils

WsPathUtils介绍

暂无

代码示例

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-java-ext-lang-server

throws ServerException, NotFoundException {
try {
 String projectWsPath = absolutize(projectPath);
 String projectCheFolderWsPath = resolve(projectWsPath, CHE_FOLDER);
 String cheFormatterWsPath = resolve(projectCheFolderWsPath, CHE_FORMATTER_XML);

代码示例来源:origin: org.eclipse.che.core/che-core-api-git

private boolean haveChanges(String projectPath, List<String> paths) {
 boolean statusChanged = false;
 for (String path : paths) {
  String filePath = resolve(projectPath, path);
  FileTime fileTime = projectFiles.get(filePath);
  try {
   FileTime currentFileTime = getLastModifiedTime(Paths.get(filePath));
   if (fileTime == null || !fileTime.equals(currentFileTime)) {
    projectFiles.put(filePath, currentFileTime);
    statusChanged = true;
   }
  } catch (IOException exception) {
   if (exception instanceof NoSuchFileException) {
    statusChanged = projectFiles.remove(filePath) != null;
   } else {
    LOG.error(exception.getMessage());
   }
  }
 }
 return statusChanged;
}

代码示例来源:origin: org.eclipse.che.core/che-core-api-git

private Consumer<String> fsEventConsumer() {
 return it -> {
  try {
   String content = fsManager.readAsString(it);
   Type type = content.contains("ref:") ? BRANCH : REVISION;
   String name = type == REVISION ? content : PATTERN.split(content)[1];
   String project = it.substring(1, it.indexOf('/', 1));
   // Update project attributes with new git values
   String wsPath = absolutize(it.split("/")[1]);
   projectManager.setType(wsPath, GitProjectType.TYPE_ID, true);
   endpointIds.forEach(transmitConsumer(type, name, project));
  } catch (ServerException | ForbiddenException e) {
   LOG.error("Error trying to read {} file and broadcast it", it, e);
  } catch (NotFoundException | ConflictException | BadRequestException e) {
   LOG.error("Error trying to update project attributes", it, e);
  }
 };
}

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-zend-debugger-server

/**
 * Convert DBG specific location to VFS one.
 *
 * @return VFS specific location.
 */
public Location convertToVFS(Location dbgLocation) {
 String remotePath = dbgLocation.getResourceProjectPath();
 String wsPath = absolutize(remotePath);
 if (wsPath.startsWith("/projects")) {
  wsPath = wsPath.substring("/projects".length());
 }
 if (!fsManager.exists(wsPath)) {
  return null;
 }
 String resourceProjectPath =
   projectManager
     .getClosest(wsPath)
     .orElseThrow(() -> new IllegalArgumentException("Can't find project"))
     .getPath();
 String target = nameOf(wsPath);
 int lineNumber = dbgLocation.getLineNumber();
 return new LocationImpl(
   target,
   lineNumber,
   false,
   null,
   resourceProjectPath,
   dbgLocation.getMethod(),
   dbgLocation.getThreadId());
}

代码示例来源:origin: org.eclipse.che.core/che-core-api-git

final String projectName = nameOf(dst);

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-cpp-lang-server

@Override
public void onCreateProject(
  String projectWsPath, Map<String, AttributeValue> attributes, Map<String, String> options)
  throws ForbiddenException, ConflictException, ServerException, NotFoundException {
 try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(RESOURCE_NAME)) {
  fsManager.createDir(projectWsPath);
  String wsPath = resolve(projectWsPath, FILE_NAME);
  fsManager.createFile(wsPath, inputStream);
 } catch (IOException e) {
  throw new ServerException(e);
 }
}

代码示例来源:origin: org.eclipse.che.core/che-core-api-languageserver

private List<TextEditDto> editFile(FileEditParams params) {
 try {
  String wsPath = absolutize(params.getUri());

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-java-ext-lang-server

@POST
@Path("update/workspace")
@Consumes(MediaType.TEXT_PLAIN)
@ApiOperation(value = "Updates configuration of the jav formatter for the workspace")
@ApiResponses({
 @ApiResponse(code = 200, message = "Formatter was imported successfully"),
 @ApiResponse(code = 500, message = "Internal server error occurred")
})
public void updateRootFormatter(
  @ApiParam(value = "The content of the formatter. Eclipse code formatting is supported only")
    String content)
  throws ServerException {
 try {
  String rootCheFolderWsPath = absolutize(CHE_FOLDER);
  if (!fsManager.existsAsDir(rootCheFolderWsPath)) {
   fsManager.createDir(rootCheFolderWsPath);
  }
  String cheFormatterWsPath = resolve(rootCheFolderWsPath, CHE_FORMATTER_XML);
  if (!fsManager.existsAsFile(cheFormatterWsPath)) {
   fsManager.createFile(cheFormatterWsPath, content);
  } else {
   fsManager.update(cheFormatterWsPath, content);
  }
 } catch (ServerException | ConflictException | NotFoundException e) {
  throw new ServerException(e);
 }
}

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-cpp-lang-server

@Override
public void onCreateProject(
  String projectWsPath, Map<String, AttributeValue> attributes, Map<String, String> options)
  throws ForbiddenException, ConflictException, ServerException, NotFoundException {
 try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(RESOURCE_NAME)) {
  fsManager.createDir(projectWsPath);
  String wsPath = resolve(projectWsPath, FILE_NAME);
  fsManager.createFile(wsPath, inputStream);
 } catch (IOException e) {
  throw new ServerException(e);
 }
}

代码示例来源:origin: org.eclipse.che.core/che-core-api-git

String itemPath = normalizedPath.substring(normalizedPath.indexOf("/") + 1);
String projectName = normalizedPath.split("/")[0];
if (!projectManager.isRegistered(absolutize(projectName))) {
 throw new NotFoundException("Project '" + projectName + "' is not found");

代码示例来源:origin: org.eclipse.che.core/che-core-api-git

@DELETE
@Path("repository")
public void deleteRepository(@Context UriInfo uriInfo) throws ApiException {
 ProjectConfig project =
   projectManager
     .get(projectPath)
     .orElseThrow(() -> new NotFoundException("Can't find project"));
 String dotGitWsPath = resolve(absolutize(projectPath), ".git");
 fsManager.delete(dotGitWsPath);
 eventService.publish(
   newDto(GitRepositoryDeletedEvent.class)
     .withProjectName(project.getName())
     .withProjectPath(projectPath));
}

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-nodejs-lang-server

@Override
public void onCreateProject(
  String projectWsPath, Map<String, AttributeValue> attributes, Map<String, String> options)
  throws ForbiddenException, ConflictException, ServerException, NotFoundException {
 try (InputStream inputStream =
   getClass().getClassLoader().getResourceAsStream("files/default_node_content")) {
  fsManager.createDir(projectWsPath);
  String wsPath = resolve(projectWsPath, "hello.js");
  fsManager.createFile(wsPath, inputStream);
 } catch (IOException e) {
  throw new ServerException(e);
 }
}

代码示例来源:origin: org.eclipse.che.core/che-core-api-languageserver

String wsPath = absolutize(path);

代码示例来源:origin: org.eclipse.che.core/che-core-api-git

ProjectConfig project =
  projectManager
    .getClosest(absolutize(wsPath))
    .orElseThrow(() -> new NotFoundException("Can't find project"));
String projectFsPath = pathTransformer.transform(project.getPath()).toString();
paths.forEach(
  path -> {
   String itemWsPath = resolve(project.getPath(), path);
   if (status.getUntracked().contains(path)) {
    statusMap.put(itemWsPath, UNTRACKED);

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-python-lang-server

@Override
public void onCreateProject(
  String projectWsPath, Map<String, AttributeValue> attributes, Map<String, String> options)
  throws ForbiddenException, ConflictException, ServerException, NotFoundException {
 try (InputStream inputStream =
   getClass().getClassLoader().getResourceAsStream("files/default_python_content")) {
  fsManager.createDir(projectWsPath);
  String wsPath = resolve(projectWsPath, "main.py");
  fsManager.createFile(wsPath, inputStream);
 } catch (IOException e) {
  throw new ServerException(e);
 }
}

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-zend-debugger-server

private GetLocalFileContentResponse handleGetLocalFileContent(
  GetLocalFileContentRequest request) {
 String remoteFilePath = request.getFileName();
 String wsPath = absolutize(remoteFilePath);
 if (!fsManager.exists(wsPath)) {
  LOG.error("Could not found corresponding local file for: " + remoteFilePath);
  return new GetLocalFileContentResponse(
    request.getID(), GetLocalFileContentResponse.STATUS_FAILURE, null);
 }
 try {
  byte[] localFileContent = fsManager.readAsString(wsPath).getBytes();
  // Check if remote content is equal to corresponding local one
  if (ZendDbgConnectionUtils.isRemoteContentEqual(
    request.getSize(), request.getCheckSum(), localFileContent)) {
   // Remote and local contents are identical
   return new GetLocalFileContentResponse(
     request.getID(), GetLocalFileContentResponse.STATUS_FILES_IDENTICAL, null);
  }
  // Remote and local contents are different, send local content to the engine
  return new GetLocalFileContentResponse(
    request.getID(), GetLocalFileContentResponse.STATUS_SUCCESS, localFileContent);
 } catch (Exception e) {
  LOG.error(e.getMessage(), e);
 }
 return new GetLocalFileContentResponse(
   request.getID(), GetLocalFileContentResponse.STATUS_FAILURE, null);
}

代码示例来源:origin: org.eclipse.che.core/che-core-api-git

@Override
public Map<String, VcsStatus> getStatus(String wsPath, List<String> paths)
  throws ServerException {
 Map<String, VcsStatus> result = new HashMap<>();
 try {
  ProjectConfig project =
    projectManager
      .getClosest(absolutize(wsPath))
      .orElseThrow(() -> new NotFoundException("Can't find project"));
  Status status =
    getStatus(
      project.getName(), pathTransformer.transform(project.getPath()).toString(), paths);
  paths.forEach(
    path -> {
     String itemWsPath = resolve(project.getPath(), path);
     if (status.getUntracked().contains(path)) {
      result.put(itemWsPath, UNTRACKED);
     } else if (status.getAdded().contains(path)) {
      result.put(itemWsPath, ADDED);
     } else if (status.getModified().contains(path) || status.getChanged().contains(path)) {
      result.put(itemWsPath, MODIFIED);
     } else {
      result.put(itemWsPath, NOT_MODIFIED);
     }
    });
 } catch (NotFoundException e) {
  throw new ServerException(e.getMessage());
 }
 return result;
}

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-ceylon-lang-server

@Override
public void onCreateProject(
  String projectWsPath, Map<String, AttributeValue> attributes, Map<String, String> options)
  throws ForbiddenException, ConflictException, ServerException, NotFoundException {
 fsManager.createDir(projectWsPath);
 fsManager.createDir(resolve(projectWsPath, "source"));
 fsManager.createDir(resolve(projectWsPath, "resource"));
 for (String file : PROJECT_FILES) {
  InputStream inputStream = new ByteArrayInputStream(getProjectContent("project/" + file));
  String wsPath = resolve(projectWsPath, file);
  fsManager.createFile(wsPath, inputStream, true, true);
  if (file.startsWith("ceylonb")) {
   fsManager.toIoFile(wsPath).setExecutable(true);
  }
 }
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com