@POST
  @Path("/saveWorkflow")
  @Consumes({MediaType.TEXT_PLAIN + "," + MediaType.TEXT_XML})
  public Response saveWorkflow(String postBody, @Context HttpHeaders headers,
                               @Context UriInfo ui, @QueryParam("app.path") String appPath,
                               @QueryParam("jobType") String jobTypeStr,
                               @DefaultValue("false") @QueryParam("overwrite") Boolean overwrite) {
    LOGGER.info("save workflow  called");
    if (StringUtils.isEmpty(appPath)) {
      throw new WfmWebException(ErrorCode.INVALID_EMPTY_INPUT);
    }
    JobType jobType = StringUtils.isEmpty(jobTypeStr) ? JobType.WORKFLOW : JobType.valueOf(jobTypeStr);
    String workflowFilePath = workflowFilesService.getWorkflowFileName(appPath.trim(), jobType);
    try {
      if (!overwrite) {
        boolean fileExists = hdfsFileUtils.fileExists(workflowFilePath);
        if (fileExists) {
          throw new WfmWebException(ErrorCode.WORKFLOW_PATH_EXISTS);
        }
      }
      if (utils.isXml(postBody)) {
        saveWorkflowXml(jobType, appPath, postBody, overwrite);
      } else {
        saveDraft(jobType, appPath, postBody, overwrite);
      }
      if (PROJ_MANAGER_ENABLED) {
        workflowManagerService.saveWorkflow(null, workflowFilePath, jobType, null,
          viewContext.getUsername(), getWorkflowName(postBody));
      }
    } catch (WfmWebException ex) {
      LOGGER.error(ex.getMessage(),ex);
      throw ex;
    } catch (Exception ex) {
      LOGGER.error(ex.getMessage(),ex);
      throw new WfmWebException(ex);
    }
    return Response.ok().build();
  }
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