protected void validateAndSwitchVersionOfExecution(CommandContext commandContext, ExecutionEntity execution, ProcessDefinitionEntity newProcessDefinition) {
// check that the new process definition version contains the current activity
if (execution.getActivity() != null) {
String activityId = execution.getActivity().getId();
ActivityImpl newActivity = newProcessDefinition.findActivity(activityId);
if (newActivity == null) {
throw new ProcessEngineException(
"The new process definition " +
"(key = '" + newProcessDefinition.getKey() + "') " +