NodeDef node = app.getNode(transitions.get(i));
if (node instanceof DecisionNodeDef) {
Set<String> decisionSet = new HashSet<String>(node.getTransitions());
for (String ds : decisionSet) {
if (transitions.contains(ds)) {
throw new WorkflowException(ErrorCode.E0734, node.getName(), ds);
} else {
transitions.add(ds);
}
}
} else if (node instanceof ActionNodeDef) {
// Make sure the transition is valid
validateTransition(errorToTransitions, transitions, app, node);
// Add the "ok-to" transition of node
transitions.add(node.getTransitions().get(0));
String errorTo = node.getTransitions().get(1);
// Add the "error-to" transition if the transition is a Action Node
if (app.getNode(errorTo) instanceof ActionNodeDef) {
errorToTransitions.add(errorTo);
}
} else if (node instanceof ForkNodeDef) {
forkList.remove(node.getName());
// Make a recursive call to resolve this fork node
NodeDef joinNd = validateFork(node, app);
// Make sure the transition is valid
validateTransition(errorToTransitions, transitions, app, node);
// Add the "ok-to" transition of node
transitions.add(joinNd.getTransitions().get(0));
} else if (node instanceof JoinNodeDef) {
// If joinNode encountered for the first time, remove it from the joinList and remember it
String currentJoin = node.getName();
if (joinList.contains(currentJoin)) {
joinList.remove(currentJoin);
joinNode = currentJoin;
} else {
// Make sure this join is the same as the join seen from the first time
if (joinNode == null) {
throw new WorkflowException(ErrorCode.E0733, forkNode);
}
if (!joinNode.equals(currentJoin)) {
throw new WorkflowException(ErrorCode.E0732, forkNode, joinNode);
}
}
} else {
throw new WorkflowException(ErrorCode.E0730);
}
}
return app.getNode(joinNode);
}