public virtual void resolve(CompleteTaskDto dto) { TaskService taskService = engine.TaskService; try { VariableMap variables = VariableValueDto.toMap(dto.Variables, engine, objectMapper); taskService.resolveTask(taskId, variables); } catch (RestException e) { string errorMessage = string.Format("Cannot resolve task {0}: {1}", taskId, e.Message); throw new InvalidRequestException(e.Status, e, errorMessage); } }
public virtual Response complete(CompleteTaskDto dto) { TaskService taskService = engine.TaskService; try { VariableMap variables = VariableValueDto.toMap(dto.Variables, engine, objectMapper); if (dto.WithVariablesInReturn) { VariableMap taskVariables = taskService.completeWithVariablesInReturn(taskId, variables, false); IDictionary <string, VariableValueDto> body = VariableValueDto.fromMap(taskVariables, true); return(Response.ok(body).type(MediaType.APPLICATION_JSON).build()); } else { taskService.complete(taskId, variables); return(Response.noContent().build()); } } catch (RestException e) { string errorMessage = string.Format("Cannot complete task {0}: {1}", taskId, e.Message); throw new InvalidRequestException(e.Status, e, errorMessage); } catch (AuthorizationException e) { throw e; } catch (FormFieldValidationException e) { string errorMessage = string.Format("Cannot complete task {0}: {1}", taskId, e.Message); throw new RestException(Response.Status.BAD_REQUEST, e, errorMessage); } catch (ProcessEngineException e) { string errorMessage = string.Format("Cannot complete task {0}: {1}", taskId, e.Message); throw new RestException(Response.Status.INTERNAL_SERVER_ERROR, e, errorMessage); } }