use of org.eclipse.che.api.project.server.VirtualFileEntry in project che by eclipse.
the class ZendDbgLocationHandler method convertToVFS.
/**
* Convert DBG specific location to VFS one.
*
* @param dbgLocation
* @return VFS specific location.
*/
public Location convertToVFS(Location dbgLocation) {
VirtualFileEntry localFileEntry = ZendDbgFileUtils.findVirtualFileEntry(dbgLocation.getResourcePath());
if (localFileEntry == null) {
return null;
}
String resourceProjectPath = localFileEntry.getProject();
String target = localFileEntry.getName();
String resourcePath = localFileEntry.getPath().toString();
int lineNumber = dbgLocation.getLineNumber();
return new LocationImpl(target, lineNumber, resourcePath, false, 0, resourceProjectPath);
}
use of org.eclipse.che.api.project.server.VirtualFileEntry in project che by eclipse.
the class ZendDebugger method handleGetLocalFileContent.
private GetLocalFileContentResponse handleGetLocalFileContent(GetLocalFileContentRequest request) {
String remoteFilePath = request.getFileName();
VirtualFileEntry localFileEntry = ZendDbgFileUtils.findVirtualFileEntry(remoteFilePath);
if (localFileEntry == null) {
LOG.error("Could not found corresponding local file for: " + remoteFilePath);
return new GetLocalFileContentResponse(request.getID(), GetLocalFileContentResponse.STATUS_FAILURE, null);
}
try {
byte[] localFileContent = localFileEntry.getVirtualFile().getContentAsBytes();
// 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);
}
use of org.eclipse.che.api.project.server.VirtualFileEntry in project che by eclipse.
the class ZendDbgFileUtils method findVirtualFileEntry.
/**
* Finds local file entry that corresponds to remote file path.
*
* @param remotePath
* @return corresponding local file entry
*/
public static VirtualFileEntry findVirtualFileEntry(String remotePath) {
Path remoteFilePath = Path.of(remotePath);
try {
for (int i = 0; i < remoteFilePath.length(); i++) {
Path path = remoteFilePath.subPath(i);
VirtualFileEntry child = getVirtualFileEntry(path.toString());
if (child != null) {
return child;
}
}
} catch (Exception e) {
ZendDebugger.LOG.error(e.getMessage(), e);
return null;
}
return null;
}
use of org.eclipse.che.api.project.server.VirtualFileEntry in project che by eclipse.
the class MavenServerService method getEffectivePom.
/**
* Returns maven effective pom file.
*
* @param projectPath
* path to the opened pom file
* @return content of the effective pom
* @throws ServerException
* when getting mount point has a problem
* @throws NotFoundException
* when current pom file isn't exist
* @throws ForbiddenException
* when response code is 403
*/
@GET
@Path("effective/pom")
@Produces(TEXT_XML)
public String getEffectivePom(@QueryParam("projectpath") String projectPath) throws ServerException, NotFoundException, ForbiddenException {
RegisteredProject project = projectRegistry.getProject(projectPath);
if (project == null) {
throw new NotFoundException("Project " + projectPath + " doesn't exist");
}
MavenServerWrapper mavenServer = wrapperManager.getMavenServer(MavenWrapperManager.ServerType.DOWNLOAD);
try {
mavenServer.customize(projectManager.copyWorkspaceCache(), terminal, notifier, false, false);
VirtualFileEntry pomFile = project.getBaseFolder().getChild("pom.xml");
if (pomFile == null) {
throw new NotFoundException("pom.xml doesn't exist");
}
return mavenServer.getEffectivePom(pomFile.getVirtualFile().toIoFile(), Collections.emptyList(), Collections.emptyList());
} finally {
wrapperManager.release(mavenServer);
}
}
use of org.eclipse.che.api.project.server.VirtualFileEntry in project che by eclipse.
the class PomReconcilerTest method testReconcilePomWhenPomContainsDependecyWithIncorrectAtrifactId.
@Test
public void testReconcilePomWhenPomContainsDependecyWithIncorrectAtrifactId() throws Exception {
String brokenDependency = " <dependency>\n" + " <groupId>junit</groupId>\n" + " <artifactId>jjjjjjjunit</artifactId>\n" + " <version>3.8.1</version>\n" + " <scope>test</scope>\n" + " </dependency>\n";
MavenServerService serverService = new MavenServerService(null, projectRegistry, pm, projectManager, null, null);
FolderEntry testProject = createTestProject(PROJECT_NAME, getPomContentWithDependency(brokenDependency));
VirtualFileEntry pom = testProject.getChild("pom.xml");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
mavenWorkspace.update(Collections.singletonList(project));
mavenWorkspace.waitForUpdate();
List<Problem> problems = serverService.reconcilePom(String.format("/%s/pom.xml", PROJECT_NAME));
assertThat(problems).hasSize(1);
assertThat(problems.get(0).isError()).isTrue();
assertThat(pom).isNotNull();
}
Aggregations