@POST
  @Path("/submitJob")
  @Consumes({MediaType.TEXT_PLAIN + "," + MediaType.TEXT_XML})
  public Response submitJob(String postBody, @Context HttpHeaders headers,
                            @Context UriInfo ui, @QueryParam("app.path") String appPath,
                            @QueryParam("projectId") String projectId,
                            @DefaultValue("false") @QueryParam("overwrite") Boolean overwrite,
                            @QueryParam("description") String description,
                            @QueryParam("jobType") String jobTypeString) {
    LOGGER.info("submit workflow job called");
    JobType jobType = JobType.valueOf(jobTypeString);
    if (StringUtils.isEmpty(appPath)) {
      throw new WfmWebException(ErrorCode.INVALID_EMPTY_INPUT);
    }
    appPath = workflowFilesService.getWorkflowFileName(appPath.trim(), jobType);
    try {
      if (!overwrite) {
        boolean fileExists = hdfsFileUtils.fileExists(appPath);
        if (fileExists) {
          throw new WfmWebException(ErrorCode.WORKFLOW_PATH_EXISTS);
        }
      }
      postBody = utils.formatXml(postBody);

      String filePath = workflowFilesService.createFile(appPath, postBody, overwrite);
      LOGGER.info(String.format("submit workflow job done. filePath=[%s]", filePath));

      if (PROJ_MANAGER_ENABLED) {
        String name = oozieUtils.deduceWorkflowNameFromXml(postBody);
        workflowManagerService.saveWorkflow(projectId, appPath, jobType,
          null, viewContext.getUsername(), name);
      }
      String response = oozieDelegate.submitWorkflowJobToOozie(headers,
        appPath, ui.getQueryParameters(), jobType);
      return Response.status(Status.OK).entity(response).build();
    } catch (WfmWebException ex) {
      LOGGER.error(ex.getMessage(),ex);
      throw ex;
    } catch(WfmException ex){
      LOGGER.error(ex.getMessage(),ex);
      throw new WfmWebException(ex,ex.getErrorCode());
    } 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