Search in sources :

Example 1 with GetLocalFileContentResponse

use of org.eclipse.che.plugin.zdb.server.connection.ZendDbgClientMessages.GetLocalFileContentResponse 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)

Aggregations

DebuggerException (org.eclipse.che.api.debugger.server.exceptions.DebuggerException)1 VirtualFileEntry (org.eclipse.che.api.project.server.VirtualFileEntry)1 GetLocalFileContentResponse (org.eclipse.che.plugin.zdb.server.connection.ZendDbgClientMessages.GetLocalFileContentResponse)1