}
public Object execute(CommandContext commandContext) {
ensureNotNull("taskId", taskId);
TaskEntity task = Context
.getCommandContext()
.getTaskManager()
.findTaskById(taskId);
ensureNotNull("Cannot find task with id " + taskId, "task", task);
final ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
int historyLevel = processEngineConfiguration.getHistoryLevel();
ExecutionEntity execution = task.getExecution();
if (historyLevel >= ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT && execution != null) {
final HistoryEventProducer eventProducer = processEngineConfiguration.getHistoryEventProducer();
final HistoryEventHandler eventHandler = processEngineConfiguration.getHistoryEventHandler();
for (String propertyId : properties.keySet()) {
Object propertyValue = properties.get(propertyId);
HistoryEvent evt = eventProducer.createFormPropertyUpdateEvt(execution, propertyId, propertyValue, taskId);
eventHandler.handleEvent(evt);
}
}
TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
taskFormHandler.submitFormProperties(properties, task.getExecution());
// complete or resolve the task
if (DelegationState.PENDING.equals(task.getDelegationState())) {
task.resolve();
task.createHistoricTaskDetails(UserOperationLogEntry.OPERATION_TYPE_RESOLVE);
} else {
task.complete();
task.createHistoricTaskDetails(UserOperationLogEntry.OPERATION_TYPE_COMPLETE);
}
return null;
}