Search in sources :

Example 1 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class DelegateExpressionTaskListener method notify.

public void notify(DelegateTask delegateTask) {
    // Note: we can't cache the result of the expression, because the
    // execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}'
    Object delegate = expression.getValue(delegateTask.getExecution());
    ClassDelegate.applyFieldDeclaration(fieldDeclarations, delegate);
    if (delegate instanceof TaskListener) {
        try {
            Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(new TaskListenerInvocation((TaskListener) delegate, delegateTask));
        } catch (Exception e) {
            throw new ActivitiException("Exception while invoking TaskListener: " + e.getMessage(), e);
        }
    } else {
        throw new ActivitiIllegalArgumentException("Delegate expression " + expression + " did not resolve to an implementation of " + TaskListener.class);
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) TaskListenerInvocation(org.activiti.engine.impl.delegate.TaskListenerInvocation) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) TaskListener(org.activiti.engine.delegate.TaskListener) ActivitiException(org.activiti.engine.ActivitiException) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException)

Example 2 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class BpmnParse method getImporter.

protected XMLImporter getImporter(Import theImport) {
    if (this.importers.containsKey(theImport.getImportType())) {
        return this.importers.get(theImport.getImportType());
    } else {
        if (theImport.getImportType().equals("http://schemas.xmlsoap.org/wsdl/")) {
            Class<?> wsdlImporterClass;
            try {
                wsdlImporterClass = Class.forName("org.activiti.engine.impl.webservice.CxfWSDLImporter", true, Thread.currentThread().getContextClassLoader());
                XMLImporter newInstance = (XMLImporter) wsdlImporterClass.newInstance();
                this.importers.put(theImport.getImportType(), newInstance);
                return newInstance;
            } catch (Exception e) {
                throw new ActivitiException("Could not find importer for type " + theImport.getImportType());
            }
        }
        return null;
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ActivitiException(org.activiti.engine.ActivitiException) XMLException(org.activiti.bpmn.exceptions.XMLException) MalformedURLException(java.net.MalformedURLException) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException)

Example 3 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class BpmnParse method createItemDefinitions.

protected void createItemDefinitions() {
    for (org.activiti.bpmn.model.ItemDefinition itemDefinitionElement : bpmnModel.getItemDefinitions().values()) {
        StructureDefinition structure = null;
        try {
            // it is a class
            Class<?> classStructure = ReflectUtil.loadClass(itemDefinitionElement.getStructureRef());
            structure = new ClassStructureDefinition(classStructure);
        } catch (ActivitiException e) {
            // it is a reference to a different structure
            structure = this.structures.get(itemDefinitionElement.getStructureRef());
        }
        ItemDefinition itemDefinition = new ItemDefinition(itemDefinitionElement.getId(), structure);
        if (StringUtils.isNotEmpty(itemDefinitionElement.getItemKind())) {
            itemDefinition.setItemKind(ItemKind.valueOf(itemDefinitionElement.getItemKind()));
        }
        itemDefinitions.put(itemDefinition.getId(), itemDefinition);
    }
}
Also used : ClassStructureDefinition(org.activiti.engine.impl.bpmn.data.ClassStructureDefinition) StructureDefinition(org.activiti.engine.impl.bpmn.data.StructureDefinition) ClassStructureDefinition(org.activiti.engine.impl.bpmn.data.ClassStructureDefinition) ActivitiException(org.activiti.engine.ActivitiException) ItemDefinition(org.activiti.engine.impl.bpmn.data.ItemDefinition)

Example 4 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class CdiActivitiTestCase method waitForJobExecutorToProcessAllJobs.

//////////////////////// copied from AbstractActivitiTestcase
public void waitForJobExecutorToProcessAllJobs(long maxMillisToWait, long intervalMillis) {
    JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
    jobExecutor.start();
    try {
        Timer timer = new Timer();
        InteruptTask task = new InteruptTask(Thread.currentThread());
        timer.schedule(task, maxMillisToWait);
        boolean areJobsAvailable = true;
        try {
            while (areJobsAvailable && !task.isTimeLimitExceeded()) {
                Thread.sleep(intervalMillis);
                areJobsAvailable = areJobsAvailable();
            }
        } catch (InterruptedException e) {
        } finally {
            timer.cancel();
        }
        if (areJobsAvailable) {
            throw new ActivitiException("time limit of " + maxMillisToWait + " was exceeded");
        }
    } finally {
        jobExecutor.shutdown();
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) Timer(java.util.Timer) JobExecutor(org.activiti.engine.impl.jobexecutor.JobExecutor)

Example 5 with ActivitiException

use of org.activiti.engine.ActivitiException in project Activiti by Activiti.

the class CdiActivitiTestCase method waitForJobExecutorOnCondition.

public void waitForJobExecutorOnCondition(long maxMillisToWait, long intervalMillis, Callable<Boolean> condition) {
    JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
    jobExecutor.start();
    try {
        Timer timer = new Timer();
        InteruptTask task = new InteruptTask(Thread.currentThread());
        timer.schedule(task, maxMillisToWait);
        boolean conditionIsViolated = true;
        try {
            while (conditionIsViolated) {
                Thread.sleep(intervalMillis);
                conditionIsViolated = !condition.call();
            }
        } catch (InterruptedException e) {
        } catch (Exception e) {
            throw new ActivitiException("Exception while waiting on condition: " + e.getMessage(), e);
        } finally {
            timer.cancel();
        }
        if (conditionIsViolated) {
            throw new ActivitiException("time limit of " + maxMillisToWait + " was exceeded");
        }
    } finally {
        jobExecutor.shutdown();
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) Timer(java.util.Timer) JobExecutor(org.activiti.engine.impl.jobexecutor.JobExecutor) ActivitiException(org.activiti.engine.ActivitiException)

Aggregations

ActivitiException (org.activiti.engine.ActivitiException)272 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)45 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)44 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)38 IOException (java.io.IOException)34 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)22 ArrayList (java.util.ArrayList)21 ByteArrayOutputStream (java.io.ByteArrayOutputStream)19 FlowElement (org.activiti.bpmn.model.FlowElement)19 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)17 Expression (org.activiti.engine.delegate.Expression)17 CommandContext (org.activiti.engine.impl.interceptor.CommandContext)17 ObjectOutputStream (java.io.ObjectOutputStream)15 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)12 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)12 HashMap (java.util.HashMap)11 ExecutionEntityManager (org.activiti.engine.impl.persistence.entity.ExecutionEntityManager)11 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)11 RestVariable (org.activiti.rest.service.api.engine.variable.RestVariable)10 InputStream (java.io.InputStream)9