Search in sources :

Example 36 with ProcessEngineConfigurationImpl

use of org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl in project Activiti by Activiti.

the class SecureJavascriptTaskActivityBehavior method execute.

@Override
public void execute(ActivityExecution execution) throws Exception {
    ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl) execution.getEngineServices().getProcessEngineConfiguration();
    if (Context.getProcessEngineConfiguration().isEnableProcessDefinitionInfoCache()) {
        ObjectNode taskElementProperties = Context.getBpmnOverrideElementProperties(scriptTaskId, execution.getProcessDefinitionId());
        if (taskElementProperties != null && taskElementProperties.has(DynamicBpmnConstants.SCRIPT_TASK_SCRIPT)) {
            String overrideScript = taskElementProperties.get(DynamicBpmnConstants.SCRIPT_TASK_SCRIPT).asText();
            if (StringUtils.isNotEmpty(overrideScript) && overrideScript.equals(script) == false) {
                script = overrideScript;
            }
        }
    }
    boolean noErrors = true;
    try {
        Object result = SecureJavascriptUtil.evaluateScript(execution, script, config.getBeans());
        if (resultVariable != null) {
            execution.setVariable(resultVariable, result);
        }
    } catch (ActivitiException e) {
        LOGGER.warn("Exception while executing " + execution.getActivity().getId() + " : " + e.getMessage());
        noErrors = false;
        Throwable rootCause = ExceptionUtils.getRootCause(e);
        if (rootCause instanceof BpmnError) {
            ErrorPropagation.propagateError((BpmnError) rootCause, execution);
        } else {
            throw e;
        }
    }
    if (noErrors) {
        leave(execution);
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ProcessEngineConfigurationImpl(org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) BpmnError(org.activiti.engine.delegate.BpmnError)

Aggregations

ProcessEngineConfigurationImpl (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl)36 ThreadLocalClock (org.activiti.crystalball.simulator.impl.clock.ThreadLocalClock)5 Clock (org.activiti.engine.runtime.Clock)5 ActivitiException (org.activiti.engine.ActivitiException)4 ProcessEngine (org.activiti.engine.ProcessEngine)4 ProcessEngineImpl (org.activiti.engine.impl.ProcessEngineImpl)4 HistoricActivityInstanceEntity (org.activiti.engine.impl.persistence.entity.HistoricActivityInstanceEntity)4 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)4 Date (java.util.Date)3 HashMap (java.util.HashMap)3 IdGenerator (org.activiti.engine.impl.cfg.IdGenerator)3 StandaloneInMemProcessEngineConfiguration (org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration)3 HistoricProcessInstanceEntity (org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity)3 DefaultClockImpl (org.activiti.engine.impl.util.DefaultClockImpl)3 EntityManagerSession (org.activiti.engine.impl.variable.EntityManagerSession)3 EntityManagerSessionFactory (org.activiti.engine.impl.variable.EntityManagerSessionFactory)3 Task (org.activiti.engine.task.Task)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 ArrayList (java.util.ArrayList)2 DefaultClockFactory (org.activiti.crystalball.simulator.impl.clock.DefaultClockFactory)2