@GET
  @Path("/readWorkflow")
  public Response readWorkflow(
    @QueryParam("workflowPath") String workflowPath, @QueryParam("jobType") String jobTypeStr) {
    try {
      String workflowFileName = workflowFilesService.getWorkflowFileName(workflowPath, JobType.valueOf(jobTypeStr));
      if (!hdfsFileUtils.fileExists(workflowFileName)) {
        throw new WfmWebException(ErrorCode.WORKFLOW_XML_DOES_NOT_EXIST);
      }
      WorkflowFileInfo workflowDetails = workflowFilesService
        .getWorkflowDetails(workflowPath, JobType.valueOf(jobTypeStr));
      if (workflowPath.endsWith(Constants.WF_DRAFT_EXTENSION) || workflowDetails.getIsDraftCurrent()) {
        String filePath = workflowFilesService.getWorkflowDraftFileName(workflowPath, JobType.valueOf(jobTypeStr));

        InputStream inputStream = workflowFilesService.readWorkflowXml(filePath);
        String stringResponse = IOUtils.toString(inputStream);
        if (!workflowFilesService.isDraftFormatCurrent(stringResponse)) {
          filePath = workflowFilesService.getWorkflowFileName(workflowPath, JobType.valueOf(jobTypeStr));
          return getWorkflowResponse(filePath, WorkflowFormat.XML.getValue(), true);
        } else {
          return Response.ok(stringResponse).header(RESPONSE_TYPE, WorkflowFormat.DRAFT.getValue()).build();
        }
      } else {
        String filePath = workflowFilesService.getWorkflowFileName(workflowPath, JobType.valueOf(jobTypeStr));
        return getWorkflowResponse(filePath, WorkflowFormat.XML.getValue(), false);
      }
    } catch (WfmWebException ex) {
      LOGGER.error(ex.getMessage(),ex);
      throw ex;
    } catch (Exception ex) {
      LOGGER.error(ex.getMessage(),ex);
      throw new WfmWebException(ex);
    }
  }
This is a class used to bridge the communication between the and the Oozie
API executing inside ambari.
contrib/views/wfmanager/src/main/java/org/apache/oozie/ambari/view/OozieProxyImpersonator.java