public long addTask(Task task, Map<String, Object> params) {
   doCallbackOperationForPeopleAssignments(task.getPeopleAssignments());
   doCallbackOperationForTaskData(task.getTaskData());
   doCallbackOperationForTaskDeadlines(task.getDeadlines());
   if (params != null) {
     ContentData contentData = ContentMarshallerHelper.marshal(params, null);
     Content content = new Content(contentData.getContent());
     em.persist(content);
     task.getTaskData().setDocument(content.getId(), contentData);
   }
   em.persist(task);
   return task.getId();
 }
  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();
  }
  public long addTask(Task task, ContentData contentData) {
    doCallbackOperationForPeopleAssignments(task.getPeopleAssignments());
    doCallbackOperationForTaskData(task.getTaskData());
    doCallbackOperationForTaskDeadlines(task.getDeadlines());
    em.persist(task);
    if (contentData != null) {
      Content content = new Content(contentData.getContent());
      em.persist(content);
      task.getTaskData().setDocument(content.getId(), contentData);
    }

    return task.getId();
  }