use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class ProcessEngineConfigurationImpl method getDefaultBpmnParseHandlers.
protected List<BpmnParseHandler> getDefaultBpmnParseHandlers() {
// Alpabetic list of default parse handler classes
List<BpmnParseHandler> bpmnParserHandlers = new ArrayList<BpmnParseHandler>();
bpmnParserHandlers.add(new BoundaryEventParseHandler());
bpmnParserHandlers.add(new BusinessRuleParseHandler());
bpmnParserHandlers.add(new CallActivityParseHandler());
bpmnParserHandlers.add(new CancelEventDefinitionParseHandler());
bpmnParserHandlers.add(new CompensateEventDefinitionParseHandler());
bpmnParserHandlers.add(new EndEventParseHandler());
bpmnParserHandlers.add(new ErrorEventDefinitionParseHandler());
bpmnParserHandlers.add(new EventBasedGatewayParseHandler());
bpmnParserHandlers.add(new ExclusiveGatewayParseHandler());
bpmnParserHandlers.add(new InclusiveGatewayParseHandler());
bpmnParserHandlers.add(new IntermediateCatchEventParseHandler());
bpmnParserHandlers.add(new IntermediateThrowEventParseHandler());
bpmnParserHandlers.add(new ManualTaskParseHandler());
bpmnParserHandlers.add(new MessageEventDefinitionParseHandler());
bpmnParserHandlers.add(new ParallelGatewayParseHandler());
bpmnParserHandlers.add(new ProcessParseHandler());
bpmnParserHandlers.add(new ReceiveTaskParseHandler());
bpmnParserHandlers.add(new ScriptTaskParseHandler());
bpmnParserHandlers.add(new SendTaskParseHandler());
bpmnParserHandlers.add(new SequenceFlowParseHandler());
bpmnParserHandlers.add(new ServiceTaskParseHandler());
bpmnParserHandlers.add(new SignalEventDefinitionParseHandler());
bpmnParserHandlers.add(new StartEventParseHandler());
bpmnParserHandlers.add(new SubProcessParseHandler());
bpmnParserHandlers.add(new EventSubProcessParseHandler());
bpmnParserHandlers.add(new TaskParseHandler());
bpmnParserHandlers.add(new TimerEventDefinitionParseHandler());
bpmnParserHandlers.add(new TransactionParseHandler());
bpmnParserHandlers.add(new UserTaskParseHandler());
// Replace any default handler if the user wants to replace them
if (customDefaultBpmnParseHandlers != null) {
Map<Class<?>, BpmnParseHandler> customParseHandlerMap = new HashMap<Class<?>, BpmnParseHandler>();
for (BpmnParseHandler bpmnParseHandler : customDefaultBpmnParseHandlers) {
for (Class<?> handledType : bpmnParseHandler.getHandledTypes()) {
customParseHandlerMap.put(handledType, bpmnParseHandler);
}
}
for (int i = 0; i < bpmnParserHandlers.size(); i++) {
// All the default handlers support only one type
BpmnParseHandler defaultBpmnParseHandler = bpmnParserHandlers.get(i);
if (defaultBpmnParseHandler.getHandledTypes().size() != 1) {
StringBuilder supportedTypes = new StringBuilder();
for (Class<?> type : defaultBpmnParseHandler.getHandledTypes()) {
supportedTypes.append(" ").append(type.getCanonicalName()).append(" ");
}
throw new ActivitiException("The default BPMN parse handlers should only support one type, but " + defaultBpmnParseHandler.getClass() + " supports " + supportedTypes.toString() + ". This is likely a programmatic error");
} else {
Class<?> handledType = defaultBpmnParseHandler.getHandledTypes().iterator().next();
if (customParseHandlerMap.containsKey(handledType)) {
BpmnParseHandler newBpmnParseHandler = customParseHandlerMap.get(handledType);
log.info("Replacing default BpmnParseHandler " + defaultBpmnParseHandler.getClass().getName() + " with " + newBpmnParseHandler.getClass().getName());
bpmnParserHandlers.set(i, newBpmnParseHandler);
}
}
}
}
// History
for (BpmnParseHandler handler : getDefaultHistoryParseHandlers()) {
bpmnParserHandlers.add(handler);
}
return bpmnParserHandlers;
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class AbstractActivityBpmnParseHandler method createMultiInstanceLoopCharacteristics.
protected void createMultiInstanceLoopCharacteristics(BpmnParse bpmnParse, Activity modelActivity) {
MultiInstanceLoopCharacteristics loopCharacteristics = modelActivity.getLoopCharacteristics();
// Activity Behavior
MultiInstanceActivityBehavior miActivityBehavior = null;
ActivityImpl activity = bpmnParse.getCurrentScope().findActivity(modelActivity.getId());
if (activity == null) {
throw new ActivitiException("Activity " + modelActivity.getId() + " needed for multi instance cannot bv found");
}
if (loopCharacteristics.isSequential()) {
miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createSequentialMultiInstanceBehavior(activity, (AbstractBpmnActivityBehavior) activity.getActivityBehavior());
} else {
miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createParallelMultiInstanceBehavior(activity, (AbstractBpmnActivityBehavior) activity.getActivityBehavior());
}
// ActivityImpl settings
activity.setScope(true);
activity.setProperty("multiInstance", loopCharacteristics.isSequential() ? "sequential" : "parallel");
activity.setActivityBehavior(miActivityBehavior);
ExpressionManager expressionManager = bpmnParse.getExpressionManager();
BpmnModel bpmnModel = bpmnParse.getBpmnModel();
// loopcardinality
if (StringUtils.isNotEmpty(loopCharacteristics.getLoopCardinality())) {
miActivityBehavior.setLoopCardinalityExpression(expressionManager.createExpression(loopCharacteristics.getLoopCardinality()));
}
// completion condition
if (StringUtils.isNotEmpty(loopCharacteristics.getCompletionCondition())) {
miActivityBehavior.setCompletionConditionExpression(expressionManager.createExpression(loopCharacteristics.getCompletionCondition()));
}
// activiti:collection
if (StringUtils.isNotEmpty(loopCharacteristics.getInputDataItem())) {
if (loopCharacteristics.getInputDataItem().contains("{")) {
miActivityBehavior.setCollectionExpression(expressionManager.createExpression(loopCharacteristics.getInputDataItem()));
} else {
miActivityBehavior.setCollectionVariable(loopCharacteristics.getInputDataItem());
}
}
// activiti:elementVariable
if (StringUtils.isNotEmpty(loopCharacteristics.getElementVariable())) {
miActivityBehavior.setCollectionElementVariable(loopCharacteristics.getElementVariable());
}
// activiti:elementIndexVariable
if (StringUtils.isNotEmpty(loopCharacteristics.getElementIndexVariable())) {
miActivityBehavior.setCollectionElementIndexVariable(loopCharacteristics.getElementIndexVariable());
}
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class JtaTransactionContext method rollback.
public void rollback() {
// managed transaction, mark rollback-only if not done so already.
try {
Transaction transaction = getTransaction();
int status = transaction.getStatus();
if (status != Status.STATUS_NO_TRANSACTION && status != Status.STATUS_ROLLEDBACK) {
transaction.setRollbackOnly();
}
} catch (IllegalStateException e) {
throw new ActivitiException("Unexpected IllegalStateException while marking transaction rollback only");
} catch (SystemException e) {
throw new ActivitiException("SystemException while marking transaction rollback only");
}
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class AbstractSetProcessDefinitionStateCmd method findProcessDefinition.
protected List<ProcessDefinitionEntity> findProcessDefinition(CommandContext commandContext) {
// we don't need to do an extra database fetch and we can simply return it, wrapped in a list
if (processDefinitionEntity != null) {
return Arrays.asList(processDefinitionEntity);
}
// Validation of input parameters
if (processDefinitionId == null && processDefinitionKey == null) {
throw new ActivitiIllegalArgumentException("Process definition id or key cannot be null");
}
List<ProcessDefinitionEntity> processDefinitionEntities = new ArrayList<ProcessDefinitionEntity>();
ProcessDefinitionEntityManager processDefinitionManager = commandContext.getProcessDefinitionEntityManager();
if (processDefinitionId != null) {
ProcessDefinitionEntity processDefinitionEntity = processDefinitionManager.findProcessDefinitionById(processDefinitionId);
if (processDefinitionEntity == null) {
throw new ActivitiObjectNotFoundException("Cannot find process definition for id '" + processDefinitionId + "'", ProcessDefinition.class);
}
processDefinitionEntities.add(processDefinitionEntity);
} else {
ProcessDefinitionQueryImpl query = new ProcessDefinitionQueryImpl(commandContext).processDefinitionKey(processDefinitionKey);
if (tenantId == null || ProcessEngineConfiguration.NO_TENANT_ID.equals(tenantId)) {
query.processDefinitionWithoutTenantId();
} else {
query.processDefinitionTenantId(tenantId);
}
List<ProcessDefinition> processDefinitions = query.list();
if (processDefinitions.isEmpty()) {
throw new ActivitiException("Cannot find process definition for key '" + processDefinitionKey + "'");
}
for (ProcessDefinition processDefinition : processDefinitions) {
processDefinitionEntities.add((ProcessDefinitionEntity) processDefinition);
}
}
return processDefinitionEntities;
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class ErrorPropagation method executeCatch.
private static void executeCatch(String errorHandlerId, ActivityExecution execution, String errorCode) {
ProcessDefinitionImpl processDefinition = ((ExecutionEntity) execution).getProcessDefinition();
ActivityImpl errorHandler = processDefinition.findActivity(errorHandlerId);
if (errorHandler == null) {
throw new ActivitiException(errorHandlerId + " not found in process definition");
}
boolean matchingParentFound = false;
ActivityExecution leavingExecution = execution;
ActivityImpl currentActivity = (ActivityImpl) execution.getActivity();
ScopeImpl catchingScope = errorHandler.getParent();
if (catchingScope instanceof ActivityImpl) {
ActivityImpl catchingScopeActivity = (ActivityImpl) catchingScope;
if (!catchingScopeActivity.isScope()) {
// event subprocesses
catchingScope = catchingScopeActivity.getParent();
}
}
if (catchingScope instanceof PvmProcessDefinition) {
executeEventHandler(errorHandler, ((ExecutionEntity) execution).getProcessInstance(), errorCode);
} else {
if (currentActivity.getId().equals(catchingScope.getId())) {
matchingParentFound = true;
} else {
currentActivity = (ActivityImpl) currentActivity.getParent();
// and matches the activity the boundary event is defined on
while (!matchingParentFound && leavingExecution != null && currentActivity != null) {
if (!leavingExecution.isConcurrent() && currentActivity.getId().equals(catchingScope.getId())) {
matchingParentFound = true;
} else if (leavingExecution.isConcurrent()) {
leavingExecution = leavingExecution.getParent();
} else {
currentActivity = currentActivity.getParentActivity();
leavingExecution = leavingExecution.getParent();
}
}
// Follow parents up until matching scope can't be found anymore (needed to support for multi-instance)
while (leavingExecution != null && leavingExecution.getParent() != null && leavingExecution.getParent().getActivity() != null && leavingExecution.getParent().getActivity().getId().equals(catchingScope.getId())) {
leavingExecution = leavingExecution.getParent();
}
}
if (matchingParentFound && leavingExecution != null) {
executeEventHandler(errorHandler, leavingExecution, errorCode);
} else {
throw new ActivitiException("No matching parent execution for activity " + errorHandlerId + " found");
}
}
}
Aggregations