TaskImpl task = dbSession.get(TaskImpl.class, Long.parseLong(taskId));
if (task==null) {
throw new JbpmException("task "+taskId+" does not exist");
}
if (take) {
task.take(userId);
} else {
task.setAssignee(userId, true);
}
HistoryEvent.fire(new TaskAssign(task, userId));