public EndpointResponse removeWorkflow(RemoveWorkflowRequest request) {
    try {
      workflowDao.remove(request.getWorkflowId());

      for (Job j : jobDao.findJobs(request.getWorkflowId(), null)) {
        jobDao.remove(j.get_id());
      }

      return EndpointHelper.createResponse(EndpointResponse.class, request);

    } catch (Exception e) {
      return EndpointHelper.createErrorResponse(EndpointResponse.class, request, e);
    }
  }
  public EndpointResponse removeJob(RemoveJobRequest request) {
    try {
      jobDao.remove(request.getJobId());
      return EndpointHelper.createResponse(EndpointResponse.class, request);

    } catch (Exception e) {
      return EndpointHelper.createErrorResponse(EndpointResponse.class, request, e);
    }
  }
  public ListJobsResponse listJobs(ListJobsRequest request) {
    try {
      ListJobsResponse r = EndpointHelper.createResponse(ListJobsResponse.class, request);
      r.setJobs(jobDao.findJobs(request.getWorkflowId(), request.getJobState()));
      return r;

    } catch (Exception e) {
      return EndpointHelper.createErrorResponse(ListJobsResponse.class, request, e);
    }
  }
  public FindJobResponse findJob(FindJobRequest request) {

    try {
      FindJobResponse r = EndpointHelper.createResponse(FindJobResponse.class, request);
      r.setJob(jobDao.get(request.getJobId()));
      return r;

    } catch (Exception e) {
      return EndpointHelper.createErrorResponse(FindJobResponse.class, request, e);
    }
  }
  public EndpointResponse submitJob(SubmitJobRequest request) {

    try {
      jobDao.add(request.getJob());
      jobDispatcher.notifyNewJobAdded();
      return EndpointHelper.createResponse(EndpointResponse.class, request);

    } catch (Exception e) {
      return EndpointHelper.createErrorResponse(EndpointResponse.class, request, e);
    }
  }