public long newTask(String name, Map<String, Object> params) {
    TaskDef taskDef = taskDefService.getTaskDefById(name);

    Task task = TaskFactory.newTask(taskDef);
    em.persist(task);
    if (params != null) {
      ContentData contentData = ContentMarshallerHelper.marshal(params, null);
      Content content = new Content(contentData.getContent());
      em.persist(content);
      task.getTaskData().setDocument(content.getId(), contentData);
    }

    return task.getId();
  }
  public long newTask(TaskDef taskDef, Map<String, Object> params, boolean deploy) {
    // TODO: need to deal with the params for the content
    if (deploy) {
      taskDefService.deployTaskDef(taskDef);
    }
    Task task = TaskFactory.newTask(taskDef);
    em.persist(task);
    if (params != null) {
      ContentData contentData = ContentMarshallerHelper.marshal(params, null);
      Content content = new Content(contentData.getContent());
      em.persist(content);
      task.getTaskData().setDocument(content.getId(), contentData);
    }

    return task.getId();
  }