use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class CamelBehavior method setAppropriateCamelContext.
protected void setAppropriateCamelContext(ActivityExecution execution) {
//Check to see if the springConfiguration has been set. If not, set it.
if (springConfiguration == null) {
//Get the ProcessEngineConfiguration object.
ProcessEngineConfiguration engineConfiguration = Context.getProcessEngineConfiguration();
// (ActivitiException extends RuntimeException.)
try {
springConfiguration = (SpringProcessEngineConfiguration) engineConfiguration;
} catch (Exception e) {
throw new ActivitiException("Expecting a SpringProcessEngineConfiguration for the Activiti Camel module.", e);
}
}
//Get the appropriate String representation of the CamelContext object from ActivityExecution (if available).
String camelContextValue = getStringFromField(camelContext, execution);
//If the String representation of the CamelContext object from ActivityExecution is empty, use the default.
if (StringUtils.isEmpty(camelContextValue) && camelContextObj != null) {
//No processing required. No custom CamelContext & the default is already set.
} else {
if (StringUtils.isEmpty(camelContextValue) && camelContextObj == null) {
camelContextValue = springConfiguration.getDefaultCamelContext();
}
//Get the CamelContext object and set the super's member variable.
Object ctx = springConfiguration.getApplicationContext().getBean(camelContextValue);
if (ctx == null || ctx instanceof CamelContext == false) {
throw new ActivitiException("Could not find CamelContext named " + camelContextValue + ".");
}
camelContextObj = (CamelContext) ctx;
}
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class DeploymentQueryTest method testQueryNoCriteria.
public void testQueryNoCriteria() {
DeploymentQuery query = repositoryService.createDeploymentQuery();
assertEquals(2, query.list().size());
assertEquals(2, query.count());
try {
query.singleResult();
fail();
} catch (ActivitiException e) {
}
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class CallActivityTest method testInstantiateSubprocess.
public void testInstantiateSubprocess() throws Exception {
BpmnModel mainBpmnModel = loadBPMNModel(MAIN_PROCESS_RESOURCE);
BpmnModel childBpmnModel = loadBPMNModel(CHILD_PROCESS_RESOURCE);
Deployment childDeployment = processEngine.getRepositoryService().createDeployment().name("childProcessDeployment").addBpmnModel("childProcess.bpmn20.xml", childBpmnModel).deploy();
Deployment masterDeployment = processEngine.getRepositoryService().createDeployment().name("masterProcessDeployment").addBpmnModel("masterProcess.bpmn20.xml", mainBpmnModel).deploy();
suspendProcessDefinitions(childDeployment);
try {
ProcessInstance masterProcessInstance = runtimeService.startProcessInstanceByKey("masterProcess");
fail("Exception expected");
} catch (ActivitiException ae) {
assertTextPresent("Cannot start process instance. Process definition Child Process", ae.getMessage());
}
}
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);
}
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class BpmnParse method execute.
public BpmnParse execute() {
try {
ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
BpmnXMLConverter converter = new BpmnXMLConverter();
boolean enableSafeBpmnXml = false;
String encoding = null;
if (processEngineConfiguration != null) {
enableSafeBpmnXml = processEngineConfiguration.isEnableSafeBpmnXml();
encoding = processEngineConfiguration.getXmlEncoding();
}
if (encoding != null) {
bpmnModel = converter.convertToBpmnModel(streamSource, validateSchema, enableSafeBpmnXml, encoding);
} else {
bpmnModel = converter.convertToBpmnModel(streamSource, validateSchema, enableSafeBpmnXml);
}
// XSD validation goes first, then process/semantic validation
if (validateProcess) {
ProcessValidator processValidator = processEngineConfiguration.getProcessValidator();
if (processValidator == null) {
LOGGER.warn("Process should be validated, but no process validator is configured on the process engine configuration!");
} else {
List<ValidationError> validationErrors = processValidator.validate(bpmnModel);
if (validationErrors != null && !validationErrors.isEmpty()) {
StringBuilder warningBuilder = new StringBuilder();
StringBuilder errorBuilder = new StringBuilder();
for (ValidationError error : validationErrors) {
if (error.isWarning()) {
warningBuilder.append(error.toString());
warningBuilder.append("\n");
} else {
errorBuilder.append(error.toString());
errorBuilder.append("\n");
}
}
// Throw exception if there is any error
if (errorBuilder.length() > 0) {
throw new ActivitiException("Errors while parsing:\n" + errorBuilder.toString());
}
// Write out warnings (if any)
if (warningBuilder.length() > 0) {
LOGGER.warn("Following warnings encountered during process validation: " + warningBuilder.toString());
}
}
}
}
// Validation successfull (or no validation)
createImports();
createItemDefinitions();
createMessages();
createOperations();
transformProcessDefinitions();
} catch (Exception e) {
if (e instanceof ActivitiException) {
throw (ActivitiException) e;
} else if (e instanceof XMLException) {
throw (XMLException) e;
} else {
throw new ActivitiException("Error parsing XML", e);
}
}
return this;
}
Aggregations