public StartWorkflowResponse startWorkflow(StartWorkflowRequest request) {

    String workflowClassId = workflowClassDao.findByName(request.getWorkflowClass()).get_id();

    Workflow wf = workflowEngine.createNewWorkflow(workflowClassId, request.getAttributes());

    Event e = new Event();
    e.setEventType(WorkflowEventType.INITIATE_WORKFLOW);
    e.setWorkflowId(wf.get_id());
    e.setAttributes(request.getAttributes()); // todo should the attributes be in event as well?
    workflowEngine.submitEvent(e);
    log.info("New workflow initiated: " + wf);
    StartWorkflowResponse response = new StartWorkflowResponse();
    response.setWorkflowId(wf.get_id());
    response.setStatus(EndpointResponseStatus.OK);
    return response;
  }
  public EndpointResponse submitEvent(SubmitEventRequest request) {

    try {
      workflowEngine.submitEvent(request.getEvent());
      return EndpointHelper.createResponse(EndpointResponse.class, request);

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