Search in sources :

Example 11 with CommandChecker

use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.

the class SubmitTaskFormCmd method execute.

public Object execute(CommandContext commandContext) {
    ensureNotNull("taskId", taskId);
    TaskManager taskManager = commandContext.getTaskManager();
    TaskEntity task = taskManager.findTaskById(taskId);
    ensureNotNull("Cannot find task with id " + taskId, "task", task);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkTaskWork(task);
    }
    TaskDefinition taskDefinition = task.getTaskDefinition();
    if (taskDefinition != null) {
        TaskFormHandler taskFormHandler = taskDefinition.getTaskFormHandler();
        taskFormHandler.submitFormVariables(properties, task);
    } else {
        // set variables on standalone task
        task.setVariables(properties);
    }
    // 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;
}
Also used : TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) TaskManager(org.camunda.bpm.engine.impl.persistence.entity.TaskManager) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) TaskFormHandler(org.camunda.bpm.engine.impl.form.handler.TaskFormHandler) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 12 with CommandChecker

use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.

the class GetExternalTaskErrorDetailsCmd method execute.

public String execute(CommandContext commandContext) {
    ensureNotNull("externalTaskId", externalTaskId);
    ExternalTaskEntity externalTask = commandContext.getExternalTaskManager().findExternalTaskById(externalTaskId);
    ensureNotNull("No external task found with id " + externalTaskId, "externalTask", externalTask);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkReadProcessInstance(externalTask.getProcessInstanceId());
    }
    return externalTask.getErrorDetails();
}
Also used : ExternalTaskEntity(org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 13 with CommandChecker

use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.

the class GetFormKeyCmd method execute.

public String execute(CommandContext commandContext) {
    ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
    DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();
    ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkReadProcessDefinition(processDefinition);
    }
    Expression formKeyExpression = null;
    if (taskDefinitionKey == null) {
        // TODO: Maybe add getFormKey() to FormHandler interface to avoid the following cast
        FormHandler formHandler = processDefinition.getStartFormHandler();
        if (formHandler instanceof DelegateStartFormHandler) {
            DelegateStartFormHandler delegateFormHandler = (DelegateStartFormHandler) formHandler;
            formHandler = delegateFormHandler.getFormHandler();
        }
        // form handler (for a startForm) has always to extend the DefaultStartFormHandler!
        if (formHandler instanceof DefaultStartFormHandler) {
            DefaultStartFormHandler startFormHandler = (DefaultStartFormHandler) formHandler;
            formKeyExpression = startFormHandler.getFormKey();
        }
    } else {
        TaskDefinition taskDefinition = processDefinition.getTaskDefinitions().get(taskDefinitionKey);
        formKeyExpression = taskDefinition.getFormKey();
    }
    String formKey = null;
    if (formKeyExpression != null) {
        formKey = formKeyExpression.getExpressionText();
    }
    return formKey;
}
Also used : TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) Expression(org.camunda.bpm.engine.delegate.Expression) DefaultStartFormHandler(org.camunda.bpm.engine.impl.form.handler.DefaultStartFormHandler) FormHandler(org.camunda.bpm.engine.impl.form.handler.FormHandler) DelegateStartFormHandler(org.camunda.bpm.engine.impl.form.handler.DelegateStartFormHandler) DelegateStartFormHandler(org.camunda.bpm.engine.impl.form.handler.DelegateStartFormHandler) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) DefaultStartFormHandler(org.camunda.bpm.engine.impl.form.handler.DefaultStartFormHandler) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 14 with CommandChecker

use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.

the class GetHistoricJobLogExceptionStacktraceCmd method execute.

public String execute(CommandContext commandContext) {
    ensureNotNull("historicJobLogId", historicJobLogId);
    HistoricJobLogEventEntity job = commandContext.getHistoricJobLogManager().findHistoricJobLogById(historicJobLogId);
    ensureNotNull("No historic job log found with id " + historicJobLogId, "historicJobLog", job);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkReadHistoricJobLog(job);
    }
    return job.getExceptionStacktrace();
}
Also used : CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker) HistoricJobLogEventEntity(org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogEventEntity)

Example 15 with CommandChecker

use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.

the class GetJobExceptionStacktraceCmd method execute.

public String execute(CommandContext commandContext) {
    ensureNotNull("jobId", jobId);
    JobEntity job = commandContext.getJobManager().findJobById(jobId);
    ensureNotNull("No job found with id " + jobId, "job", job);
    for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
        checker.checkReadJob(job);
    }
    return job.getExceptionStacktrace();
}
Also used : JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Aggregations

CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)59 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)14 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)10 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)8 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)7 CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)6 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)6 InputStream (java.io.InputStream)5 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)4 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)3 DecisionDefinitionEntity (org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionDefinitionEntity)3 TaskFormHandler (org.camunda.bpm.engine.impl.form.handler.TaskFormHandler)3 ExternalTaskEntity (org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity)3 JobDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity)3 JobDefinitionManager (org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager)3 PropertyChange (org.camunda.bpm.engine.impl.persistence.entity.PropertyChange)3 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)3 TaskManager (org.camunda.bpm.engine.impl.persistence.entity.TaskManager)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2