Search in sources :

Example 16 with VirtualFileEntry

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);
}
Also used : VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) LocationImpl(org.eclipse.che.api.debug.shared.model.impl.LocationImpl)

Example 17 with VirtualFileEntry

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);
}
Also used : GetLocalFileContentResponse(org.eclipse.che.plugin.zdb.server.connection.ZendDbgClientMessages.GetLocalFileContentResponse) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) DebuggerException(org.eclipse.che.api.debugger.server.exceptions.DebuggerException)

Example 18 with VirtualFileEntry

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;
}
Also used : Path(org.eclipse.che.api.vfs.Path) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) ServerException(org.eclipse.che.api.core.ServerException)

Example 19 with VirtualFileEntry

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);
    }
}
Also used : MavenServerWrapper(org.eclipse.che.plugin.maven.server.MavenServerWrapper) NotFoundException(org.eclipse.che.api.core.NotFoundException) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 20 with VirtualFileEntry

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();
}
Also used : FolderEntry(org.eclipse.che.api.project.server.FolderEntry) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) MavenServerService(org.eclipse.che.plugin.maven.server.rest.MavenServerService) Problem(org.eclipse.che.ide.ext.java.shared.dto.Problem) IProject(org.eclipse.core.resources.IProject) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Aggregations

VirtualFileEntry (org.eclipse.che.api.project.server.VirtualFileEntry)21 FolderEntry (org.eclipse.che.api.project.server.FolderEntry)11 ServerException (org.eclipse.che.api.core.ServerException)9 Problem (org.eclipse.che.ide.ext.java.shared.dto.Problem)7 ForbiddenException (org.eclipse.che.api.core.ForbiddenException)6 MavenServerService (org.eclipse.che.plugin.maven.server.rest.MavenServerService)6 MavenServerManagerTest (org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)6 Test (org.testng.annotations.Test)6 NotFoundException (org.eclipse.che.api.core.NotFoundException)5 IProject (org.eclipse.core.resources.IProject)5 ConflictException (org.eclipse.che.api.core.ConflictException)4 FileEntry (org.eclipse.che.api.project.server.FileEntry)3 RegisteredProject (org.eclipse.che.api.project.server.RegisteredProject)3 IResourceStatus (org.eclipse.core.resources.IResourceStatus)3 CoreException (org.eclipse.core.runtime.CoreException)3 IStatus (org.eclipse.core.runtime.IStatus)3 MultiStatus (org.eclipse.core.runtime.MultiStatus)3 Status (org.eclipse.core.runtime.Status)3 HashMap (java.util.HashMap)2 List (java.util.List)2