ProcessDefinitionEntity processDefinition = null;
if (processDefinitionId!=null) {
processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
ensureNotNull("No process definition found for id = '" + processDefinitionId + "'", "processDefinition", processDefinition);
} else if(processDefinitionKey != null) {
processDefinition = deploymentCache.findDeployedLatestProcessDefinitionByKey(processDefinitionKey);
ensureNotNull("No process definition found for key '" + processDefinitionKey + "'", "processDefinition", processDefinition);
} else {
throw new ProcessEngineException("processDefinitionKey and processDefinitionId are null");
}